babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070
  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. _waitingTransformNodeId: Nullable<string>;
  8065. /** @hidden */
  8066. /** @hidden */
  8067. _matrix: Matrix;
  8068. /**
  8069. * Create a new bone
  8070. * @param name defines the bone name
  8071. * @param skeleton defines the parent skeleton
  8072. * @param parentBone defines the parent (can be null if the bone is the root)
  8073. * @param localMatrix defines the local matrix
  8074. * @param restPose defines the rest pose matrix
  8075. * @param baseMatrix defines the base matrix
  8076. * @param index defines index of the bone in the hiearchy
  8077. */
  8078. constructor(
  8079. /**
  8080. * defines the bone name
  8081. */
  8082. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8083. /**
  8084. * Gets the current object class name.
  8085. * @return the class name
  8086. */
  8087. getClassName(): string;
  8088. /**
  8089. * Gets the parent skeleton
  8090. * @returns a skeleton
  8091. */
  8092. getSkeleton(): Skeleton;
  8093. /**
  8094. * Gets parent bone
  8095. * @returns a bone or null if the bone is the root of the bone hierarchy
  8096. */
  8097. getParent(): Nullable<Bone>;
  8098. /**
  8099. * Returns an array containing the root bones
  8100. * @returns an array containing the root bones
  8101. */
  8102. getChildren(): Array<Bone>;
  8103. /**
  8104. * Sets the parent bone
  8105. * @param parent defines the parent (can be null if the bone is the root)
  8106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8107. */
  8108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8109. /**
  8110. * Gets the local matrix
  8111. * @returns a matrix
  8112. */
  8113. getLocalMatrix(): Matrix;
  8114. /**
  8115. * Gets the base matrix (initial matrix which remains unchanged)
  8116. * @returns a matrix
  8117. */
  8118. getBaseMatrix(): Matrix;
  8119. /**
  8120. * Gets the rest pose matrix
  8121. * @returns a matrix
  8122. */
  8123. getRestPose(): Matrix;
  8124. /**
  8125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8126. */
  8127. getWorldMatrix(): Matrix;
  8128. /**
  8129. * Sets the local matrix to rest pose matrix
  8130. */
  8131. returnToRest(): void;
  8132. /**
  8133. * Gets the inverse of the absolute transform matrix.
  8134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8135. * @returns a matrix
  8136. */
  8137. getInvertedAbsoluteTransform(): Matrix;
  8138. /**
  8139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8140. * @returns a matrix
  8141. */
  8142. getAbsoluteTransform(): Matrix;
  8143. /**
  8144. * Links with the given transform node.
  8145. * The local matrix of this bone is copied from the transform node every frame.
  8146. * @param transformNode defines the transform node to link to
  8147. */
  8148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8149. /** Gets or sets current position (in local space) */
  8150. position: Vector3;
  8151. /** Gets or sets current rotation (in local space) */
  8152. rotation: Vector3;
  8153. /** Gets or sets current rotation quaternion (in local space) */
  8154. rotationQuaternion: Quaternion;
  8155. /** Gets or sets current scaling (in local space) */
  8156. scaling: Vector3;
  8157. /**
  8158. * Gets the animation properties override
  8159. */
  8160. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8161. private _decompose;
  8162. private _compose;
  8163. /**
  8164. * Update the base and local matrices
  8165. * @param matrix defines the new base or local matrix
  8166. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8167. * @param updateLocalMatrix defines if the local matrix should be updated
  8168. */
  8169. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8170. /** @hidden */
  8171. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8172. /**
  8173. * Flag the bone as dirty (Forcing it to update everything)
  8174. */
  8175. markAsDirty(): void;
  8176. private _markAsDirtyAndCompose;
  8177. private _markAsDirtyAndDecompose;
  8178. /**
  8179. * Translate the bone in local or world space
  8180. * @param vec The amount to translate the bone
  8181. * @param space The space that the translation is in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Set the postion of the bone in local or world space
  8187. * @param position The position to set the bone
  8188. * @param space The space that the position is in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. */
  8191. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8192. /**
  8193. * Set the absolute position of the bone (world space)
  8194. * @param position The position to set the bone
  8195. * @param mesh The mesh that this bone is attached to
  8196. */
  8197. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8198. /**
  8199. * Scale the bone on the x, y and z axes (in local space)
  8200. * @param x The amount to scale the bone on the x axis
  8201. * @param y The amount to scale the bone on the y axis
  8202. * @param z The amount to scale the bone on the z axis
  8203. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8204. */
  8205. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8206. /**
  8207. * Set the bone scaling in local space
  8208. * @param scale defines the scaling vector
  8209. */
  8210. setScale(scale: Vector3): void;
  8211. /**
  8212. * Gets the current scaling in local space
  8213. * @returns the current scaling vector
  8214. */
  8215. getScale(): Vector3;
  8216. /**
  8217. * Gets the current scaling in local space and stores it in a target vector
  8218. * @param result defines the target vector
  8219. */
  8220. getScaleToRef(result: Vector3): void;
  8221. /**
  8222. * Set the yaw, pitch, and roll of the bone in local or world space
  8223. * @param yaw The rotation of the bone on the y axis
  8224. * @param pitch The rotation of the bone on the x axis
  8225. * @param roll The rotation of the bone on the z axis
  8226. * @param space The space that the axes of rotation are in
  8227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8228. */
  8229. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8230. /**
  8231. * Add a rotation to the bone on an axis in local or world space
  8232. * @param axis The axis to rotate the bone on
  8233. * @param amount The amount to rotate the bone
  8234. * @param space The space that the axis is in
  8235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8236. */
  8237. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8238. /**
  8239. * Set the rotation of the bone to a particular axis angle in local or world space
  8240. * @param axis The axis to rotate the bone on
  8241. * @param angle The angle that the bone should be rotated to
  8242. * @param space The space that the axis is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. */
  8245. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8246. /**
  8247. * Set the euler rotation of the bone in local of world space
  8248. * @param rotation The euler rotation that the bone should be set to
  8249. * @param space The space that the rotation is in
  8250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8251. */
  8252. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8253. /**
  8254. * Set the quaternion rotation of the bone in local of world space
  8255. * @param quat The quaternion rotation that the bone should be set to
  8256. * @param space The space that the rotation is in
  8257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8258. */
  8259. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8260. /**
  8261. * Set the rotation matrix of the bone in local of world space
  8262. * @param rotMat The rotation matrix that the bone should be set to
  8263. * @param space The space that the rotation is in
  8264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8265. */
  8266. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8267. private _rotateWithMatrix;
  8268. private _getNegativeRotationToRef;
  8269. /**
  8270. * Get the position of the bone in local or world space
  8271. * @param space The space that the returned position is in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The position of the bone
  8274. */
  8275. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8276. /**
  8277. * Copy the position of the bone to a vector3 in local or world space
  8278. * @param space The space that the returned position is in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The vector3 to copy the position to
  8281. */
  8282. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8283. /**
  8284. * Get the absolute position of the bone (world space)
  8285. * @param mesh The mesh that this bone is attached to
  8286. * @returns The absolute position of the bone
  8287. */
  8288. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8289. /**
  8290. * Copy the absolute position of the bone (world space) to the result param
  8291. * @param mesh The mesh that this bone is attached to
  8292. * @param result The vector3 to copy the absolute position to
  8293. */
  8294. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8295. /**
  8296. * Compute the absolute transforms of this bone and its children
  8297. */
  8298. computeAbsoluteTransforms(): void;
  8299. /**
  8300. * Get the world direction from an axis that is in the local space of the bone
  8301. * @param localAxis The local direction that is used to compute the world direction
  8302. * @param mesh The mesh that this bone is attached to
  8303. * @returns The world direction
  8304. */
  8305. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8306. /**
  8307. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8308. * @param localAxis The local direction that is used to compute the world direction
  8309. * @param mesh The mesh that this bone is attached to
  8310. * @param result The vector3 that the world direction will be copied to
  8311. */
  8312. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8313. /**
  8314. * Get the euler rotation of the bone in local or world space
  8315. * @param space The space that the rotation should be in
  8316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8317. * @returns The euler rotation
  8318. */
  8319. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8320. /**
  8321. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8322. * @param space The space that the rotation should be in
  8323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8324. * @param result The vector3 that the rotation should be copied to
  8325. */
  8326. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8327. /**
  8328. * Get the quaternion rotation of the bone in either local or world space
  8329. * @param space The space that the rotation should be in
  8330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8331. * @returns The quaternion rotation
  8332. */
  8333. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8334. /**
  8335. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8336. * @param space The space that the rotation should be in
  8337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8338. * @param result The quaternion that the rotation should be copied to
  8339. */
  8340. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8341. /**
  8342. * Get the rotation matrix of the bone in local or world space
  8343. * @param space The space that the rotation should be in
  8344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8345. * @returns The rotation matrix
  8346. */
  8347. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8348. /**
  8349. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8350. * @param space The space that the rotation should be in
  8351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8352. * @param result The quaternion that the rotation should be copied to
  8353. */
  8354. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8355. /**
  8356. * Get the world position of a point that is in the local space of the bone
  8357. * @param position The local position
  8358. * @param mesh The mesh that this bone is attached to
  8359. * @returns The world position
  8360. */
  8361. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8362. /**
  8363. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8364. * @param position The local position
  8365. * @param mesh The mesh that this bone is attached to
  8366. * @param result The vector3 that the world position should be copied to
  8367. */
  8368. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8369. /**
  8370. * Get the local position of a point that is in world space
  8371. * @param position The world position
  8372. * @param mesh The mesh that this bone is attached to
  8373. * @returns The local position
  8374. */
  8375. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8376. /**
  8377. * Get the local position of a point that is in world space and copy it to the result param
  8378. * @param position The world position
  8379. * @param mesh The mesh that this bone is attached to
  8380. * @param result The vector3 that the local position should be copied to
  8381. */
  8382. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8383. }
  8384. }
  8385. declare module "babylonjs/Misc/iInspectable" {
  8386. /**
  8387. * Enum that determines the text-wrapping mode to use.
  8388. */
  8389. export enum InspectableType {
  8390. /**
  8391. * Checkbox for booleans
  8392. */
  8393. Checkbox = 0,
  8394. /**
  8395. * Sliders for numbers
  8396. */
  8397. Slider = 1,
  8398. /**
  8399. * Vector3
  8400. */
  8401. Vector3 = 2,
  8402. /**
  8403. * Quaternions
  8404. */
  8405. Quaternion = 3,
  8406. /**
  8407. * Color3
  8408. */
  8409. Color3 = 4
  8410. }
  8411. /**
  8412. * Interface used to define custom inspectable properties.
  8413. * This interface is used by the inspector to display custom property grids
  8414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8415. */
  8416. export interface IInspectable {
  8417. /**
  8418. * Gets the label to display
  8419. */
  8420. label: string;
  8421. /**
  8422. * Gets the name of the property to edit
  8423. */
  8424. propertyName: string;
  8425. /**
  8426. * Gets the type of the editor to use
  8427. */
  8428. type: InspectableType;
  8429. /**
  8430. * Gets the minimum value of the property when using in "slider" mode
  8431. */
  8432. min?: number;
  8433. /**
  8434. * Gets the maximum value of the property when using in "slider" mode
  8435. */
  8436. max?: number;
  8437. /**
  8438. * Gets the setp to use when using in "slider" mode
  8439. */
  8440. step?: number;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8444. import { Nullable } from "babylonjs/types";
  8445. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8446. /**
  8447. * This represents the required contract to create a new type of texture loader.
  8448. */
  8449. export interface IInternalTextureLoader {
  8450. /**
  8451. * Defines wether the loader supports cascade loading the different faces.
  8452. */
  8453. supportCascades: boolean;
  8454. /**
  8455. * This returns if the loader support the current file information.
  8456. * @param extension defines the file extension of the file being loaded
  8457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8458. * @param fallback defines the fallback internal texture if any
  8459. * @param isBase64 defines whether the texture is encoded as a base64
  8460. * @param isBuffer defines whether the texture data are stored as a buffer
  8461. * @returns true if the loader can load the specified file
  8462. */
  8463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8464. /**
  8465. * Transform the url before loading if required.
  8466. * @param rootUrl the url of the texture
  8467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8468. * @returns the transformed texture
  8469. */
  8470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8471. /**
  8472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8473. * @param rootUrl the url of the texture
  8474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8475. * @returns the fallback texture
  8476. */
  8477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8478. /**
  8479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8480. * @param data contains the texture data
  8481. * @param texture defines the BabylonJS internal texture
  8482. * @param createPolynomials will be true if polynomials have been requested
  8483. * @param onLoad defines the callback to trigger once the texture is ready
  8484. * @param onError defines the callback to trigger in case of error
  8485. */
  8486. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8487. /**
  8488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8489. * @param data contains the texture data
  8490. * @param texture defines the BabylonJS internal texture
  8491. * @param callback defines the method to call once ready to upload
  8492. */
  8493. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8494. }
  8495. }
  8496. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8498. import { Nullable } from "babylonjs/types";
  8499. import { Scene } from "babylonjs/scene";
  8500. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8501. module "babylonjs/Engines/engine" {
  8502. interface Engine {
  8503. /**
  8504. * Creates a depth stencil cube texture.
  8505. * This is only available in WebGL 2.
  8506. * @param size The size of face edge in the cube texture.
  8507. * @param options The options defining the cube texture.
  8508. * @returns The cube texture
  8509. */
  8510. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8511. /**
  8512. * Creates a cube texture
  8513. * @param rootUrl defines the url where the files to load is located
  8514. * @param scene defines the current scene
  8515. * @param files defines the list of files to load (1 per face)
  8516. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8517. * @param onLoad defines an optional callback raised when the texture is loaded
  8518. * @param onError defines an optional callback raised if there is an issue to load the texture
  8519. * @param format defines the format of the data
  8520. * @param forcedExtension defines the extension to use to pick the right loader
  8521. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8522. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8523. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8524. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8525. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8526. * @returns the cube texture as an InternalTexture
  8527. */
  8528. 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;
  8529. /**
  8530. * Creates a cube texture
  8531. * @param rootUrl defines the url where the files to load is located
  8532. * @param scene defines the current scene
  8533. * @param files defines the list of files to load (1 per face)
  8534. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8535. * @param onLoad defines an optional callback raised when the texture is loaded
  8536. * @param onError defines an optional callback raised if there is an issue to load the texture
  8537. * @param format defines the format of the data
  8538. * @param forcedExtension defines the extension to use to pick the right loader
  8539. * @returns the cube texture as an InternalTexture
  8540. */
  8541. 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;
  8542. /**
  8543. * Creates a cube texture
  8544. * @param rootUrl defines the url where the files to load is located
  8545. * @param scene defines the current scene
  8546. * @param files defines the list of files to load (1 per face)
  8547. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8548. * @param onLoad defines an optional callback raised when the texture is loaded
  8549. * @param onError defines an optional callback raised if there is an issue to load the texture
  8550. * @param format defines the format of the data
  8551. * @param forcedExtension defines the extension to use to pick the right loader
  8552. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8553. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8554. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8555. * @returns the cube texture as an InternalTexture
  8556. */
  8557. 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;
  8558. /** @hidden */
  8559. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8564. /** @hidden */
  8565. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8566. }
  8567. }
  8568. }
  8569. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8570. import { Nullable } from "babylonjs/types";
  8571. import { Scene } from "babylonjs/scene";
  8572. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8574. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8575. /**
  8576. * Class for creating a cube texture
  8577. */
  8578. export class CubeTexture extends BaseTexture {
  8579. private _delayedOnLoad;
  8580. /**
  8581. * The url of the texture
  8582. */
  8583. url: string;
  8584. /**
  8585. * Gets or sets the center of the bounding box associated with the cube texture.
  8586. * It must define where the camera used to render the texture was set
  8587. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8588. */
  8589. boundingBoxPosition: Vector3;
  8590. private _boundingBoxSize;
  8591. /**
  8592. * Gets or sets the size of the bounding box associated with the cube texture
  8593. * When defined, the cubemap will switch to local mode
  8594. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8595. * @example https://www.babylonjs-playground.com/#RNASML
  8596. */
  8597. /**
  8598. * Returns the bounding box size
  8599. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8600. */
  8601. boundingBoxSize: Vector3;
  8602. protected _rotationY: number;
  8603. /**
  8604. * Sets texture matrix rotation angle around Y axis in radians.
  8605. */
  8606. /**
  8607. * Gets texture matrix rotation angle around Y axis radians.
  8608. */
  8609. rotationY: number;
  8610. /**
  8611. * Are mip maps generated for this texture or not.
  8612. */
  8613. readonly noMipmap: boolean;
  8614. private _noMipmap;
  8615. private _files;
  8616. private _extensions;
  8617. private _textureMatrix;
  8618. private _format;
  8619. private _createPolynomials;
  8620. /** @hidden */
  8621. _prefiltered: boolean;
  8622. /**
  8623. * Creates a cube texture from an array of image urls
  8624. * @param files defines an array of image urls
  8625. * @param scene defines the hosting scene
  8626. * @param noMipmap specifies if mip maps are not used
  8627. * @returns a cube texture
  8628. */
  8629. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8630. /**
  8631. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8632. * @param url defines the url of the prefiltered texture
  8633. * @param scene defines the scene the texture is attached to
  8634. * @param forcedExtension defines the extension of the file if different from the url
  8635. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8636. * @return the prefiltered texture
  8637. */
  8638. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8639. /**
  8640. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8641. * as prefiltered data.
  8642. * @param rootUrl defines the url of the texture or the root name of the six images
  8643. * @param scene defines the scene the texture is attached to
  8644. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8645. * @param noMipmap defines if mipmaps should be created or not
  8646. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8647. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8648. * @param onError defines a callback triggered in case of error during load
  8649. * @param format defines the internal format to use for the texture once loaded
  8650. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8651. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8652. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8655. * @return the cube texture
  8656. */
  8657. 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);
  8658. /**
  8659. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8660. */
  8661. readonly isPrefiltered: boolean;
  8662. /**
  8663. * Get the current class name of the texture useful for serialization or dynamic coding.
  8664. * @returns "CubeTexture"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Update the url (and optional buffer) of this texture if url was null during construction.
  8669. * @param url the url of the texture
  8670. * @param forcedExtension defines the extension to use
  8671. * @param onLoad callback called when the texture is loaded (defaults to null)
  8672. */
  8673. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8674. /**
  8675. * Delays loading of the cube texture
  8676. * @param forcedExtension defines the extension to use
  8677. */
  8678. delayLoad(forcedExtension?: string): void;
  8679. /**
  8680. * Returns the reflection texture matrix
  8681. * @returns the reflection texture matrix
  8682. */
  8683. getReflectionTextureMatrix(): Matrix;
  8684. /**
  8685. * Sets the reflection texture matrix
  8686. * @param value Reflection texture matrix
  8687. */
  8688. setReflectionTextureMatrix(value: Matrix): void;
  8689. /**
  8690. * Parses text to create a cube texture
  8691. * @param parsedTexture define the serialized text to read from
  8692. * @param scene defines the hosting scene
  8693. * @param rootUrl defines the root url of the cube texture
  8694. * @returns a cube texture
  8695. */
  8696. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8697. /**
  8698. * Makes a clone, or deep copy, of the cube texture
  8699. * @returns a new cube texture
  8700. */
  8701. clone(): CubeTexture;
  8702. }
  8703. }
  8704. declare module "babylonjs/Shaders/postprocess.vertex" {
  8705. /** @hidden */
  8706. export var postprocessVertexShader: {
  8707. name: string;
  8708. shader: string;
  8709. };
  8710. }
  8711. declare module "babylonjs/Cameras/targetCamera" {
  8712. import { Nullable } from "babylonjs/types";
  8713. import { Camera } from "babylonjs/Cameras/camera";
  8714. import { Scene } from "babylonjs/scene";
  8715. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8716. /**
  8717. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8718. * This is the base of the follow, arc rotate cameras and Free camera
  8719. * @see http://doc.babylonjs.com/features/cameras
  8720. */
  8721. export class TargetCamera extends Camera {
  8722. private static _RigCamTransformMatrix;
  8723. private static _TargetTransformMatrix;
  8724. private static _TargetFocalPoint;
  8725. /**
  8726. * Define the current direction the camera is moving to
  8727. */
  8728. cameraDirection: Vector3;
  8729. /**
  8730. * Define the current rotation the camera is rotating to
  8731. */
  8732. cameraRotation: Vector2;
  8733. /**
  8734. * When set, the up vector of the camera will be updated by the rotation of the camera
  8735. */
  8736. updateUpVectorFromRotation: boolean;
  8737. private _tmpQuaternion;
  8738. /**
  8739. * Define the current rotation of the camera
  8740. */
  8741. rotation: Vector3;
  8742. /**
  8743. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8744. */
  8745. rotationQuaternion: Quaternion;
  8746. /**
  8747. * Define the current speed of the camera
  8748. */
  8749. speed: number;
  8750. /**
  8751. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8752. * around all axis.
  8753. */
  8754. noRotationConstraint: boolean;
  8755. /**
  8756. * Define the current target of the camera as an object or a position.
  8757. */
  8758. lockedTarget: any;
  8759. /** @hidden */
  8760. _currentTarget: Vector3;
  8761. /** @hidden */
  8762. _initialFocalDistance: number;
  8763. /** @hidden */
  8764. _viewMatrix: Matrix;
  8765. /** @hidden */
  8766. _camMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraTransformMatrix: Matrix;
  8769. /** @hidden */
  8770. _cameraRotationMatrix: Matrix;
  8771. /** @hidden */
  8772. _referencePoint: Vector3;
  8773. /** @hidden */
  8774. _transformedReferencePoint: Vector3;
  8775. protected _globalCurrentTarget: Vector3;
  8776. protected _globalCurrentUpVector: Vector3;
  8777. /** @hidden */
  8778. _reset: () => void;
  8779. private _defaultUp;
  8780. /**
  8781. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8782. * This is the base of the follow, arc rotate cameras and Free camera
  8783. * @see http://doc.babylonjs.com/features/cameras
  8784. * @param name Defines the name of the camera in the scene
  8785. * @param position Defines the start position of the camera in the scene
  8786. * @param scene Defines the scene the camera belongs to
  8787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8788. */
  8789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8790. /**
  8791. * Gets the position in front of the camera at a given distance.
  8792. * @param distance The distance from the camera we want the position to be
  8793. * @returns the position
  8794. */
  8795. getFrontPosition(distance: number): Vector3;
  8796. /** @hidden */
  8797. _getLockedTargetPosition(): Nullable<Vector3>;
  8798. private _storedPosition;
  8799. private _storedRotation;
  8800. private _storedRotationQuaternion;
  8801. /**
  8802. * Store current camera state of the camera (fov, position, rotation, etc..)
  8803. * @returns the camera
  8804. */
  8805. storeState(): Camera;
  8806. /**
  8807. * Restored camera state. You must call storeState() first
  8808. * @returns whether it was successful or not
  8809. * @hidden
  8810. */
  8811. _restoreStateValues(): boolean;
  8812. /** @hidden */
  8813. _initCache(): void;
  8814. /** @hidden */
  8815. _updateCache(ignoreParentClass?: boolean): void;
  8816. /** @hidden */
  8817. _isSynchronizedViewMatrix(): boolean;
  8818. /** @hidden */
  8819. _computeLocalCameraSpeed(): number;
  8820. /**
  8821. * Defines the target the camera should look at.
  8822. * This will automatically adapt alpha beta and radius to fit within the new target.
  8823. * @param target Defines the new target as a Vector or a mesh
  8824. */
  8825. setTarget(target: Vector3): void;
  8826. /**
  8827. * Return the current target position of the camera. This value is expressed in local space.
  8828. * @returns the target position
  8829. */
  8830. getTarget(): Vector3;
  8831. /** @hidden */
  8832. _decideIfNeedsToMove(): boolean;
  8833. /** @hidden */
  8834. _updatePosition(): void;
  8835. /** @hidden */
  8836. _checkInputs(): void;
  8837. protected _updateCameraRotationMatrix(): void;
  8838. /**
  8839. * 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)
  8840. * @returns the current camera
  8841. */
  8842. private _rotateUpVectorWithCameraRotationMatrix;
  8843. private _cachedRotationZ;
  8844. private _cachedQuaternionRotationZ;
  8845. /** @hidden */
  8846. _getViewMatrix(): Matrix;
  8847. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8848. /**
  8849. * @hidden
  8850. */
  8851. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8852. /**
  8853. * @hidden
  8854. */
  8855. _updateRigCameras(): void;
  8856. private _getRigCamPositionAndTarget;
  8857. /**
  8858. * Gets the current object class name.
  8859. * @return the class name
  8860. */
  8861. getClassName(): string;
  8862. }
  8863. }
  8864. declare module "babylonjs/Cameras/cameraInputsManager" {
  8865. import { Nullable } from "babylonjs/types";
  8866. import { Camera } from "babylonjs/Cameras/camera";
  8867. /**
  8868. * @ignore
  8869. * This is a list of all the different input types that are available in the application.
  8870. * Fo instance: ArcRotateCameraGamepadInput...
  8871. */
  8872. export var CameraInputTypes: {};
  8873. /**
  8874. * This is the contract to implement in order to create a new input class.
  8875. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8876. */
  8877. export interface ICameraInput<TCamera extends Camera> {
  8878. /**
  8879. * Defines the camera the input is attached to.
  8880. */
  8881. camera: Nullable<TCamera>;
  8882. /**
  8883. * Gets the class name of the current intput.
  8884. * @returns the class name
  8885. */
  8886. getClassName(): string;
  8887. /**
  8888. * Get the friendly name associated with the input class.
  8889. * @returns the input friendly name
  8890. */
  8891. getSimpleName(): string;
  8892. /**
  8893. * Attach the input controls to a specific dom element to get the input from.
  8894. * @param element Defines the element the controls should be listened from
  8895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8896. */
  8897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8898. /**
  8899. * Detach the current controls from the specified dom element.
  8900. * @param element Defines the element to stop listening the inputs from
  8901. */
  8902. detachControl(element: Nullable<HTMLElement>): void;
  8903. /**
  8904. * Update the current camera state depending on the inputs that have been used this frame.
  8905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8906. */
  8907. checkInputs?: () => void;
  8908. }
  8909. /**
  8910. * Represents a map of input types to input instance or input index to input instance.
  8911. */
  8912. export interface CameraInputsMap<TCamera extends Camera> {
  8913. /**
  8914. * Accessor to the input by input type.
  8915. */
  8916. [name: string]: ICameraInput<TCamera>;
  8917. /**
  8918. * Accessor to the input by input index.
  8919. */
  8920. [idx: number]: ICameraInput<TCamera>;
  8921. }
  8922. /**
  8923. * This represents the input manager used within a camera.
  8924. * It helps dealing with all the different kind of input attached to a camera.
  8925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8926. */
  8927. export class CameraInputsManager<TCamera extends Camera> {
  8928. /**
  8929. * Defines the list of inputs attahed to the camera.
  8930. */
  8931. attached: CameraInputsMap<TCamera>;
  8932. /**
  8933. * Defines the dom element the camera is collecting inputs from.
  8934. * This is null if the controls have not been attached.
  8935. */
  8936. attachedElement: Nullable<HTMLElement>;
  8937. /**
  8938. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8939. */
  8940. noPreventDefault: boolean;
  8941. /**
  8942. * Defined the camera the input manager belongs to.
  8943. */
  8944. camera: TCamera;
  8945. /**
  8946. * Update the current camera state depending on the inputs that have been used this frame.
  8947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8948. */
  8949. checkInputs: () => void;
  8950. /**
  8951. * Instantiate a new Camera Input Manager.
  8952. * @param camera Defines the camera the input manager blongs to
  8953. */
  8954. constructor(camera: TCamera);
  8955. /**
  8956. * Add an input method to a camera
  8957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8958. * @param input camera input method
  8959. */
  8960. add(input: ICameraInput<TCamera>): void;
  8961. /**
  8962. * Remove a specific input method from a camera
  8963. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8964. * @param inputToRemove camera input method
  8965. */
  8966. remove(inputToRemove: ICameraInput<TCamera>): void;
  8967. /**
  8968. * Remove a specific input type from a camera
  8969. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8970. * @param inputType the type of the input to remove
  8971. */
  8972. removeByType(inputType: string): void;
  8973. private _addCheckInputs;
  8974. /**
  8975. * Attach the input controls to the currently attached dom element to listen the events from.
  8976. * @param input Defines the input to attach
  8977. */
  8978. attachInput(input: ICameraInput<TCamera>): void;
  8979. /**
  8980. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8981. * @param element Defines the dom element to collect the events from
  8982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8983. */
  8984. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8985. /**
  8986. * Detach the current manager inputs controls from a specific dom element.
  8987. * @param element Defines the dom element to collect the events from
  8988. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8989. */
  8990. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8991. /**
  8992. * Rebuild the dynamic inputCheck function from the current list of
  8993. * defined inputs in the manager.
  8994. */
  8995. rebuildInputCheck(): void;
  8996. /**
  8997. * Remove all attached input methods from a camera
  8998. */
  8999. clear(): void;
  9000. /**
  9001. * Serialize the current input manager attached to a camera.
  9002. * This ensures than once parsed,
  9003. * the input associated to the camera will be identical to the current ones
  9004. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9005. */
  9006. serialize(serializedCamera: any): void;
  9007. /**
  9008. * Parses an input manager serialized JSON to restore the previous list of inputs
  9009. * and states associated to a camera.
  9010. * @param parsedCamera Defines the JSON to parse
  9011. */
  9012. parse(parsedCamera: any): void;
  9013. }
  9014. }
  9015. declare module "babylonjs/Events/keyboardEvents" {
  9016. /**
  9017. * Gather the list of keyboard event types as constants.
  9018. */
  9019. export class KeyboardEventTypes {
  9020. /**
  9021. * The keydown event is fired when a key becomes active (pressed).
  9022. */
  9023. static readonly KEYDOWN: number;
  9024. /**
  9025. * The keyup event is fired when a key has been released.
  9026. */
  9027. static readonly KEYUP: number;
  9028. }
  9029. /**
  9030. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9031. */
  9032. export class KeyboardInfo {
  9033. /**
  9034. * Defines the type of event (KeyboardEventTypes)
  9035. */
  9036. type: number;
  9037. /**
  9038. * Defines the related dom event
  9039. */
  9040. event: KeyboardEvent;
  9041. /**
  9042. * Instantiates a new keyboard info.
  9043. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9044. * @param type Defines the type of event (KeyboardEventTypes)
  9045. * @param event Defines the related dom event
  9046. */
  9047. constructor(
  9048. /**
  9049. * Defines the type of event (KeyboardEventTypes)
  9050. */
  9051. type: number,
  9052. /**
  9053. * Defines the related dom event
  9054. */
  9055. event: KeyboardEvent);
  9056. }
  9057. /**
  9058. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9059. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9060. */
  9061. export class KeyboardInfoPre extends KeyboardInfo {
  9062. /**
  9063. * Defines the type of event (KeyboardEventTypes)
  9064. */
  9065. type: number;
  9066. /**
  9067. * Defines the related dom event
  9068. */
  9069. event: KeyboardEvent;
  9070. /**
  9071. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9072. */
  9073. skipOnPointerObservable: boolean;
  9074. /**
  9075. * Instantiates a new keyboard pre info.
  9076. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9077. * @param type Defines the type of event (KeyboardEventTypes)
  9078. * @param event Defines the related dom event
  9079. */
  9080. constructor(
  9081. /**
  9082. * Defines the type of event (KeyboardEventTypes)
  9083. */
  9084. type: number,
  9085. /**
  9086. * Defines the related dom event
  9087. */
  9088. event: KeyboardEvent);
  9089. }
  9090. }
  9091. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9092. import { Nullable } from "babylonjs/types";
  9093. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9095. /**
  9096. * Manage the keyboard inputs to control the movement of a free camera.
  9097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9098. */
  9099. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9100. /**
  9101. * Defines the camera the input is attached to.
  9102. */
  9103. camera: FreeCamera;
  9104. /**
  9105. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9106. */
  9107. keysUp: number[];
  9108. /**
  9109. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9110. */
  9111. keysDown: number[];
  9112. /**
  9113. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9114. */
  9115. keysLeft: number[];
  9116. /**
  9117. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9118. */
  9119. keysRight: number[];
  9120. private _keys;
  9121. private _onCanvasBlurObserver;
  9122. private _onKeyboardObserver;
  9123. private _engine;
  9124. private _scene;
  9125. /**
  9126. * Attach the input controls to a specific dom element to get the input from.
  9127. * @param element Defines the element the controls should be listened from
  9128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9129. */
  9130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9131. /**
  9132. * Detach the current controls from the specified dom element.
  9133. * @param element Defines the element to stop listening the inputs from
  9134. */
  9135. detachControl(element: Nullable<HTMLElement>): void;
  9136. /**
  9137. * Update the current camera state depending on the inputs that have been used this frame.
  9138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9139. */
  9140. checkInputs(): void;
  9141. /**
  9142. * Gets the class name of the current intput.
  9143. * @returns the class name
  9144. */
  9145. getClassName(): string;
  9146. /** @hidden */
  9147. _onLostFocus(): void;
  9148. /**
  9149. * Get the friendly name associated with the input class.
  9150. * @returns the input friendly name
  9151. */
  9152. getSimpleName(): string;
  9153. }
  9154. }
  9155. declare module "babylonjs/Lights/shadowLight" {
  9156. import { Camera } from "babylonjs/Cameras/camera";
  9157. import { Scene } from "babylonjs/scene";
  9158. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9160. import { Light } from "babylonjs/Lights/light";
  9161. /**
  9162. * Interface describing all the common properties and methods a shadow light needs to implement.
  9163. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9164. * as well as binding the different shadow properties to the effects.
  9165. */
  9166. export interface IShadowLight extends Light {
  9167. /**
  9168. * The light id in the scene (used in scene.findLighById for instance)
  9169. */
  9170. id: string;
  9171. /**
  9172. * The position the shdow will be casted from.
  9173. */
  9174. position: Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9177. */
  9178. direction: Vector3;
  9179. /**
  9180. * The transformed position. Position of the light in world space taking parenting in account.
  9181. */
  9182. transformedPosition: Vector3;
  9183. /**
  9184. * The transformed direction. Direction of the light in world space taking parenting in account.
  9185. */
  9186. transformedDirection: Vector3;
  9187. /**
  9188. * The friendly name of the light in the scene.
  9189. */
  9190. name: string;
  9191. /**
  9192. * Defines the shadow projection clipping minimum z value.
  9193. */
  9194. shadowMinZ: number;
  9195. /**
  9196. * Defines the shadow projection clipping maximum z value.
  9197. */
  9198. shadowMaxZ: number;
  9199. /**
  9200. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9201. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9202. */
  9203. computeTransformedInformation(): boolean;
  9204. /**
  9205. * Gets the scene the light belongs to.
  9206. * @returns The scene
  9207. */
  9208. getScene(): Scene;
  9209. /**
  9210. * Callback defining a custom Projection Matrix Builder.
  9211. * This can be used to override the default projection matrix computation.
  9212. */
  9213. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9214. /**
  9215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9216. * @param matrix The materix to updated with the projection information
  9217. * @param viewMatrix The transform matrix of the light
  9218. * @param renderList The list of mesh to render in the map
  9219. * @returns The current light
  9220. */
  9221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9222. /**
  9223. * Gets the current depth scale used in ESM.
  9224. * @returns The scale
  9225. */
  9226. getDepthScale(): number;
  9227. /**
  9228. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9229. * @returns true if a cube texture needs to be use
  9230. */
  9231. needCube(): boolean;
  9232. /**
  9233. * Detects if the projection matrix requires to be recomputed this frame.
  9234. * @returns true if it requires to be recomputed otherwise, false.
  9235. */
  9236. needProjectionMatrixCompute(): boolean;
  9237. /**
  9238. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9239. */
  9240. forceProjectionMatrixCompute(): void;
  9241. /**
  9242. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9243. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9244. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9245. */
  9246. getShadowDirection(faceIndex?: number): Vector3;
  9247. /**
  9248. * Gets the minZ used for shadow according to both the scene and the light.
  9249. * @param activeCamera The camera we are returning the min for
  9250. * @returns the depth min z
  9251. */
  9252. getDepthMinZ(activeCamera: Camera): number;
  9253. /**
  9254. * Gets the maxZ used for shadow according to both the scene and the light.
  9255. * @param activeCamera The camera we are returning the max for
  9256. * @returns the depth max z
  9257. */
  9258. getDepthMaxZ(activeCamera: Camera): number;
  9259. }
  9260. /**
  9261. * Base implementation IShadowLight
  9262. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9263. */
  9264. export abstract class ShadowLight extends Light implements IShadowLight {
  9265. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9266. protected _position: Vector3;
  9267. protected _setPosition(value: Vector3): void;
  9268. /**
  9269. * Sets the position the shadow will be casted from. Also use as the light position for both
  9270. * point and spot lights.
  9271. */
  9272. /**
  9273. * Sets the position the shadow will be casted from. Also use as the light position for both
  9274. * point and spot lights.
  9275. */
  9276. position: Vector3;
  9277. protected _direction: Vector3;
  9278. protected _setDirection(value: Vector3): void;
  9279. /**
  9280. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9281. * Also use as the light direction on spot and directional lights.
  9282. */
  9283. /**
  9284. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9285. * Also use as the light direction on spot and directional lights.
  9286. */
  9287. direction: Vector3;
  9288. private _shadowMinZ;
  9289. /**
  9290. * Gets the shadow projection clipping minimum z value.
  9291. */
  9292. /**
  9293. * Sets the shadow projection clipping minimum z value.
  9294. */
  9295. shadowMinZ: number;
  9296. private _shadowMaxZ;
  9297. /**
  9298. * Sets the shadow projection clipping maximum z value.
  9299. */
  9300. /**
  9301. * Gets the shadow projection clipping maximum z value.
  9302. */
  9303. shadowMaxZ: number;
  9304. /**
  9305. * Callback defining a custom Projection Matrix Builder.
  9306. * This can be used to override the default projection matrix computation.
  9307. */
  9308. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9309. /**
  9310. * The transformed position. Position of the light in world space taking parenting in account.
  9311. */
  9312. transformedPosition: Vector3;
  9313. /**
  9314. * The transformed direction. Direction of the light in world space taking parenting in account.
  9315. */
  9316. transformedDirection: Vector3;
  9317. private _needProjectionMatrixCompute;
  9318. /**
  9319. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9320. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9321. */
  9322. computeTransformedInformation(): boolean;
  9323. /**
  9324. * Return the depth scale used for the shadow map.
  9325. * @returns the depth scale.
  9326. */
  9327. getDepthScale(): number;
  9328. /**
  9329. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9330. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9331. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9332. */
  9333. getShadowDirection(faceIndex?: number): Vector3;
  9334. /**
  9335. * Returns the ShadowLight absolute position in the World.
  9336. * @returns the position vector in world space
  9337. */
  9338. getAbsolutePosition(): Vector3;
  9339. /**
  9340. * Sets the ShadowLight direction toward the passed target.
  9341. * @param target The point to target in local space
  9342. * @returns the updated ShadowLight direction
  9343. */
  9344. setDirectionToTarget(target: Vector3): Vector3;
  9345. /**
  9346. * Returns the light rotation in euler definition.
  9347. * @returns the x y z rotation in local space.
  9348. */
  9349. getRotation(): Vector3;
  9350. /**
  9351. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9352. * @returns true if a cube texture needs to be use
  9353. */
  9354. needCube(): boolean;
  9355. /**
  9356. * Detects if the projection matrix requires to be recomputed this frame.
  9357. * @returns true if it requires to be recomputed otherwise, false.
  9358. */
  9359. needProjectionMatrixCompute(): boolean;
  9360. /**
  9361. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9362. */
  9363. forceProjectionMatrixCompute(): void;
  9364. /** @hidden */
  9365. _initCache(): void;
  9366. /** @hidden */
  9367. _isSynchronized(): boolean;
  9368. /**
  9369. * Computes the world matrix of the node
  9370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9371. * @returns the world matrix
  9372. */
  9373. computeWorldMatrix(force?: boolean): Matrix;
  9374. /**
  9375. * Gets the minZ used for shadow according to both the scene and the light.
  9376. * @param activeCamera The camera we are returning the min for
  9377. * @returns the depth min z
  9378. */
  9379. getDepthMinZ(activeCamera: Camera): number;
  9380. /**
  9381. * Gets the maxZ used for shadow according to both the scene and the light.
  9382. * @param activeCamera The camera we are returning the max for
  9383. * @returns the depth max z
  9384. */
  9385. getDepthMaxZ(activeCamera: Camera): number;
  9386. /**
  9387. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9388. * @param matrix The materix to updated with the projection information
  9389. * @param viewMatrix The transform matrix of the light
  9390. * @param renderList The list of mesh to render in the map
  9391. * @returns The current light
  9392. */
  9393. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9394. }
  9395. }
  9396. declare module "babylonjs/Materials/materialHelper" {
  9397. import { Nullable } from "babylonjs/types";
  9398. import { Scene } from "babylonjs/scene";
  9399. import { Engine } from "babylonjs/Engines/engine";
  9400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9401. import { Light } from "babylonjs/Lights/light";
  9402. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9403. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9405. /**
  9406. * "Static Class" containing the most commonly used helper while dealing with material for
  9407. * rendering purpose.
  9408. *
  9409. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9410. *
  9411. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9412. */
  9413. export class MaterialHelper {
  9414. /**
  9415. * Bind the current view position to an effect.
  9416. * @param effect The effect to be bound
  9417. * @param scene The scene the eyes position is used from
  9418. */
  9419. static BindEyePosition(effect: Effect, scene: Scene): void;
  9420. /**
  9421. * Helps preparing the defines values about the UVs in used in the effect.
  9422. * UVs are shared as much as we can accross channels in the shaders.
  9423. * @param texture The texture we are preparing the UVs for
  9424. * @param defines The defines to update
  9425. * @param key The channel key "diffuse", "specular"... used in the shader
  9426. */
  9427. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9428. /**
  9429. * Binds a texture matrix value to its corrsponding uniform
  9430. * @param texture The texture to bind the matrix for
  9431. * @param uniformBuffer The uniform buffer receivin the data
  9432. * @param key The channel key "diffuse", "specular"... used in the shader
  9433. */
  9434. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9435. /**
  9436. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9437. * @param mesh defines the current mesh
  9438. * @param scene defines the current scene
  9439. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9440. * @param pointsCloud defines if point cloud rendering has to be turned on
  9441. * @param fogEnabled defines if fog has to be turned on
  9442. * @param alphaTest defines if alpha testing has to be turned on
  9443. * @param defines defines the current list of defines
  9444. */
  9445. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9446. /**
  9447. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9448. * @param scene defines the current scene
  9449. * @param engine defines the current engine
  9450. * @param defines specifies the list of active defines
  9451. * @param useInstances defines if instances have to be turned on
  9452. * @param useClipPlane defines if clip plane have to be turned on
  9453. */
  9454. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9455. /**
  9456. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9457. * @param mesh The mesh containing the geometry data we will draw
  9458. * @param defines The defines to update
  9459. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9460. * @param useBones Precise whether bones should be used or not (override mesh info)
  9461. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9462. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9463. * @returns false if defines are considered not dirty and have not been checked
  9464. */
  9465. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9466. /**
  9467. * Prepares the defines related to multiview
  9468. * @param scene The scene we are intending to draw
  9469. * @param defines The defines to update
  9470. */
  9471. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9472. /**
  9473. * Prepares the defines related to the light information passed in parameter
  9474. * @param scene The scene we are intending to draw
  9475. * @param mesh The mesh the effect is compiling for
  9476. * @param defines The defines to update
  9477. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9478. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9479. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9480. * @returns true if normals will be required for the rest of the effect
  9481. */
  9482. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9483. /**
  9484. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9485. * that won t be acctive due to defines being turned off.
  9486. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9487. * @param samplersList The samplers list
  9488. * @param defines The defines helping in the list generation
  9489. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9490. */
  9491. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9492. /**
  9493. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9494. * @param defines The defines to update while falling back
  9495. * @param fallbacks The authorized effect fallbacks
  9496. * @param maxSimultaneousLights The maximum number of lights allowed
  9497. * @param rank the current rank of the Effect
  9498. * @returns The newly affected rank
  9499. */
  9500. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9501. /**
  9502. * Prepares the list of attributes required for morph targets according to the effect defines.
  9503. * @param attribs The current list of supported attribs
  9504. * @param mesh The mesh to prepare the morph targets attributes for
  9505. * @param defines The current Defines of the effect
  9506. */
  9507. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9508. /**
  9509. * Prepares the list of attributes required for bones according to the effect defines.
  9510. * @param attribs The current list of supported attribs
  9511. * @param mesh The mesh to prepare the bones attributes for
  9512. * @param defines The current Defines of the effect
  9513. * @param fallbacks The current efffect fallback strategy
  9514. */
  9515. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9516. /**
  9517. * Prepares the list of attributes required for instances according to the effect defines.
  9518. * @param attribs The current list of supported attribs
  9519. * @param defines The current Defines of the effect
  9520. */
  9521. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9522. /**
  9523. * Binds the light shadow information to the effect for the given mesh.
  9524. * @param light The light containing the generator
  9525. * @param scene The scene the lights belongs to
  9526. * @param mesh The mesh we are binding the information to render
  9527. * @param lightIndex The light index in the effect used to render the mesh
  9528. * @param effect The effect we are binding the data to
  9529. */
  9530. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9531. /**
  9532. * Binds the light information to the effect.
  9533. * @param light The light containing the generator
  9534. * @param effect The effect we are binding the data to
  9535. * @param lightIndex The light index in the effect used to render
  9536. */
  9537. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9538. /**
  9539. * Binds the lights information from the scene to the effect for the given mesh.
  9540. * @param scene The scene the lights belongs to
  9541. * @param mesh The mesh we are binding the information to render
  9542. * @param effect The effect we are binding the data to
  9543. * @param defines The generated defines for the effect
  9544. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9545. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9546. */
  9547. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9548. private static _tempFogColor;
  9549. /**
  9550. * Binds the fog information from the scene to the effect for the given mesh.
  9551. * @param scene The scene the lights belongs to
  9552. * @param mesh The mesh we are binding the information to render
  9553. * @param effect The effect we are binding the data to
  9554. * @param linearSpace Defines if the fog effect is applied in linear space
  9555. */
  9556. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9557. /**
  9558. * Binds the bones information from the mesh to the effect.
  9559. * @param mesh The mesh we are binding the information to render
  9560. * @param effect The effect we are binding the data to
  9561. */
  9562. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9563. /**
  9564. * Binds the morph targets information from the mesh to the effect.
  9565. * @param abstractMesh The mesh we are binding the information to render
  9566. * @param effect The effect we are binding the data to
  9567. */
  9568. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9569. /**
  9570. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9571. * @param defines The generated defines used in the effect
  9572. * @param effect The effect we are binding the data to
  9573. * @param scene The scene we are willing to render with logarithmic scale for
  9574. */
  9575. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9576. /**
  9577. * Binds the clip plane information from the scene to the effect.
  9578. * @param scene The scene the clip plane information are extracted from
  9579. * @param effect The effect we are binding the data to
  9580. */
  9581. static BindClipPlane(effect: Effect, scene: Scene): void;
  9582. }
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9585. /** @hidden */
  9586. export var kernelBlurVaryingDeclaration: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9592. /** @hidden */
  9593. export var kernelBlurFragment: {
  9594. name: string;
  9595. shader: string;
  9596. };
  9597. }
  9598. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9599. /** @hidden */
  9600. export var kernelBlurFragment2: {
  9601. name: string;
  9602. shader: string;
  9603. };
  9604. }
  9605. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9607. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9608. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9609. /** @hidden */
  9610. export var kernelBlurPixelShader: {
  9611. name: string;
  9612. shader: string;
  9613. };
  9614. }
  9615. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9616. /** @hidden */
  9617. export var kernelBlurVertex: {
  9618. name: string;
  9619. shader: string;
  9620. };
  9621. }
  9622. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9623. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9624. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9625. /** @hidden */
  9626. export var kernelBlurVertexShader: {
  9627. name: string;
  9628. shader: string;
  9629. };
  9630. }
  9631. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9632. import { Vector2 } from "babylonjs/Maths/math";
  9633. import { Nullable } from "babylonjs/types";
  9634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9635. import { Camera } from "babylonjs/Cameras/camera";
  9636. import { Effect } from "babylonjs/Materials/effect";
  9637. import { Engine } from "babylonjs/Engines/engine";
  9638. import "babylonjs/Shaders/kernelBlur.fragment";
  9639. import "babylonjs/Shaders/kernelBlur.vertex";
  9640. /**
  9641. * The Blur Post Process which blurs an image based on a kernel and direction.
  9642. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9643. */
  9644. export class BlurPostProcess extends PostProcess {
  9645. /** The direction in which to blur the image. */
  9646. direction: Vector2;
  9647. private blockCompilation;
  9648. protected _kernel: number;
  9649. protected _idealKernel: number;
  9650. protected _packedFloat: boolean;
  9651. private _staticDefines;
  9652. /**
  9653. * Sets the length in pixels of the blur sample region
  9654. */
  9655. /**
  9656. * Gets the length in pixels of the blur sample region
  9657. */
  9658. kernel: number;
  9659. /**
  9660. * Sets wether or not the blur needs to unpack/repack floats
  9661. */
  9662. /**
  9663. * Gets wether or not the blur is unpacking/repacking floats
  9664. */
  9665. packedFloat: boolean;
  9666. /**
  9667. * Creates a new instance BlurPostProcess
  9668. * @param name The name of the effect.
  9669. * @param direction The direction in which to blur the image.
  9670. * @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.
  9671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9672. * @param camera The camera to apply the render pass to.
  9673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9674. * @param engine The engine which the post process will be applied. (default: current engine)
  9675. * @param reusable If the post process can be reused on the same frame. (default: false)
  9676. * @param textureType Type of textures used when performing the post process. (default: 0)
  9677. * @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)
  9678. */
  9679. constructor(name: string,
  9680. /** The direction in which to blur the image. */
  9681. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9682. /**
  9683. * Updates the effect with the current post process compile time values and recompiles the shader.
  9684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9687. * @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
  9688. * @param onCompiled Called when the shader has been compiled.
  9689. * @param onError Called if there is an error when compiling a shader.
  9690. */
  9691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9692. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9693. /**
  9694. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9695. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9696. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9697. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9698. * The gaps between physical kernels are compensated for in the weighting of the samples
  9699. * @param idealKernel Ideal blur kernel.
  9700. * @return Nearest best kernel.
  9701. */
  9702. protected _nearestBestKernel(idealKernel: number): number;
  9703. /**
  9704. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9705. * @param x The point on the Gaussian distribution to sample.
  9706. * @return the value of the Gaussian function at x.
  9707. */
  9708. protected _gaussianWeight(x: number): number;
  9709. /**
  9710. * Generates a string that can be used as a floating point number in GLSL.
  9711. * @param x Value to print.
  9712. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9713. * @return GLSL float string.
  9714. */
  9715. protected _glslFloat(x: number, decimalFigures?: number): string;
  9716. }
  9717. }
  9718. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9719. /** @hidden */
  9720. export var shadowMapPixelShader: {
  9721. name: string;
  9722. shader: string;
  9723. };
  9724. }
  9725. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9726. /** @hidden */
  9727. export var bonesDeclaration: {
  9728. name: string;
  9729. shader: string;
  9730. };
  9731. }
  9732. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9733. /** @hidden */
  9734. export var morphTargetsVertexGlobalDeclaration: {
  9735. name: string;
  9736. shader: string;
  9737. };
  9738. }
  9739. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9740. /** @hidden */
  9741. export var morphTargetsVertexDeclaration: {
  9742. name: string;
  9743. shader: string;
  9744. };
  9745. }
  9746. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9747. /** @hidden */
  9748. export var instancesDeclaration: {
  9749. name: string;
  9750. shader: string;
  9751. };
  9752. }
  9753. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9754. /** @hidden */
  9755. export var helperFunctions: {
  9756. name: string;
  9757. shader: string;
  9758. };
  9759. }
  9760. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9761. /** @hidden */
  9762. export var morphTargetsVertex: {
  9763. name: string;
  9764. shader: string;
  9765. };
  9766. }
  9767. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9768. /** @hidden */
  9769. export var instancesVertex: {
  9770. name: string;
  9771. shader: string;
  9772. };
  9773. }
  9774. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9775. /** @hidden */
  9776. export var bonesVertex: {
  9777. name: string;
  9778. shader: string;
  9779. };
  9780. }
  9781. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9785. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9787. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9788. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9789. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9790. /** @hidden */
  9791. export var shadowMapVertexShader: {
  9792. name: string;
  9793. shader: string;
  9794. };
  9795. }
  9796. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9797. /** @hidden */
  9798. export var depthBoxBlurPixelShader: {
  9799. name: string;
  9800. shader: string;
  9801. };
  9802. }
  9803. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9804. import { Nullable } from "babylonjs/types";
  9805. import { Scene } from "babylonjs/scene";
  9806. import { Matrix } from "babylonjs/Maths/math";
  9807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9809. import { Mesh } from "babylonjs/Meshes/mesh";
  9810. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9811. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9812. import { Effect } from "babylonjs/Materials/effect";
  9813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9814. import "babylonjs/Shaders/shadowMap.fragment";
  9815. import "babylonjs/Shaders/shadowMap.vertex";
  9816. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9817. import { Observable } from "babylonjs/Misc/observable";
  9818. /**
  9819. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9820. */
  9821. export interface ICustomShaderOptions {
  9822. /**
  9823. * Gets or sets the custom shader name to use
  9824. */
  9825. shaderName: string;
  9826. /**
  9827. * The list of attribute names used in the shader
  9828. */
  9829. attributes?: string[];
  9830. /**
  9831. * The list of unifrom names used in the shader
  9832. */
  9833. uniforms?: string[];
  9834. /**
  9835. * The list of sampler names used in the shader
  9836. */
  9837. samplers?: string[];
  9838. /**
  9839. * The list of defines used in the shader
  9840. */
  9841. defines?: string[];
  9842. }
  9843. /**
  9844. * Interface to implement to create a shadow generator compatible with BJS.
  9845. */
  9846. export interface IShadowGenerator {
  9847. /**
  9848. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9849. * @returns The render target texture if present otherwise, null
  9850. */
  9851. getShadowMap(): Nullable<RenderTargetTexture>;
  9852. /**
  9853. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9854. * @returns The render target texture if the shadow map is present otherwise, null
  9855. */
  9856. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9857. /**
  9858. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9859. * @param subMesh The submesh we want to render in the shadow map
  9860. * @param useInstances Defines wether will draw in the map using instances
  9861. * @returns true if ready otherwise, false
  9862. */
  9863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9864. /**
  9865. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9866. * @param defines Defines of the material we want to update
  9867. * @param lightIndex Index of the light in the enabled light list of the material
  9868. */
  9869. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9870. /**
  9871. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9872. * defined in the generator but impacting the effect).
  9873. * It implies the unifroms available on the materials are the standard BJS ones.
  9874. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9875. * @param effect The effect we are binfing the information for
  9876. */
  9877. bindShadowLight(lightIndex: string, effect: Effect): void;
  9878. /**
  9879. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9880. * (eq to shadow prjection matrix * light transform matrix)
  9881. * @returns The transform matrix used to create the shadow map
  9882. */
  9883. getTransformMatrix(): Matrix;
  9884. /**
  9885. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9886. * Cube and 2D textures for instance.
  9887. */
  9888. recreateShadowMap(): void;
  9889. /**
  9890. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9891. * @param onCompiled Callback triggered at the and of the effects compilation
  9892. * @param options Sets of optional options forcing the compilation with different modes
  9893. */
  9894. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9895. useInstances: boolean;
  9896. }>): void;
  9897. /**
  9898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9899. * @param options Sets of optional options forcing the compilation with different modes
  9900. * @returns A promise that resolves when the compilation completes
  9901. */
  9902. forceCompilationAsync(options?: Partial<{
  9903. useInstances: boolean;
  9904. }>): Promise<void>;
  9905. /**
  9906. * Serializes the shadow generator setup to a json object.
  9907. * @returns The serialized JSON object
  9908. */
  9909. serialize(): any;
  9910. /**
  9911. * Disposes the Shadow map and related Textures and effects.
  9912. */
  9913. dispose(): void;
  9914. }
  9915. /**
  9916. * Default implementation IShadowGenerator.
  9917. * This is the main object responsible of generating shadows in the framework.
  9918. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9919. */
  9920. export class ShadowGenerator implements IShadowGenerator {
  9921. /**
  9922. * Shadow generator mode None: no filtering applied.
  9923. */
  9924. static readonly FILTER_NONE: number;
  9925. /**
  9926. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9927. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9928. */
  9929. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9930. /**
  9931. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9932. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9933. */
  9934. static readonly FILTER_POISSONSAMPLING: number;
  9935. /**
  9936. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9937. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9938. */
  9939. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9940. /**
  9941. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9942. * edge artifacts on steep falloff.
  9943. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9944. */
  9945. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9946. /**
  9947. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9948. * edge artifacts on steep falloff.
  9949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9950. */
  9951. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9952. /**
  9953. * Shadow generator mode PCF: Percentage Closer Filtering
  9954. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9955. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9956. */
  9957. static readonly FILTER_PCF: number;
  9958. /**
  9959. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9960. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9961. * Contact Hardening
  9962. */
  9963. static readonly FILTER_PCSS: number;
  9964. /**
  9965. * Reserved for PCF and PCSS
  9966. * Highest Quality.
  9967. *
  9968. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9969. *
  9970. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9971. */
  9972. static readonly QUALITY_HIGH: number;
  9973. /**
  9974. * Reserved for PCF and PCSS
  9975. * Good tradeoff for quality/perf cross devices
  9976. *
  9977. * Execute PCF on a 3*3 kernel.
  9978. *
  9979. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9980. */
  9981. static readonly QUALITY_MEDIUM: number;
  9982. /**
  9983. * Reserved for PCF and PCSS
  9984. * The lowest quality but the fastest.
  9985. *
  9986. * Execute PCF on a 1*1 kernel.
  9987. *
  9988. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9989. */
  9990. static readonly QUALITY_LOW: number;
  9991. /** Gets or sets the custom shader name to use */
  9992. customShaderOptions: ICustomShaderOptions;
  9993. /**
  9994. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9995. */
  9996. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9997. /**
  9998. * Observable triggered before a mesh is rendered in the shadow map.
  9999. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10000. */
  10001. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10002. private _bias;
  10003. /**
  10004. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10005. */
  10006. /**
  10007. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10008. */
  10009. bias: number;
  10010. private _normalBias;
  10011. /**
  10012. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10013. */
  10014. /**
  10015. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10016. */
  10017. normalBias: number;
  10018. private _blurBoxOffset;
  10019. /**
  10020. * Gets the blur box offset: offset applied during the blur pass.
  10021. * Only useful if useKernelBlur = false
  10022. */
  10023. /**
  10024. * Sets the blur box offset: offset applied during the blur pass.
  10025. * Only useful if useKernelBlur = false
  10026. */
  10027. blurBoxOffset: number;
  10028. private _blurScale;
  10029. /**
  10030. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10031. * 2 means half of the size.
  10032. */
  10033. /**
  10034. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10035. * 2 means half of the size.
  10036. */
  10037. blurScale: number;
  10038. private _blurKernel;
  10039. /**
  10040. * Gets the blur kernel: kernel size of the blur pass.
  10041. * Only useful if useKernelBlur = true
  10042. */
  10043. /**
  10044. * Sets the blur kernel: kernel size of the blur pass.
  10045. * Only useful if useKernelBlur = true
  10046. */
  10047. blurKernel: number;
  10048. private _useKernelBlur;
  10049. /**
  10050. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10051. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10052. */
  10053. /**
  10054. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10055. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10056. */
  10057. useKernelBlur: boolean;
  10058. private _depthScale;
  10059. /**
  10060. * Gets the depth scale used in ESM mode.
  10061. */
  10062. /**
  10063. * Sets the depth scale used in ESM mode.
  10064. * This can override the scale stored on the light.
  10065. */
  10066. depthScale: number;
  10067. private _filter;
  10068. /**
  10069. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10071. */
  10072. /**
  10073. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10074. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10075. */
  10076. filter: number;
  10077. /**
  10078. * Gets if the current filter is set to Poisson Sampling.
  10079. */
  10080. /**
  10081. * Sets the current filter to Poisson Sampling.
  10082. */
  10083. usePoissonSampling: boolean;
  10084. /**
  10085. * Gets if the current filter is set to ESM.
  10086. */
  10087. /**
  10088. * Sets the current filter is to ESM.
  10089. */
  10090. useExponentialShadowMap: boolean;
  10091. /**
  10092. * Gets if the current filter is set to filtered ESM.
  10093. */
  10094. /**
  10095. * Gets if the current filter is set to filtered ESM.
  10096. */
  10097. useBlurExponentialShadowMap: boolean;
  10098. /**
  10099. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10100. * exponential to prevent steep falloff artifacts).
  10101. */
  10102. /**
  10103. * Sets the current filter to "close ESM" (using the inverse of the
  10104. * exponential to prevent steep falloff artifacts).
  10105. */
  10106. useCloseExponentialShadowMap: boolean;
  10107. /**
  10108. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10109. * exponential to prevent steep falloff artifacts).
  10110. */
  10111. /**
  10112. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10113. * exponential to prevent steep falloff artifacts).
  10114. */
  10115. useBlurCloseExponentialShadowMap: boolean;
  10116. /**
  10117. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10118. */
  10119. /**
  10120. * Sets the current filter to "PCF" (percentage closer filtering).
  10121. */
  10122. usePercentageCloserFiltering: boolean;
  10123. private _filteringQuality;
  10124. /**
  10125. * Gets the PCF or PCSS Quality.
  10126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10127. */
  10128. /**
  10129. * Sets the PCF or PCSS Quality.
  10130. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10131. */
  10132. filteringQuality: number;
  10133. /**
  10134. * Gets if the current filter is set to "PCSS" (contact hardening).
  10135. */
  10136. /**
  10137. * Sets the current filter to "PCSS" (contact hardening).
  10138. */
  10139. useContactHardeningShadow: boolean;
  10140. private _contactHardeningLightSizeUVRatio;
  10141. /**
  10142. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10143. * Using a ratio helps keeping shape stability independently of the map size.
  10144. *
  10145. * It does not account for the light projection as it was having too much
  10146. * instability during the light setup or during light position changes.
  10147. *
  10148. * Only valid if useContactHardeningShadow is true.
  10149. */
  10150. /**
  10151. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10152. * Using a ratio helps keeping shape stability independently of the map size.
  10153. *
  10154. * It does not account for the light projection as it was having too much
  10155. * instability during the light setup or during light position changes.
  10156. *
  10157. * Only valid if useContactHardeningShadow is true.
  10158. */
  10159. contactHardeningLightSizeUVRatio: number;
  10160. private _darkness;
  10161. /**
  10162. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10163. * 0 means strongest and 1 would means no shadow.
  10164. * @returns the darkness.
  10165. */
  10166. getDarkness(): number;
  10167. /**
  10168. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10169. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10170. * @returns the shadow generator allowing fluent coding.
  10171. */
  10172. setDarkness(darkness: number): ShadowGenerator;
  10173. private _transparencyShadow;
  10174. /**
  10175. * Sets the ability to have transparent shadow (boolean).
  10176. * @param transparent True if transparent else False
  10177. * @returns the shadow generator allowing fluent coding
  10178. */
  10179. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10180. private _shadowMap;
  10181. private _shadowMap2;
  10182. /**
  10183. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10184. * @returns The render target texture if present otherwise, null
  10185. */
  10186. getShadowMap(): Nullable<RenderTargetTexture>;
  10187. /**
  10188. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10189. * @returns The render target texture if the shadow map is present otherwise, null
  10190. */
  10191. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10192. /**
  10193. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10194. * @param mesh Mesh to add
  10195. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10196. * @returns the Shadow Generator itself
  10197. */
  10198. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10199. /**
  10200. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10201. * @param mesh Mesh to remove
  10202. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10203. * @returns the Shadow Generator itself
  10204. */
  10205. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10206. /**
  10207. * Controls the extent to which the shadows fade out at the edge of the frustum
  10208. * Used only by directionals and spots
  10209. */
  10210. frustumEdgeFalloff: number;
  10211. private _light;
  10212. /**
  10213. * Returns the associated light object.
  10214. * @returns the light generating the shadow
  10215. */
  10216. getLight(): IShadowLight;
  10217. /**
  10218. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10219. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10220. * It might on the other hand introduce peter panning.
  10221. */
  10222. forceBackFacesOnly: boolean;
  10223. private _scene;
  10224. private _lightDirection;
  10225. private _effect;
  10226. private _viewMatrix;
  10227. private _projectionMatrix;
  10228. private _transformMatrix;
  10229. private _cachedPosition;
  10230. private _cachedDirection;
  10231. private _cachedDefines;
  10232. private _currentRenderID;
  10233. private _boxBlurPostprocess;
  10234. private _kernelBlurXPostprocess;
  10235. private _kernelBlurYPostprocess;
  10236. private _blurPostProcesses;
  10237. private _mapSize;
  10238. private _currentFaceIndex;
  10239. private _currentFaceIndexCache;
  10240. private _textureType;
  10241. private _defaultTextureMatrix;
  10242. /** @hidden */
  10243. static _SceneComponentInitialization: (scene: Scene) => void;
  10244. /**
  10245. * Creates a ShadowGenerator object.
  10246. * A ShadowGenerator is the required tool to use the shadows.
  10247. * Each light casting shadows needs to use its own ShadowGenerator.
  10248. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10249. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10250. * @param light The light object generating the shadows.
  10251. * @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.
  10252. */
  10253. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10254. private _initializeGenerator;
  10255. private _initializeShadowMap;
  10256. private _initializeBlurRTTAndPostProcesses;
  10257. private _renderForShadowMap;
  10258. private _renderSubMeshForShadowMap;
  10259. private _applyFilterValues;
  10260. /**
  10261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10262. * @param onCompiled Callback triggered at the and of the effects compilation
  10263. * @param options Sets of optional options forcing the compilation with different modes
  10264. */
  10265. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10266. useInstances: boolean;
  10267. }>): void;
  10268. /**
  10269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10270. * @param options Sets of optional options forcing the compilation with different modes
  10271. * @returns A promise that resolves when the compilation completes
  10272. */
  10273. forceCompilationAsync(options?: Partial<{
  10274. useInstances: boolean;
  10275. }>): Promise<void>;
  10276. /**
  10277. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10278. * @param subMesh The submesh we want to render in the shadow map
  10279. * @param useInstances Defines wether will draw in the map using instances
  10280. * @returns true if ready otherwise, false
  10281. */
  10282. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10283. /**
  10284. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10285. * @param defines Defines of the material we want to update
  10286. * @param lightIndex Index of the light in the enabled light list of the material
  10287. */
  10288. prepareDefines(defines: any, lightIndex: number): void;
  10289. /**
  10290. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10291. * defined in the generator but impacting the effect).
  10292. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10293. * @param effect The effect we are binfing the information for
  10294. */
  10295. bindShadowLight(lightIndex: string, effect: Effect): void;
  10296. /**
  10297. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10298. * (eq to shadow prjection matrix * light transform matrix)
  10299. * @returns The transform matrix used to create the shadow map
  10300. */
  10301. getTransformMatrix(): Matrix;
  10302. /**
  10303. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10304. * Cube and 2D textures for instance.
  10305. */
  10306. recreateShadowMap(): void;
  10307. private _disposeBlurPostProcesses;
  10308. private _disposeRTTandPostProcesses;
  10309. /**
  10310. * Disposes the ShadowGenerator.
  10311. * Returns nothing.
  10312. */
  10313. dispose(): void;
  10314. /**
  10315. * Serializes the shadow generator setup to a json object.
  10316. * @returns The serialized JSON object
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10321. * @param parsedShadowGenerator The JSON object to parse
  10322. * @param scene The scene to create the shadow map for
  10323. * @returns The parsed shadow generator
  10324. */
  10325. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10326. }
  10327. }
  10328. declare module "babylonjs/Lights/light" {
  10329. import { Nullable } from "babylonjs/types";
  10330. import { Scene } from "babylonjs/scene";
  10331. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10332. import { Node } from "babylonjs/node";
  10333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10334. import { Effect } from "babylonjs/Materials/effect";
  10335. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10336. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10337. /**
  10338. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10339. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10340. * 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.
  10341. */
  10342. export abstract class Light extends Node {
  10343. /**
  10344. * Falloff Default: light is falling off following the material specification:
  10345. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10346. */
  10347. static readonly FALLOFF_DEFAULT: number;
  10348. /**
  10349. * Falloff Physical: light is falling off following the inverse squared distance law.
  10350. */
  10351. static readonly FALLOFF_PHYSICAL: number;
  10352. /**
  10353. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10354. * to enhance interoperability with other engines.
  10355. */
  10356. static readonly FALLOFF_GLTF: number;
  10357. /**
  10358. * Falloff Standard: light is falling off like in the standard material
  10359. * to enhance interoperability with other materials.
  10360. */
  10361. static readonly FALLOFF_STANDARD: number;
  10362. /**
  10363. * If every light affecting the material is in this lightmapMode,
  10364. * material.lightmapTexture adds or multiplies
  10365. * (depends on material.useLightmapAsShadowmap)
  10366. * after every other light calculations.
  10367. */
  10368. static readonly LIGHTMAP_DEFAULT: number;
  10369. /**
  10370. * material.lightmapTexture as only diffuse lighting from this light
  10371. * adds only specular lighting from this light
  10372. * adds dynamic shadows
  10373. */
  10374. static readonly LIGHTMAP_SPECULAR: number;
  10375. /**
  10376. * material.lightmapTexture as only lighting
  10377. * no light calculation from this light
  10378. * only adds dynamic shadows from this light
  10379. */
  10380. static readonly LIGHTMAP_SHADOWSONLY: number;
  10381. /**
  10382. * Each light type uses the default quantity according to its type:
  10383. * point/spot lights use luminous intensity
  10384. * directional lights use illuminance
  10385. */
  10386. static readonly INTENSITYMODE_AUTOMATIC: number;
  10387. /**
  10388. * lumen (lm)
  10389. */
  10390. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10391. /**
  10392. * candela (lm/sr)
  10393. */
  10394. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10395. /**
  10396. * lux (lm/m^2)
  10397. */
  10398. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10399. /**
  10400. * nit (cd/m^2)
  10401. */
  10402. static readonly INTENSITYMODE_LUMINANCE: number;
  10403. /**
  10404. * Light type const id of the point light.
  10405. */
  10406. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10407. /**
  10408. * Light type const id of the directional light.
  10409. */
  10410. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10411. /**
  10412. * Light type const id of the spot light.
  10413. */
  10414. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10415. /**
  10416. * Light type const id of the hemispheric light.
  10417. */
  10418. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10419. /**
  10420. * Diffuse gives the basic color to an object.
  10421. */
  10422. diffuse: Color3;
  10423. /**
  10424. * Specular produces a highlight color on an object.
  10425. * Note: This is note affecting PBR materials.
  10426. */
  10427. specular: Color3;
  10428. /**
  10429. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10430. * falling off base on range or angle.
  10431. * This can be set to any values in Light.FALLOFF_x.
  10432. *
  10433. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10434. * other types of materials.
  10435. */
  10436. falloffType: number;
  10437. /**
  10438. * Strength of the light.
  10439. * Note: By default it is define in the framework own unit.
  10440. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10441. */
  10442. intensity: number;
  10443. private _range;
  10444. protected _inverseSquaredRange: number;
  10445. /**
  10446. * Defines how far from the source the light is impacting in scene units.
  10447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10448. */
  10449. /**
  10450. * Defines how far from the source the light is impacting in scene units.
  10451. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10452. */
  10453. range: number;
  10454. /**
  10455. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10456. * of light.
  10457. */
  10458. private _photometricScale;
  10459. private _intensityMode;
  10460. /**
  10461. * Gets the photometric scale used to interpret the intensity.
  10462. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10463. */
  10464. /**
  10465. * Sets the photometric scale used to interpret the intensity.
  10466. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10467. */
  10468. intensityMode: number;
  10469. private _radius;
  10470. /**
  10471. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10472. */
  10473. /**
  10474. * sets the light radius used by PBR Materials to simulate soft area lights.
  10475. */
  10476. radius: number;
  10477. private _renderPriority;
  10478. /**
  10479. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10480. * exceeding the number allowed of the materials.
  10481. */
  10482. renderPriority: number;
  10483. private _shadowEnabled;
  10484. /**
  10485. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10486. * the current shadow generator.
  10487. */
  10488. /**
  10489. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10490. * the current shadow generator.
  10491. */
  10492. shadowEnabled: boolean;
  10493. private _includedOnlyMeshes;
  10494. /**
  10495. * Gets the only meshes impacted by this light.
  10496. */
  10497. /**
  10498. * Sets the only meshes impacted by this light.
  10499. */
  10500. includedOnlyMeshes: AbstractMesh[];
  10501. private _excludedMeshes;
  10502. /**
  10503. * Gets the meshes not impacted by this light.
  10504. */
  10505. /**
  10506. * Sets the meshes not impacted by this light.
  10507. */
  10508. excludedMeshes: AbstractMesh[];
  10509. private _excludeWithLayerMask;
  10510. /**
  10511. * Gets the layer id use to find what meshes are not impacted by the light.
  10512. * Inactive if 0
  10513. */
  10514. /**
  10515. * Sets the layer id use to find what meshes are not impacted by the light.
  10516. * Inactive if 0
  10517. */
  10518. excludeWithLayerMask: number;
  10519. private _includeOnlyWithLayerMask;
  10520. /**
  10521. * Gets the layer id use to find what meshes are impacted by the light.
  10522. * Inactive if 0
  10523. */
  10524. /**
  10525. * Sets the layer id use to find what meshes are impacted by the light.
  10526. * Inactive if 0
  10527. */
  10528. includeOnlyWithLayerMask: number;
  10529. private _lightmapMode;
  10530. /**
  10531. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10532. */
  10533. /**
  10534. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10535. */
  10536. lightmapMode: number;
  10537. /**
  10538. * Shadow generator associted to the light.
  10539. * @hidden Internal use only.
  10540. */
  10541. _shadowGenerator: Nullable<IShadowGenerator>;
  10542. /**
  10543. * @hidden Internal use only.
  10544. */
  10545. _excludedMeshesIds: string[];
  10546. /**
  10547. * @hidden Internal use only.
  10548. */
  10549. _includedOnlyMeshesIds: string[];
  10550. /**
  10551. * The current light unifom buffer.
  10552. * @hidden Internal use only.
  10553. */
  10554. _uniformBuffer: UniformBuffer;
  10555. /**
  10556. * Creates a Light object in the scene.
  10557. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10558. * @param name The firendly name of the light
  10559. * @param scene The scene the light belongs too
  10560. */
  10561. constructor(name: string, scene: Scene);
  10562. protected abstract _buildUniformLayout(): void;
  10563. /**
  10564. * Sets the passed Effect "effect" with the Light information.
  10565. * @param effect The effect to update
  10566. * @param lightIndex The index of the light in the effect to update
  10567. * @returns The light
  10568. */
  10569. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10570. /**
  10571. * Returns the string "Light".
  10572. * @returns the class name
  10573. */
  10574. getClassName(): string;
  10575. /** @hidden */
  10576. readonly _isLight: boolean;
  10577. /**
  10578. * Converts the light information to a readable string for debug purpose.
  10579. * @param fullDetails Supports for multiple levels of logging within scene loading
  10580. * @returns the human readable light info
  10581. */
  10582. toString(fullDetails?: boolean): string;
  10583. /** @hidden */
  10584. protected _syncParentEnabledState(): void;
  10585. /**
  10586. * Set the enabled state of this node.
  10587. * @param value - the new enabled state
  10588. */
  10589. setEnabled(value: boolean): void;
  10590. /**
  10591. * Returns the Light associated shadow generator if any.
  10592. * @return the associated shadow generator.
  10593. */
  10594. getShadowGenerator(): Nullable<IShadowGenerator>;
  10595. /**
  10596. * Returns a Vector3, the absolute light position in the World.
  10597. * @returns the world space position of the light
  10598. */
  10599. getAbsolutePosition(): Vector3;
  10600. /**
  10601. * Specifies if the light will affect the passed mesh.
  10602. * @param mesh The mesh to test against the light
  10603. * @return true the mesh is affected otherwise, false.
  10604. */
  10605. canAffectMesh(mesh: AbstractMesh): boolean;
  10606. /**
  10607. * Sort function to order lights for rendering.
  10608. * @param a First Light object to compare to second.
  10609. * @param b Second Light object to compare first.
  10610. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10611. */
  10612. static CompareLightsPriority(a: Light, b: Light): number;
  10613. /**
  10614. * Releases resources associated with this node.
  10615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10617. */
  10618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10619. /**
  10620. * Returns the light type ID (integer).
  10621. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10622. */
  10623. getTypeID(): number;
  10624. /**
  10625. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10626. * @returns the scaled intensity in intensity mode unit
  10627. */
  10628. getScaledIntensity(): number;
  10629. /**
  10630. * Returns a new Light object, named "name", from the current one.
  10631. * @param name The name of the cloned light
  10632. * @returns the new created light
  10633. */
  10634. clone(name: string): Nullable<Light>;
  10635. /**
  10636. * Serializes the current light into a Serialization object.
  10637. * @returns the serialized object.
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10642. * This new light is named "name" and added to the passed scene.
  10643. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10644. * @param name The friendly name of the light
  10645. * @param scene The scene the new light will belong to
  10646. * @returns the constructor function
  10647. */
  10648. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10649. /**
  10650. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10651. * @param parsedLight The JSON representation of the light
  10652. * @param scene The scene to create the parsed light in
  10653. * @returns the created light after parsing
  10654. */
  10655. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10656. private _hookArrayForExcluded;
  10657. private _hookArrayForIncludedOnly;
  10658. private _resyncMeshes;
  10659. /**
  10660. * Forces the meshes to update their light related information in their rendering used effects
  10661. * @hidden Internal Use Only
  10662. */
  10663. _markMeshesAsLightDirty(): void;
  10664. /**
  10665. * Recomputes the cached photometric scale if needed.
  10666. */
  10667. private _computePhotometricScale;
  10668. /**
  10669. * Returns the Photometric Scale according to the light type and intensity mode.
  10670. */
  10671. private _getPhotometricScale;
  10672. /**
  10673. * Reorder the light in the scene according to their defined priority.
  10674. * @hidden Internal Use Only
  10675. */
  10676. _reorderLightsInScene(): void;
  10677. /**
  10678. * Prepares the list of defines specific to the light type.
  10679. * @param defines the list of defines
  10680. * @param lightIndex defines the index of the light for the effect
  10681. */
  10682. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10683. }
  10684. }
  10685. declare module "babylonjs/Actions/action" {
  10686. import { Observable } from "babylonjs/Misc/observable";
  10687. import { Condition } from "babylonjs/Actions/condition";
  10688. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10689. import { ActionManager } from "babylonjs/Actions/actionManager";
  10690. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10691. /**
  10692. * Interface used to define Action
  10693. */
  10694. export interface IAction {
  10695. /**
  10696. * Trigger for the action
  10697. */
  10698. trigger: number;
  10699. /** Options of the trigger */
  10700. triggerOptions: any;
  10701. /**
  10702. * Gets the trigger parameters
  10703. * @returns the trigger parameters
  10704. */
  10705. getTriggerParameter(): any;
  10706. /**
  10707. * Internal only - executes current action event
  10708. * @hidden
  10709. */
  10710. _executeCurrent(evt?: ActionEvent): void;
  10711. /**
  10712. * Serialize placeholder for child classes
  10713. * @param parent of child
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. _prepare(): void;
  10722. /**
  10723. * Internal only - manager for action
  10724. * @hidden
  10725. */
  10726. _actionManager: AbstractActionManager;
  10727. }
  10728. /**
  10729. * The action to be carried out following a trigger
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10731. */
  10732. export class Action implements IAction {
  10733. /** the trigger, with or without parameters, for the action */
  10734. triggerOptions: any;
  10735. /**
  10736. * Trigger for the action
  10737. */
  10738. trigger: number;
  10739. /**
  10740. * Internal only - manager for action
  10741. * @hidden
  10742. */
  10743. _actionManager: ActionManager;
  10744. private _nextActiveAction;
  10745. private _child;
  10746. private _condition?;
  10747. private _triggerParameter;
  10748. /**
  10749. * An event triggered prior to action being executed.
  10750. */
  10751. onBeforeExecuteObservable: Observable<Action>;
  10752. /**
  10753. * Creates a new Action
  10754. * @param triggerOptions the trigger, with or without parameters, for the action
  10755. * @param condition an optional determinant of action
  10756. */
  10757. constructor(
  10758. /** the trigger, with or without parameters, for the action */
  10759. triggerOptions: any, condition?: Condition);
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. _prepare(): void;
  10765. /**
  10766. * Gets the trigger parameters
  10767. * @returns the trigger parameters
  10768. */
  10769. getTriggerParameter(): any;
  10770. /**
  10771. * Internal only - executes current action event
  10772. * @hidden
  10773. */
  10774. _executeCurrent(evt?: ActionEvent): void;
  10775. /**
  10776. * Execute placeholder for child classes
  10777. * @param evt optional action event
  10778. */
  10779. execute(evt?: ActionEvent): void;
  10780. /**
  10781. * Skips to next active action
  10782. */
  10783. skipToNextActiveAction(): void;
  10784. /**
  10785. * Adds action to chain of actions, may be a DoNothingAction
  10786. * @param action defines the next action to execute
  10787. * @returns The action passed in
  10788. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10789. */
  10790. then(action: Action): Action;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. _getProperty(propertyPath: string): string;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. _getEffectiveTarget(target: any, propertyPath: string): any;
  10801. /**
  10802. * Serialize placeholder for child classes
  10803. * @param parent of child
  10804. * @returns the serialized object
  10805. */
  10806. serialize(parent: any): any;
  10807. /**
  10808. * Internal only called by serialize
  10809. * @hidden
  10810. */
  10811. protected _serialize(serializedAction: any, parent?: any): any;
  10812. /**
  10813. * Internal only
  10814. * @hidden
  10815. */
  10816. static _SerializeValueAsString: (value: any) => string;
  10817. /**
  10818. * Internal only
  10819. * @hidden
  10820. */
  10821. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10822. name: string;
  10823. targetType: string;
  10824. value: string;
  10825. };
  10826. }
  10827. }
  10828. declare module "babylonjs/Actions/condition" {
  10829. import { ActionManager } from "babylonjs/Actions/actionManager";
  10830. /**
  10831. * A Condition applied to an Action
  10832. */
  10833. export class Condition {
  10834. /**
  10835. * Internal only - manager for action
  10836. * @hidden
  10837. */
  10838. _actionManager: ActionManager;
  10839. /**
  10840. * Internal only
  10841. * @hidden
  10842. */
  10843. _evaluationId: number;
  10844. /**
  10845. * Internal only
  10846. * @hidden
  10847. */
  10848. _currentResult: boolean;
  10849. /**
  10850. * Creates a new Condition
  10851. * @param actionManager the manager of the action the condition is applied to
  10852. */
  10853. constructor(actionManager: ActionManager);
  10854. /**
  10855. * Check if the current condition is valid
  10856. * @returns a boolean
  10857. */
  10858. isValid(): boolean;
  10859. /**
  10860. * Internal only
  10861. * @hidden
  10862. */
  10863. _getProperty(propertyPath: string): string;
  10864. /**
  10865. * Internal only
  10866. * @hidden
  10867. */
  10868. _getEffectiveTarget(target: any, propertyPath: string): any;
  10869. /**
  10870. * Serialize placeholder for child classes
  10871. * @returns the serialized object
  10872. */
  10873. serialize(): any;
  10874. /**
  10875. * Internal only
  10876. * @hidden
  10877. */
  10878. protected _serialize(serializedCondition: any): any;
  10879. }
  10880. /**
  10881. * Defines specific conditional operators as extensions of Condition
  10882. */
  10883. export class ValueCondition extends Condition {
  10884. /** path to specify the property of the target the conditional operator uses */
  10885. propertyPath: string;
  10886. /** the value compared by the conditional operator against the current value of the property */
  10887. value: any;
  10888. /** the conditional operator, default ValueCondition.IsEqual */
  10889. operator: number;
  10890. /**
  10891. * Internal only
  10892. * @hidden
  10893. */
  10894. private static _IsEqual;
  10895. /**
  10896. * Internal only
  10897. * @hidden
  10898. */
  10899. private static _IsDifferent;
  10900. /**
  10901. * Internal only
  10902. * @hidden
  10903. */
  10904. private static _IsGreater;
  10905. /**
  10906. * Internal only
  10907. * @hidden
  10908. */
  10909. private static _IsLesser;
  10910. /**
  10911. * returns the number for IsEqual
  10912. */
  10913. static readonly IsEqual: number;
  10914. /**
  10915. * Returns the number for IsDifferent
  10916. */
  10917. static readonly IsDifferent: number;
  10918. /**
  10919. * Returns the number for IsGreater
  10920. */
  10921. static readonly IsGreater: number;
  10922. /**
  10923. * Returns the number for IsLesser
  10924. */
  10925. static readonly IsLesser: number;
  10926. /**
  10927. * Internal only The action manager for the condition
  10928. * @hidden
  10929. */
  10930. _actionManager: ActionManager;
  10931. /**
  10932. * Internal only
  10933. * @hidden
  10934. */
  10935. private _target;
  10936. /**
  10937. * Internal only
  10938. * @hidden
  10939. */
  10940. private _effectiveTarget;
  10941. /**
  10942. * Internal only
  10943. * @hidden
  10944. */
  10945. private _property;
  10946. /**
  10947. * Creates a new ValueCondition
  10948. * @param actionManager manager for the action the condition applies to
  10949. * @param target for the action
  10950. * @param propertyPath path to specify the property of the target the conditional operator uses
  10951. * @param value the value compared by the conditional operator against the current value of the property
  10952. * @param operator the conditional operator, default ValueCondition.IsEqual
  10953. */
  10954. constructor(actionManager: ActionManager, target: any,
  10955. /** path to specify the property of the target the conditional operator uses */
  10956. propertyPath: string,
  10957. /** the value compared by the conditional operator against the current value of the property */
  10958. value: any,
  10959. /** the conditional operator, default ValueCondition.IsEqual */
  10960. operator?: number);
  10961. /**
  10962. * Compares the given value with the property value for the specified conditional operator
  10963. * @returns the result of the comparison
  10964. */
  10965. isValid(): boolean;
  10966. /**
  10967. * Serialize the ValueCondition into a JSON compatible object
  10968. * @returns serialization object
  10969. */
  10970. serialize(): any;
  10971. /**
  10972. * Gets the name of the conditional operator for the ValueCondition
  10973. * @param operator the conditional operator
  10974. * @returns the name
  10975. */
  10976. static GetOperatorName(operator: number): string;
  10977. }
  10978. /**
  10979. * Defines a predicate condition as an extension of Condition
  10980. */
  10981. export class PredicateCondition extends Condition {
  10982. /** defines the predicate function used to validate the condition */
  10983. predicate: () => boolean;
  10984. /**
  10985. * Internal only - manager for action
  10986. * @hidden
  10987. */
  10988. _actionManager: ActionManager;
  10989. /**
  10990. * Creates a new PredicateCondition
  10991. * @param actionManager manager for the action the condition applies to
  10992. * @param predicate defines the predicate function used to validate the condition
  10993. */
  10994. constructor(actionManager: ActionManager,
  10995. /** defines the predicate function used to validate the condition */
  10996. predicate: () => boolean);
  10997. /**
  10998. * @returns the validity of the predicate condition
  10999. */
  11000. isValid(): boolean;
  11001. }
  11002. /**
  11003. * Defines a state condition as an extension of Condition
  11004. */
  11005. export class StateCondition extends Condition {
  11006. /** Value to compare with target state */
  11007. value: string;
  11008. /**
  11009. * Internal only - manager for action
  11010. * @hidden
  11011. */
  11012. _actionManager: ActionManager;
  11013. /**
  11014. * Internal only
  11015. * @hidden
  11016. */
  11017. private _target;
  11018. /**
  11019. * Creates a new StateCondition
  11020. * @param actionManager manager for the action the condition applies to
  11021. * @param target of the condition
  11022. * @param value to compare with target state
  11023. */
  11024. constructor(actionManager: ActionManager, target: any,
  11025. /** Value to compare with target state */
  11026. value: string);
  11027. /**
  11028. * Gets a boolean indicating if the current condition is met
  11029. * @returns the validity of the state
  11030. */
  11031. isValid(): boolean;
  11032. /**
  11033. * Serialize the StateCondition into a JSON compatible object
  11034. * @returns serialization object
  11035. */
  11036. serialize(): any;
  11037. }
  11038. }
  11039. declare module "babylonjs/Actions/directActions" {
  11040. import { Action } from "babylonjs/Actions/action";
  11041. import { Condition } from "babylonjs/Actions/condition";
  11042. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11043. /**
  11044. * This defines an action responsible to toggle a boolean once triggered.
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11046. */
  11047. export class SwitchBooleanAction extends Action {
  11048. /**
  11049. * The path to the boolean property in the target object
  11050. */
  11051. propertyPath: string;
  11052. private _target;
  11053. private _effectiveTarget;
  11054. private _property;
  11055. /**
  11056. * Instantiate the action
  11057. * @param triggerOptions defines the trigger options
  11058. * @param target defines the object containing the boolean
  11059. * @param propertyPath defines the path to the boolean property in the target object
  11060. * @param condition defines the trigger related conditions
  11061. */
  11062. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11063. /** @hidden */
  11064. _prepare(): void;
  11065. /**
  11066. * Execute the action toggle the boolean value.
  11067. */
  11068. execute(): void;
  11069. /**
  11070. * Serializes the actions and its related information.
  11071. * @param parent defines the object to serialize in
  11072. * @returns the serialized object
  11073. */
  11074. serialize(parent: any): any;
  11075. }
  11076. /**
  11077. * This defines an action responsible to set a the state field of the target
  11078. * to a desired value once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class SetStateAction extends Action {
  11082. /**
  11083. * The value to store in the state field.
  11084. */
  11085. value: string;
  11086. private _target;
  11087. /**
  11088. * Instantiate the action
  11089. * @param triggerOptions defines the trigger options
  11090. * @param target defines the object containing the state property
  11091. * @param value defines the value to store in the state field
  11092. * @param condition defines the trigger related conditions
  11093. */
  11094. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11095. /**
  11096. * Execute the action and store the value on the target state property.
  11097. */
  11098. execute(): void;
  11099. /**
  11100. * Serializes the actions and its related information.
  11101. * @param parent defines the object to serialize in
  11102. * @returns the serialized object
  11103. */
  11104. serialize(parent: any): any;
  11105. }
  11106. /**
  11107. * This defines an action responsible to set a property of the target
  11108. * to a desired value once triggered.
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11110. */
  11111. export class SetValueAction extends Action {
  11112. /**
  11113. * The path of the property to set in the target.
  11114. */
  11115. propertyPath: string;
  11116. /**
  11117. * The value to set in the property
  11118. */
  11119. value: any;
  11120. private _target;
  11121. private _effectiveTarget;
  11122. private _property;
  11123. /**
  11124. * Instantiate the action
  11125. * @param triggerOptions defines the trigger options
  11126. * @param target defines the object containing the property
  11127. * @param propertyPath defines the path of the property to set in the target
  11128. * @param value defines the value to set in the property
  11129. * @param condition defines the trigger related conditions
  11130. */
  11131. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11132. /** @hidden */
  11133. _prepare(): void;
  11134. /**
  11135. * Execute the action and set the targetted property to the desired value.
  11136. */
  11137. execute(): void;
  11138. /**
  11139. * Serializes the actions and its related information.
  11140. * @param parent defines the object to serialize in
  11141. * @returns the serialized object
  11142. */
  11143. serialize(parent: any): any;
  11144. }
  11145. /**
  11146. * This defines an action responsible to increment the target value
  11147. * to a desired value once triggered.
  11148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11149. */
  11150. export class IncrementValueAction extends Action {
  11151. /**
  11152. * The path of the property to increment in the target.
  11153. */
  11154. propertyPath: string;
  11155. /**
  11156. * The value we should increment the property by.
  11157. */
  11158. value: any;
  11159. private _target;
  11160. private _effectiveTarget;
  11161. private _property;
  11162. /**
  11163. * Instantiate the action
  11164. * @param triggerOptions defines the trigger options
  11165. * @param target defines the object containing the property
  11166. * @param propertyPath defines the path of the property to increment in the target
  11167. * @param value defines the value value we should increment the property by
  11168. * @param condition defines the trigger related conditions
  11169. */
  11170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11171. /** @hidden */
  11172. _prepare(): void;
  11173. /**
  11174. * Execute the action and increment the target of the value amount.
  11175. */
  11176. execute(): void;
  11177. /**
  11178. * Serializes the actions and its related information.
  11179. * @param parent defines the object to serialize in
  11180. * @returns the serialized object
  11181. */
  11182. serialize(parent: any): any;
  11183. }
  11184. /**
  11185. * This defines an action responsible to start an animation once triggered.
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11187. */
  11188. export class PlayAnimationAction extends Action {
  11189. /**
  11190. * Where the animation should start (animation frame)
  11191. */
  11192. from: number;
  11193. /**
  11194. * Where the animation should stop (animation frame)
  11195. */
  11196. to: number;
  11197. /**
  11198. * Define if the animation should loop or stop after the first play.
  11199. */
  11200. loop?: boolean;
  11201. private _target;
  11202. /**
  11203. * Instantiate the action
  11204. * @param triggerOptions defines the trigger options
  11205. * @param target defines the target animation or animation name
  11206. * @param from defines from where the animation should start (animation frame)
  11207. * @param end defines where the animation should stop (animation frame)
  11208. * @param loop defines if the animation should loop or stop after the first play
  11209. * @param condition defines the trigger related conditions
  11210. */
  11211. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11212. /** @hidden */
  11213. _prepare(): void;
  11214. /**
  11215. * Execute the action and play the animation.
  11216. */
  11217. execute(): void;
  11218. /**
  11219. * Serializes the actions and its related information.
  11220. * @param parent defines the object to serialize in
  11221. * @returns the serialized object
  11222. */
  11223. serialize(parent: any): any;
  11224. }
  11225. /**
  11226. * This defines an action responsible to stop an animation once triggered.
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11228. */
  11229. export class StopAnimationAction extends Action {
  11230. private _target;
  11231. /**
  11232. * Instantiate the action
  11233. * @param triggerOptions defines the trigger options
  11234. * @param target defines the target animation or animation name
  11235. * @param condition defines the trigger related conditions
  11236. */
  11237. constructor(triggerOptions: any, target: any, condition?: Condition);
  11238. /** @hidden */
  11239. _prepare(): void;
  11240. /**
  11241. * Execute the action and stop the animation.
  11242. */
  11243. execute(): void;
  11244. /**
  11245. * Serializes the actions and its related information.
  11246. * @param parent defines the object to serialize in
  11247. * @returns the serialized object
  11248. */
  11249. serialize(parent: any): any;
  11250. }
  11251. /**
  11252. * This defines an action responsible that does nothing once triggered.
  11253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11254. */
  11255. export class DoNothingAction extends Action {
  11256. /**
  11257. * Instantiate the action
  11258. * @param triggerOptions defines the trigger options
  11259. * @param condition defines the trigger related conditions
  11260. */
  11261. constructor(triggerOptions?: any, condition?: Condition);
  11262. /**
  11263. * Execute the action and do nothing.
  11264. */
  11265. execute(): void;
  11266. /**
  11267. * Serializes the actions and its related information.
  11268. * @param parent defines the object to serialize in
  11269. * @returns the serialized object
  11270. */
  11271. serialize(parent: any): any;
  11272. }
  11273. /**
  11274. * This defines an action responsible to trigger several actions once triggered.
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11276. */
  11277. export class CombineAction extends Action {
  11278. /**
  11279. * The list of aggregated animations to run.
  11280. */
  11281. children: Action[];
  11282. /**
  11283. * Instantiate the action
  11284. * @param triggerOptions defines the trigger options
  11285. * @param children defines the list of aggregated animations to run
  11286. * @param condition defines the trigger related conditions
  11287. */
  11288. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11289. /** @hidden */
  11290. _prepare(): void;
  11291. /**
  11292. * Execute the action and executes all the aggregated actions.
  11293. */
  11294. execute(evt: ActionEvent): void;
  11295. /**
  11296. * Serializes the actions and its related information.
  11297. * @param parent defines the object to serialize in
  11298. * @returns the serialized object
  11299. */
  11300. serialize(parent: any): any;
  11301. }
  11302. /**
  11303. * This defines an action responsible to run code (external event) once triggered.
  11304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11305. */
  11306. export class ExecuteCodeAction extends Action {
  11307. /**
  11308. * The callback function to run.
  11309. */
  11310. func: (evt: ActionEvent) => void;
  11311. /**
  11312. * Instantiate the action
  11313. * @param triggerOptions defines the trigger options
  11314. * @param func defines the callback function to run
  11315. * @param condition defines the trigger related conditions
  11316. */
  11317. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11318. /**
  11319. * Execute the action and run the attached code.
  11320. */
  11321. execute(evt: ActionEvent): void;
  11322. }
  11323. /**
  11324. * This defines an action responsible to set the parent property of the target once triggered.
  11325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11326. */
  11327. export class SetParentAction extends Action {
  11328. private _parent;
  11329. private _target;
  11330. /**
  11331. * Instantiate the action
  11332. * @param triggerOptions defines the trigger options
  11333. * @param target defines the target containing the parent property
  11334. * @param parent defines from where the animation should start (animation frame)
  11335. * @param condition defines the trigger related conditions
  11336. */
  11337. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11338. /** @hidden */
  11339. _prepare(): void;
  11340. /**
  11341. * Execute the action and set the parent property.
  11342. */
  11343. execute(): void;
  11344. /**
  11345. * Serializes the actions and its related information.
  11346. * @param parent defines the object to serialize in
  11347. * @returns the serialized object
  11348. */
  11349. serialize(parent: any): any;
  11350. }
  11351. }
  11352. declare module "babylonjs/Actions/actionManager" {
  11353. import { Nullable } from "babylonjs/types";
  11354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11355. import { Scene } from "babylonjs/scene";
  11356. import { IAction } from "babylonjs/Actions/action";
  11357. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11358. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11359. /**
  11360. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11361. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11363. */
  11364. export class ActionManager extends AbstractActionManager {
  11365. /**
  11366. * Nothing
  11367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11368. */
  11369. static readonly NothingTrigger: number;
  11370. /**
  11371. * On pick
  11372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11373. */
  11374. static readonly OnPickTrigger: number;
  11375. /**
  11376. * On left pick
  11377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11378. */
  11379. static readonly OnLeftPickTrigger: number;
  11380. /**
  11381. * On right pick
  11382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11383. */
  11384. static readonly OnRightPickTrigger: number;
  11385. /**
  11386. * On center pick
  11387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11388. */
  11389. static readonly OnCenterPickTrigger: number;
  11390. /**
  11391. * On pick down
  11392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11393. */
  11394. static readonly OnPickDownTrigger: number;
  11395. /**
  11396. * On double pick
  11397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11398. */
  11399. static readonly OnDoublePickTrigger: number;
  11400. /**
  11401. * On pick up
  11402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11403. */
  11404. static readonly OnPickUpTrigger: number;
  11405. /**
  11406. * On pick out.
  11407. * This trigger will only be raised if you also declared a OnPickDown
  11408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11409. */
  11410. static readonly OnPickOutTrigger: number;
  11411. /**
  11412. * On long press
  11413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11414. */
  11415. static readonly OnLongPressTrigger: number;
  11416. /**
  11417. * On pointer over
  11418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11419. */
  11420. static readonly OnPointerOverTrigger: number;
  11421. /**
  11422. * On pointer out
  11423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11424. */
  11425. static readonly OnPointerOutTrigger: number;
  11426. /**
  11427. * On every frame
  11428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11429. */
  11430. static readonly OnEveryFrameTrigger: number;
  11431. /**
  11432. * On intersection enter
  11433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11434. */
  11435. static readonly OnIntersectionEnterTrigger: number;
  11436. /**
  11437. * On intersection exit
  11438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11439. */
  11440. static readonly OnIntersectionExitTrigger: number;
  11441. /**
  11442. * On key down
  11443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11444. */
  11445. static readonly OnKeyDownTrigger: number;
  11446. /**
  11447. * On key up
  11448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11449. */
  11450. static readonly OnKeyUpTrigger: number;
  11451. private _scene;
  11452. /**
  11453. * Creates a new action manager
  11454. * @param scene defines the hosting scene
  11455. */
  11456. constructor(scene: Scene);
  11457. /**
  11458. * Releases all associated resources
  11459. */
  11460. dispose(): void;
  11461. /**
  11462. * Gets hosting scene
  11463. * @returns the hosting scene
  11464. */
  11465. getScene(): Scene;
  11466. /**
  11467. * Does this action manager handles actions of any of the given triggers
  11468. * @param triggers defines the triggers to be tested
  11469. * @return a boolean indicating whether one (or more) of the triggers is handled
  11470. */
  11471. hasSpecificTriggers(triggers: number[]): boolean;
  11472. /**
  11473. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11474. * speed.
  11475. * @param triggerA defines the trigger to be tested
  11476. * @param triggerB defines the trigger to be tested
  11477. * @return a boolean indicating whether one (or more) of the triggers is handled
  11478. */
  11479. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11480. /**
  11481. * Does this action manager handles actions of a given trigger
  11482. * @param trigger defines the trigger to be tested
  11483. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11484. * @return whether the trigger is handled
  11485. */
  11486. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11487. /**
  11488. * Does this action manager has pointer triggers
  11489. */
  11490. readonly hasPointerTriggers: boolean;
  11491. /**
  11492. * Does this action manager has pick triggers
  11493. */
  11494. readonly hasPickTriggers: boolean;
  11495. /**
  11496. * Registers an action to this action manager
  11497. * @param action defines the action to be registered
  11498. * @return the action amended (prepared) after registration
  11499. */
  11500. registerAction(action: IAction): Nullable<IAction>;
  11501. /**
  11502. * Unregisters an action to this action manager
  11503. * @param action defines the action to be unregistered
  11504. * @return a boolean indicating whether the action has been unregistered
  11505. */
  11506. unregisterAction(action: IAction): Boolean;
  11507. /**
  11508. * Process a specific trigger
  11509. * @param trigger defines the trigger to process
  11510. * @param evt defines the event details to be processed
  11511. */
  11512. processTrigger(trigger: number, evt?: IActionEvent): void;
  11513. /** @hidden */
  11514. _getEffectiveTarget(target: any, propertyPath: string): any;
  11515. /** @hidden */
  11516. _getProperty(propertyPath: string): string;
  11517. /**
  11518. * Serialize this manager to a JSON object
  11519. * @param name defines the property name to store this manager
  11520. * @returns a JSON representation of this manager
  11521. */
  11522. serialize(name: string): any;
  11523. /**
  11524. * Creates a new ActionManager from a JSON data
  11525. * @param parsedActions defines the JSON data to read from
  11526. * @param object defines the hosting mesh
  11527. * @param scene defines the hosting scene
  11528. */
  11529. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11530. /**
  11531. * Get a trigger name by index
  11532. * @param trigger defines the trigger index
  11533. * @returns a trigger name
  11534. */
  11535. static GetTriggerName(trigger: number): string;
  11536. }
  11537. }
  11538. declare module "babylonjs/Culling/ray" {
  11539. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11540. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11543. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11544. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11545. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11546. /**
  11547. * Class representing a ray with position and direction
  11548. */
  11549. export class Ray {
  11550. /** origin point */
  11551. origin: Vector3;
  11552. /** direction */
  11553. direction: Vector3;
  11554. /** length of the ray */
  11555. length: number;
  11556. private static readonly TmpVector3;
  11557. private _tmpRay;
  11558. /**
  11559. * Creates a new ray
  11560. * @param origin origin point
  11561. * @param direction direction
  11562. * @param length length of the ray
  11563. */
  11564. constructor(
  11565. /** origin point */
  11566. origin: Vector3,
  11567. /** direction */
  11568. direction: Vector3,
  11569. /** length of the ray */
  11570. length?: number);
  11571. /**
  11572. * Checks if the ray intersects a box
  11573. * @param minimum bound of the box
  11574. * @param maximum bound of the box
  11575. * @param intersectionTreshold extra extend to be added to the box in all direction
  11576. * @returns if the box was hit
  11577. */
  11578. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11579. /**
  11580. * Checks if the ray intersects a box
  11581. * @param box the bounding box to check
  11582. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11583. * @returns if the box was hit
  11584. */
  11585. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11586. /**
  11587. * If the ray hits a sphere
  11588. * @param sphere the bounding sphere to check
  11589. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11590. * @returns true if it hits the sphere
  11591. */
  11592. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11593. /**
  11594. * If the ray hits a triange
  11595. * @param vertex0 triangle vertex
  11596. * @param vertex1 triangle vertex
  11597. * @param vertex2 triangle vertex
  11598. * @returns intersection information if hit
  11599. */
  11600. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11601. /**
  11602. * Checks if ray intersects a plane
  11603. * @param plane the plane to check
  11604. * @returns the distance away it was hit
  11605. */
  11606. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11607. /**
  11608. * Checks if ray intersects a mesh
  11609. * @param mesh the mesh to check
  11610. * @param fastCheck if only the bounding box should checked
  11611. * @returns picking info of the intersecton
  11612. */
  11613. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11614. /**
  11615. * Checks if ray intersects a mesh
  11616. * @param meshes the meshes to check
  11617. * @param fastCheck if only the bounding box should checked
  11618. * @param results array to store result in
  11619. * @returns Array of picking infos
  11620. */
  11621. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11622. private _comparePickingInfo;
  11623. private static smallnum;
  11624. private static rayl;
  11625. /**
  11626. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11627. * @param sega the first point of the segment to test the intersection against
  11628. * @param segb the second point of the segment to test the intersection against
  11629. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11630. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11631. */
  11632. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11633. /**
  11634. * Update the ray from viewport position
  11635. * @param x position
  11636. * @param y y position
  11637. * @param viewportWidth viewport width
  11638. * @param viewportHeight viewport height
  11639. * @param world world matrix
  11640. * @param view view matrix
  11641. * @param projection projection matrix
  11642. * @returns this ray updated
  11643. */
  11644. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11645. /**
  11646. * Creates a ray with origin and direction of 0,0,0
  11647. * @returns the new ray
  11648. */
  11649. static Zero(): Ray;
  11650. /**
  11651. * Creates a new ray from screen space and viewport
  11652. * @param x position
  11653. * @param y y position
  11654. * @param viewportWidth viewport width
  11655. * @param viewportHeight viewport height
  11656. * @param world world matrix
  11657. * @param view view matrix
  11658. * @param projection projection matrix
  11659. * @returns new ray
  11660. */
  11661. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11662. /**
  11663. * 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
  11664. * transformed to the given world matrix.
  11665. * @param origin The origin point
  11666. * @param end The end point
  11667. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11668. * @returns the new ray
  11669. */
  11670. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11671. /**
  11672. * Transforms a ray by a matrix
  11673. * @param ray ray to transform
  11674. * @param matrix matrix to apply
  11675. * @returns the resulting new ray
  11676. */
  11677. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11678. /**
  11679. * Transforms a ray by a matrix
  11680. * @param ray ray to transform
  11681. * @param matrix matrix to apply
  11682. * @param result ray to store result in
  11683. */
  11684. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11685. /**
  11686. * Unproject a ray from screen space to object space
  11687. * @param sourceX defines the screen space x coordinate to use
  11688. * @param sourceY defines the screen space y coordinate to use
  11689. * @param viewportWidth defines the current width of the viewport
  11690. * @param viewportHeight defines the current height of the viewport
  11691. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11692. * @param view defines the view matrix to use
  11693. * @param projection defines the projection matrix to use
  11694. */
  11695. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11696. }
  11697. /**
  11698. * Type used to define predicate used to select faces when a mesh intersection is detected
  11699. */
  11700. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11701. module "babylonjs/scene" {
  11702. interface Scene {
  11703. /** @hidden */
  11704. _tempPickingRay: Nullable<Ray>;
  11705. /** @hidden */
  11706. _cachedRayForTransform: Ray;
  11707. /** @hidden */
  11708. _pickWithRayInverseMatrix: Matrix;
  11709. /** @hidden */
  11710. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11711. /** @hidden */
  11712. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11713. }
  11714. }
  11715. }
  11716. declare module "babylonjs/sceneComponent" {
  11717. import { Scene } from "babylonjs/scene";
  11718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11720. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11721. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11722. import { Nullable } from "babylonjs/types";
  11723. import { Camera } from "babylonjs/Cameras/camera";
  11724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11725. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11726. import { AbstractScene } from "babylonjs/abstractScene";
  11727. /**
  11728. * Groups all the scene component constants in one place to ease maintenance.
  11729. * @hidden
  11730. */
  11731. export class SceneComponentConstants {
  11732. static readonly NAME_EFFECTLAYER: string;
  11733. static readonly NAME_LAYER: string;
  11734. static readonly NAME_LENSFLARESYSTEM: string;
  11735. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11736. static readonly NAME_PARTICLESYSTEM: string;
  11737. static readonly NAME_GAMEPAD: string;
  11738. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11739. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11740. static readonly NAME_DEPTHRENDERER: string;
  11741. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11742. static readonly NAME_SPRITE: string;
  11743. static readonly NAME_OUTLINERENDERER: string;
  11744. static readonly NAME_PROCEDURALTEXTURE: string;
  11745. static readonly NAME_SHADOWGENERATOR: string;
  11746. static readonly NAME_OCTREE: string;
  11747. static readonly NAME_PHYSICSENGINE: string;
  11748. static readonly NAME_AUDIO: string;
  11749. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11750. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11752. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11753. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11754. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11755. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11756. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11757. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11758. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11759. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11760. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11761. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11762. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11763. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11764. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11768. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11769. static readonly STEP_AFTERRENDER_AUDIO: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11772. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11774. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11775. static readonly STEP_POINTERMOVE_SPRITE: number;
  11776. static readonly STEP_POINTERDOWN_SPRITE: number;
  11777. static readonly STEP_POINTERUP_SPRITE: number;
  11778. }
  11779. /**
  11780. * This represents a scene component.
  11781. *
  11782. * This is used to decouple the dependency the scene is having on the different workloads like
  11783. * layers, post processes...
  11784. */
  11785. export interface ISceneComponent {
  11786. /**
  11787. * The name of the component. Each component must have a unique name.
  11788. */
  11789. name: string;
  11790. /**
  11791. * The scene the component belongs to.
  11792. */
  11793. scene: Scene;
  11794. /**
  11795. * Register the component to one instance of a scene.
  11796. */
  11797. register(): void;
  11798. /**
  11799. * Rebuilds the elements related to this component in case of
  11800. * context lost for instance.
  11801. */
  11802. rebuild(): void;
  11803. /**
  11804. * Disposes the component and the associated ressources.
  11805. */
  11806. dispose(): void;
  11807. }
  11808. /**
  11809. * This represents a SERIALIZABLE scene component.
  11810. *
  11811. * This extends Scene Component to add Serialization methods on top.
  11812. */
  11813. export interface ISceneSerializableComponent extends ISceneComponent {
  11814. /**
  11815. * Adds all the element from the container to the scene
  11816. * @param container the container holding the elements
  11817. */
  11818. addFromContainer(container: AbstractScene): void;
  11819. /**
  11820. * Removes all the elements in the container from the scene
  11821. * @param container contains the elements to remove
  11822. * @param dispose if the removed element should be disposed (default: false)
  11823. */
  11824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11825. /**
  11826. * Serializes the component data to the specified json object
  11827. * @param serializationObject The object to serialize to
  11828. */
  11829. serialize(serializationObject: any): void;
  11830. }
  11831. /**
  11832. * Strong typing of a Mesh related stage step action
  11833. */
  11834. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11835. /**
  11836. * Strong typing of a Evaluate Sub Mesh related stage step action
  11837. */
  11838. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11839. /**
  11840. * Strong typing of a Active Mesh related stage step action
  11841. */
  11842. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11843. /**
  11844. * Strong typing of a Camera related stage step action
  11845. */
  11846. export type CameraStageAction = (camera: Camera) => void;
  11847. /**
  11848. * Strong typing of a Camera Frame buffer related stage step action
  11849. */
  11850. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11851. /**
  11852. * Strong typing of a Render Target related stage step action
  11853. */
  11854. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11855. /**
  11856. * Strong typing of a RenderingGroup related stage step action
  11857. */
  11858. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11859. /**
  11860. * Strong typing of a Mesh Render related stage step action
  11861. */
  11862. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11863. /**
  11864. * Strong typing of a simple stage step action
  11865. */
  11866. export type SimpleStageAction = () => void;
  11867. /**
  11868. * Strong typing of a render target action.
  11869. */
  11870. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11871. /**
  11872. * Strong typing of a pointer move action.
  11873. */
  11874. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11875. /**
  11876. * Strong typing of a pointer up/down action.
  11877. */
  11878. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11879. /**
  11880. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11881. * @hidden
  11882. */
  11883. export class Stage<T extends Function> extends Array<{
  11884. index: number;
  11885. component: ISceneComponent;
  11886. action: T;
  11887. }> {
  11888. /**
  11889. * Hide ctor from the rest of the world.
  11890. * @param items The items to add.
  11891. */
  11892. private constructor();
  11893. /**
  11894. * Creates a new Stage.
  11895. * @returns A new instance of a Stage
  11896. */
  11897. static Create<T extends Function>(): Stage<T>;
  11898. /**
  11899. * Registers a step in an ordered way in the targeted stage.
  11900. * @param index Defines the position to register the step in
  11901. * @param component Defines the component attached to the step
  11902. * @param action Defines the action to launch during the step
  11903. */
  11904. registerStep(index: number, component: ISceneComponent, action: T): void;
  11905. /**
  11906. * Clears all the steps from the stage.
  11907. */
  11908. clear(): void;
  11909. }
  11910. }
  11911. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11912. import { Nullable } from "babylonjs/types";
  11913. import { Observable } from "babylonjs/Misc/observable";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Sprite } from "babylonjs/Sprites/sprite";
  11916. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11917. import { Ray } from "babylonjs/Culling/ray";
  11918. import { Camera } from "babylonjs/Cameras/camera";
  11919. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11920. import { ISceneComponent } from "babylonjs/sceneComponent";
  11921. module "babylonjs/scene" {
  11922. interface Scene {
  11923. /** @hidden */
  11924. _pointerOverSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _pickedDownSprite: Nullable<Sprite>;
  11927. /** @hidden */
  11928. _tempSpritePickingRay: Nullable<Ray>;
  11929. /**
  11930. * All of the sprite managers added to this scene
  11931. * @see http://doc.babylonjs.com/babylon101/sprites
  11932. */
  11933. spriteManagers: Array<ISpriteManager>;
  11934. /**
  11935. * An event triggered when sprites rendering is about to start
  11936. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11937. */
  11938. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11939. /**
  11940. * An event triggered when sprites rendering is done
  11941. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11942. */
  11943. onAfterSpritesRenderingObservable: Observable<Scene>;
  11944. /** @hidden */
  11945. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11946. /** Launch a ray to try to pick a sprite in the scene
  11947. * @param x position on screen
  11948. * @param y position on screen
  11949. * @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
  11950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11951. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11952. * @returns a PickingInfo
  11953. */
  11954. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11955. /** Use the given ray to pick a sprite in the scene
  11956. * @param ray The ray (in world space) to use to pick meshes
  11957. * @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
  11958. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11959. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11960. * @returns a PickingInfo
  11961. */
  11962. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11963. /**
  11964. * Force the sprite under the pointer
  11965. * @param sprite defines the sprite to use
  11966. */
  11967. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11968. /**
  11969. * Gets the sprite under the pointer
  11970. * @returns a Sprite or null if no sprite is under the pointer
  11971. */
  11972. getPointerOverSprite(): Nullable<Sprite>;
  11973. }
  11974. }
  11975. /**
  11976. * Defines the sprite scene component responsible to manage sprites
  11977. * in a given scene.
  11978. */
  11979. export class SpriteSceneComponent implements ISceneComponent {
  11980. /**
  11981. * The component name helpfull to identify the component in the list of scene components.
  11982. */
  11983. readonly name: string;
  11984. /**
  11985. * The scene the component belongs to.
  11986. */
  11987. scene: Scene;
  11988. /** @hidden */
  11989. private _spritePredicate;
  11990. /**
  11991. * Creates a new instance of the component for the given scene
  11992. * @param scene Defines the scene to register the component in
  11993. */
  11994. constructor(scene: Scene);
  11995. /**
  11996. * Registers the component in a given scene
  11997. */
  11998. register(): void;
  11999. /**
  12000. * Rebuilds the elements related to this component in case of
  12001. * context lost for instance.
  12002. */
  12003. rebuild(): void;
  12004. /**
  12005. * Disposes the component and the associated ressources.
  12006. */
  12007. dispose(): void;
  12008. private _pickSpriteButKeepRay;
  12009. private _pointerMove;
  12010. private _pointerDown;
  12011. private _pointerUp;
  12012. }
  12013. }
  12014. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12015. /** @hidden */
  12016. export var fogFragmentDeclaration: {
  12017. name: string;
  12018. shader: string;
  12019. };
  12020. }
  12021. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12022. /** @hidden */
  12023. export var fogFragment: {
  12024. name: string;
  12025. shader: string;
  12026. };
  12027. }
  12028. declare module "babylonjs/Shaders/sprites.fragment" {
  12029. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12030. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12031. /** @hidden */
  12032. export var spritesPixelShader: {
  12033. name: string;
  12034. shader: string;
  12035. };
  12036. }
  12037. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12038. /** @hidden */
  12039. export var fogVertexDeclaration: {
  12040. name: string;
  12041. shader: string;
  12042. };
  12043. }
  12044. declare module "babylonjs/Shaders/sprites.vertex" {
  12045. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12046. /** @hidden */
  12047. export var spritesVertexShader: {
  12048. name: string;
  12049. shader: string;
  12050. };
  12051. }
  12052. declare module "babylonjs/Sprites/spriteManager" {
  12053. import { IDisposable, Scene } from "babylonjs/scene";
  12054. import { Nullable } from "babylonjs/types";
  12055. import { Observable } from "babylonjs/Misc/observable";
  12056. import { Sprite } from "babylonjs/Sprites/sprite";
  12057. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12058. import { Camera } from "babylonjs/Cameras/camera";
  12059. import { Texture } from "babylonjs/Materials/Textures/texture";
  12060. import "babylonjs/Shaders/sprites.fragment";
  12061. import "babylonjs/Shaders/sprites.vertex";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12065. */
  12066. export interface ISpriteManager extends IDisposable {
  12067. /**
  12068. * Restricts the camera to viewing objects with the same layerMask.
  12069. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12070. */
  12071. layerMask: number;
  12072. /**
  12073. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12074. */
  12075. isPickable: boolean;
  12076. /**
  12077. * Specifies the rendering group id for this mesh (0 by default)
  12078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12079. */
  12080. renderingGroupId: number;
  12081. /**
  12082. * Defines the list of sprites managed by the manager.
  12083. */
  12084. sprites: Array<Sprite>;
  12085. /**
  12086. * Tests the intersection of a sprite with a specific ray.
  12087. * @param ray The ray we are sending to test the collision
  12088. * @param camera The camera space we are sending rays in
  12089. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12090. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12091. * @returns picking info or null.
  12092. */
  12093. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12094. /**
  12095. * Renders the list of sprites on screen.
  12096. */
  12097. render(): void;
  12098. }
  12099. /**
  12100. * Class used to manage multiple sprites on the same spritesheet
  12101. * @see http://doc.babylonjs.com/babylon101/sprites
  12102. */
  12103. export class SpriteManager implements ISpriteManager {
  12104. /** defines the manager's name */
  12105. name: string;
  12106. /** Gets the list of sprites */
  12107. sprites: Sprite[];
  12108. /** Gets or sets the rendering group id (0 by default) */
  12109. renderingGroupId: number;
  12110. /** Gets or sets camera layer mask */
  12111. layerMask: number;
  12112. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12113. fogEnabled: boolean;
  12114. /** Gets or sets a boolean indicating if the sprites are pickable */
  12115. isPickable: boolean;
  12116. /** Defines the default width of a cell in the spritesheet */
  12117. cellWidth: number;
  12118. /** Defines the default height of a cell in the spritesheet */
  12119. cellHeight: number;
  12120. /**
  12121. * An event triggered when the manager is disposed.
  12122. */
  12123. onDisposeObservable: Observable<SpriteManager>;
  12124. private _onDisposeObserver;
  12125. /**
  12126. * Callback called when the manager is disposed
  12127. */
  12128. onDispose: () => void;
  12129. private _capacity;
  12130. private _spriteTexture;
  12131. private _epsilon;
  12132. private _scene;
  12133. private _vertexData;
  12134. private _buffer;
  12135. private _vertexBuffers;
  12136. private _indexBuffer;
  12137. private _effectBase;
  12138. private _effectFog;
  12139. /**
  12140. * Gets or sets the spritesheet texture
  12141. */
  12142. texture: Texture;
  12143. /**
  12144. * Creates a new sprite manager
  12145. * @param name defines the manager's name
  12146. * @param imgUrl defines the sprite sheet url
  12147. * @param capacity defines the maximum allowed number of sprites
  12148. * @param cellSize defines the size of a sprite cell
  12149. * @param scene defines the hosting scene
  12150. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12151. * @param samplingMode defines the smapling mode to use with spritesheet
  12152. */
  12153. constructor(
  12154. /** defines the manager's name */
  12155. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12156. private _appendSpriteVertex;
  12157. /**
  12158. * Intersects the sprites with a ray
  12159. * @param ray defines the ray to intersect with
  12160. * @param camera defines the current active camera
  12161. * @param predicate defines a predicate used to select candidate sprites
  12162. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12163. * @returns null if no hit or a PickingInfo
  12164. */
  12165. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12166. /**
  12167. * Render all child sprites
  12168. */
  12169. render(): void;
  12170. /**
  12171. * Release associated resources
  12172. */
  12173. dispose(): void;
  12174. }
  12175. }
  12176. declare module "babylonjs/Sprites/sprite" {
  12177. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12178. import { Nullable } from "babylonjs/types";
  12179. import { ActionManager } from "babylonjs/Actions/actionManager";
  12180. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12181. /**
  12182. * Class used to represent a sprite
  12183. * @see http://doc.babylonjs.com/babylon101/sprites
  12184. */
  12185. export class Sprite {
  12186. /** defines the name */
  12187. name: string;
  12188. /** Gets or sets the current world position */
  12189. position: Vector3;
  12190. /** Gets or sets the main color */
  12191. color: Color4;
  12192. /** Gets or sets the width */
  12193. width: number;
  12194. /** Gets or sets the height */
  12195. height: number;
  12196. /** Gets or sets rotation angle */
  12197. angle: number;
  12198. /** Gets or sets the cell index in the sprite sheet */
  12199. cellIndex: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12201. invertU: number;
  12202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12203. invertV: number;
  12204. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12205. disposeWhenFinishedAnimating: boolean;
  12206. /** Gets the list of attached animations */
  12207. animations: Animation[];
  12208. /** Gets or sets a boolean indicating if the sprite can be picked */
  12209. isPickable: boolean;
  12210. /**
  12211. * Gets or sets the associated action manager
  12212. */
  12213. actionManager: Nullable<ActionManager>;
  12214. private _animationStarted;
  12215. private _loopAnimation;
  12216. private _fromIndex;
  12217. private _toIndex;
  12218. private _delay;
  12219. private _direction;
  12220. private _manager;
  12221. private _time;
  12222. private _onAnimationEnd;
  12223. /**
  12224. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12225. */
  12226. isVisible: boolean;
  12227. /**
  12228. * Gets or sets the sprite size
  12229. */
  12230. size: number;
  12231. /**
  12232. * Creates a new Sprite
  12233. * @param name defines the name
  12234. * @param manager defines the manager
  12235. */
  12236. constructor(
  12237. /** defines the name */
  12238. name: string, manager: ISpriteManager);
  12239. /**
  12240. * Starts an animation
  12241. * @param from defines the initial key
  12242. * @param to defines the end key
  12243. * @param loop defines if the animation must loop
  12244. * @param delay defines the start delay (in ms)
  12245. * @param onAnimationEnd defines a callback to call when animation ends
  12246. */
  12247. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12248. /** Stops current animation (if any) */
  12249. stopAnimation(): void;
  12250. /** @hidden */
  12251. _animate(deltaTime: number): void;
  12252. /** Release associated resources */
  12253. dispose(): void;
  12254. }
  12255. }
  12256. declare module "babylonjs/Collisions/pickingInfo" {
  12257. import { Nullable } from "babylonjs/types";
  12258. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12260. import { Sprite } from "babylonjs/Sprites/sprite";
  12261. import { Ray } from "babylonjs/Culling/ray";
  12262. /**
  12263. * Information about the result of picking within a scene
  12264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12265. */
  12266. export class PickingInfo {
  12267. /** @hidden */
  12268. _pickingUnavailable: boolean;
  12269. /**
  12270. * If the pick collided with an object
  12271. */
  12272. hit: boolean;
  12273. /**
  12274. * Distance away where the pick collided
  12275. */
  12276. distance: number;
  12277. /**
  12278. * The location of pick collision
  12279. */
  12280. pickedPoint: Nullable<Vector3>;
  12281. /**
  12282. * The mesh corresponding the the pick collision
  12283. */
  12284. pickedMesh: Nullable<AbstractMesh>;
  12285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bu: number;
  12287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12288. bv: number;
  12289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12290. faceId: number;
  12291. /** Id of the the submesh that was picked */
  12292. subMeshId: number;
  12293. /** If a sprite was picked, this will be the sprite the pick collided with */
  12294. pickedSprite: Nullable<Sprite>;
  12295. /**
  12296. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12297. */
  12298. originMesh: Nullable<AbstractMesh>;
  12299. /**
  12300. * The ray that was used to perform the picking.
  12301. */
  12302. ray: Nullable<Ray>;
  12303. /**
  12304. * Gets the normal correspodning to the face the pick collided with
  12305. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12306. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12307. * @returns The normal correspodning to the face the pick collided with
  12308. */
  12309. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12310. /**
  12311. * Gets the texture coordinates of where the pick occured
  12312. * @returns the vector containing the coordnates of the texture
  12313. */
  12314. getTextureCoordinates(): Nullable<Vector2>;
  12315. }
  12316. }
  12317. declare module "babylonjs/Events/pointerEvents" {
  12318. import { Nullable } from "babylonjs/types";
  12319. import { Vector2 } from "babylonjs/Maths/math";
  12320. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12321. import { Ray } from "babylonjs/Culling/ray";
  12322. /**
  12323. * Gather the list of pointer event types as constants.
  12324. */
  12325. export class PointerEventTypes {
  12326. /**
  12327. * 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.
  12328. */
  12329. static readonly POINTERDOWN: number;
  12330. /**
  12331. * The pointerup event is fired when a pointer is no longer active.
  12332. */
  12333. static readonly POINTERUP: number;
  12334. /**
  12335. * The pointermove event is fired when a pointer changes coordinates.
  12336. */
  12337. static readonly POINTERMOVE: number;
  12338. /**
  12339. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12340. */
  12341. static readonly POINTERWHEEL: number;
  12342. /**
  12343. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12344. */
  12345. static readonly POINTERPICK: number;
  12346. /**
  12347. * The pointertap event is fired when a the object has been touched and released without drag.
  12348. */
  12349. static readonly POINTERTAP: number;
  12350. /**
  12351. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12352. */
  12353. static readonly POINTERDOUBLETAP: number;
  12354. }
  12355. /**
  12356. * Base class of pointer info types.
  12357. */
  12358. export class PointerInfoBase {
  12359. /**
  12360. * Defines the type of event (PointerEventTypes)
  12361. */
  12362. type: number;
  12363. /**
  12364. * Defines the related dom event
  12365. */
  12366. event: PointerEvent | MouseWheelEvent;
  12367. /**
  12368. * Instantiates the base class of pointers info.
  12369. * @param type Defines the type of event (PointerEventTypes)
  12370. * @param event Defines the related dom event
  12371. */
  12372. constructor(
  12373. /**
  12374. * Defines the type of event (PointerEventTypes)
  12375. */
  12376. type: number,
  12377. /**
  12378. * Defines the related dom event
  12379. */
  12380. event: PointerEvent | MouseWheelEvent);
  12381. }
  12382. /**
  12383. * This class is used to store pointer related info for the onPrePointerObservable event.
  12384. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12385. */
  12386. export class PointerInfoPre extends PointerInfoBase {
  12387. /**
  12388. * Ray from a pointer if availible (eg. 6dof controller)
  12389. */
  12390. ray: Nullable<Ray>;
  12391. /**
  12392. * Defines the local position of the pointer on the canvas.
  12393. */
  12394. localPosition: Vector2;
  12395. /**
  12396. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12397. */
  12398. skipOnPointerObservable: boolean;
  12399. /**
  12400. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12401. * @param type Defines the type of event (PointerEventTypes)
  12402. * @param event Defines the related dom event
  12403. * @param localX Defines the local x coordinates of the pointer when the event occured
  12404. * @param localY Defines the local y coordinates of the pointer when the event occured
  12405. */
  12406. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12407. }
  12408. /**
  12409. * This type contains all the data related to a pointer event in Babylon.js.
  12410. * 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.
  12411. */
  12412. export class PointerInfo extends PointerInfoBase {
  12413. /**
  12414. * Defines the picking info associated to the info (if any)\
  12415. */
  12416. pickInfo: Nullable<PickingInfo>;
  12417. /**
  12418. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12419. * @param type Defines the type of event (PointerEventTypes)
  12420. * @param event Defines the related dom event
  12421. * @param pickInfo Defines the picking info associated to the info (if any)\
  12422. */
  12423. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12424. /**
  12425. * Defines the picking info associated to the info (if any)\
  12426. */
  12427. pickInfo: Nullable<PickingInfo>);
  12428. }
  12429. /**
  12430. * Data relating to a touch event on the screen.
  12431. */
  12432. export interface PointerTouch {
  12433. /**
  12434. * X coordinate of touch.
  12435. */
  12436. x: number;
  12437. /**
  12438. * Y coordinate of touch.
  12439. */
  12440. y: number;
  12441. /**
  12442. * Id of touch. Unique for each finger.
  12443. */
  12444. pointerId: number;
  12445. /**
  12446. * Event type passed from DOM.
  12447. */
  12448. type: any;
  12449. }
  12450. }
  12451. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12452. import { Observable } from "babylonjs/Misc/observable";
  12453. import { Nullable } from "babylonjs/types";
  12454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12456. /**
  12457. * Manage the mouse inputs to control the movement of a free camera.
  12458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12459. */
  12460. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12461. /**
  12462. * Define if touch is enabled in the mouse input
  12463. */
  12464. touchEnabled: boolean;
  12465. /**
  12466. * Defines the camera the input is attached to.
  12467. */
  12468. camera: FreeCamera;
  12469. /**
  12470. * Defines the buttons associated with the input to handle camera move.
  12471. */
  12472. buttons: number[];
  12473. /**
  12474. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12475. */
  12476. angularSensibility: number;
  12477. private _pointerInput;
  12478. private _onMouseMove;
  12479. private _observer;
  12480. private previousPosition;
  12481. /**
  12482. * Observable for when a pointer move event occurs containing the move offset
  12483. */
  12484. onPointerMovedObservable: Observable<{
  12485. offsetX: number;
  12486. offsetY: number;
  12487. }>;
  12488. /**
  12489. * @hidden
  12490. * If the camera should be rotated automatically based on pointer movement
  12491. */
  12492. _allowCameraRotation: boolean;
  12493. /**
  12494. * Manage the mouse inputs to control the movement of a free camera.
  12495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12496. * @param touchEnabled Defines if touch is enabled or not
  12497. */
  12498. constructor(
  12499. /**
  12500. * Define if touch is enabled in the mouse input
  12501. */
  12502. touchEnabled?: boolean);
  12503. /**
  12504. * Attach the input controls to a specific dom element to get the input from.
  12505. * @param element Defines the element the controls should be listened from
  12506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12507. */
  12508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12509. /**
  12510. * Called on JS contextmenu event.
  12511. * Override this method to provide functionality.
  12512. */
  12513. protected onContextMenu(evt: PointerEvent): void;
  12514. /**
  12515. * Detach the current controls from the specified dom element.
  12516. * @param element Defines the element to stop listening the inputs from
  12517. */
  12518. detachControl(element: Nullable<HTMLElement>): void;
  12519. /**
  12520. * Gets the class name of the current intput.
  12521. * @returns the class name
  12522. */
  12523. getClassName(): string;
  12524. /**
  12525. * Get the friendly name associated with the input class.
  12526. * @returns the input friendly name
  12527. */
  12528. getSimpleName(): string;
  12529. }
  12530. }
  12531. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12532. import { Nullable } from "babylonjs/types";
  12533. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12534. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12535. /**
  12536. * Manage the touch inputs to control the movement of a free camera.
  12537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12538. */
  12539. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12540. /**
  12541. * Defines the camera the input is attached to.
  12542. */
  12543. camera: FreeCamera;
  12544. /**
  12545. * Defines the touch sensibility for rotation.
  12546. * The higher the faster.
  12547. */
  12548. touchAngularSensibility: number;
  12549. /**
  12550. * Defines the touch sensibility for move.
  12551. * The higher the faster.
  12552. */
  12553. touchMoveSensibility: number;
  12554. private _offsetX;
  12555. private _offsetY;
  12556. private _pointerPressed;
  12557. private _pointerInput;
  12558. private _observer;
  12559. private _onLostFocus;
  12560. /**
  12561. * Attach the input controls to a specific dom element to get the input from.
  12562. * @param element Defines the element the controls should be listened from
  12563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12564. */
  12565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12566. /**
  12567. * Detach the current controls from the specified dom element.
  12568. * @param element Defines the element to stop listening the inputs from
  12569. */
  12570. detachControl(element: Nullable<HTMLElement>): void;
  12571. /**
  12572. * Update the current camera state depending on the inputs that have been used this frame.
  12573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12574. */
  12575. checkInputs(): void;
  12576. /**
  12577. * Gets the class name of the current intput.
  12578. * @returns the class name
  12579. */
  12580. getClassName(): string;
  12581. /**
  12582. * Get the friendly name associated with the input class.
  12583. * @returns the input friendly name
  12584. */
  12585. getSimpleName(): string;
  12586. }
  12587. }
  12588. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12589. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12590. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12591. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12592. import { Nullable } from "babylonjs/types";
  12593. /**
  12594. * Default Inputs manager for the FreeCamera.
  12595. * It groups all the default supported inputs for ease of use.
  12596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12597. */
  12598. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12599. /**
  12600. * @hidden
  12601. */
  12602. _mouseInput: Nullable<FreeCameraMouseInput>;
  12603. /**
  12604. * Instantiates a new FreeCameraInputsManager.
  12605. * @param camera Defines the camera the inputs belong to
  12606. */
  12607. constructor(camera: FreeCamera);
  12608. /**
  12609. * Add keyboard input support to the input manager.
  12610. * @returns the current input manager
  12611. */
  12612. addKeyboard(): FreeCameraInputsManager;
  12613. /**
  12614. * Add mouse input support to the input manager.
  12615. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12616. * @returns the current input manager
  12617. */
  12618. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12619. /**
  12620. * Removes the mouse input support from the manager
  12621. * @returns the current input manager
  12622. */
  12623. removeMouse(): FreeCameraInputsManager;
  12624. /**
  12625. * Add touch input support to the input manager.
  12626. * @returns the current input manager
  12627. */
  12628. addTouch(): FreeCameraInputsManager;
  12629. /**
  12630. * Remove all attached input methods from a camera
  12631. */
  12632. clear(): void;
  12633. }
  12634. }
  12635. declare module "babylonjs/Cameras/freeCamera" {
  12636. import { Vector3 } from "babylonjs/Maths/math";
  12637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12638. import { Scene } from "babylonjs/scene";
  12639. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12640. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12641. /**
  12642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12643. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12645. */
  12646. export class FreeCamera extends TargetCamera {
  12647. /**
  12648. * Define the collision ellipsoid of the camera.
  12649. * This is helpful to simulate a camera body like the player body around the camera
  12650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12651. */
  12652. ellipsoid: Vector3;
  12653. /**
  12654. * Define an offset for the position of the ellipsoid around the camera.
  12655. * This can be helpful to determine the center of the body near the gravity center of the body
  12656. * instead of its head.
  12657. */
  12658. ellipsoidOffset: Vector3;
  12659. /**
  12660. * Enable or disable collisions of the camera with the rest of the scene objects.
  12661. */
  12662. checkCollisions: boolean;
  12663. /**
  12664. * Enable or disable gravity on the camera.
  12665. */
  12666. applyGravity: boolean;
  12667. /**
  12668. * Define the input manager associated to the camera.
  12669. */
  12670. inputs: FreeCameraInputsManager;
  12671. /**
  12672. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12673. * Higher values reduce sensitivity.
  12674. */
  12675. /**
  12676. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12677. * Higher values reduce sensitivity.
  12678. */
  12679. angularSensibility: number;
  12680. /**
  12681. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12682. */
  12683. keysUp: number[];
  12684. /**
  12685. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12686. */
  12687. keysDown: number[];
  12688. /**
  12689. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12690. */
  12691. keysLeft: number[];
  12692. /**
  12693. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12694. */
  12695. keysRight: number[];
  12696. /**
  12697. * Event raised when the camera collide with a mesh in the scene.
  12698. */
  12699. onCollide: (collidedMesh: AbstractMesh) => void;
  12700. private _collider;
  12701. private _needMoveForGravity;
  12702. private _oldPosition;
  12703. private _diffPosition;
  12704. private _newPosition;
  12705. /** @hidden */
  12706. _localDirection: Vector3;
  12707. /** @hidden */
  12708. _transformedDirection: Vector3;
  12709. /**
  12710. * Instantiates a Free Camera.
  12711. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12712. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12713. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12714. * @param name Define the name of the camera in the scene
  12715. * @param position Define the start position of the camera in the scene
  12716. * @param scene Define the scene the camera belongs to
  12717. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12718. */
  12719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12720. /**
  12721. * Attached controls to the current camera.
  12722. * @param element Defines the element the controls should be listened from
  12723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12724. */
  12725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12726. /**
  12727. * Detach the current controls from the camera.
  12728. * The camera will stop reacting to inputs.
  12729. * @param element Defines the element to stop listening the inputs from
  12730. */
  12731. detachControl(element: HTMLElement): void;
  12732. private _collisionMask;
  12733. /**
  12734. * Define a collision mask to limit the list of object the camera can collide with
  12735. */
  12736. collisionMask: number;
  12737. /** @hidden */
  12738. _collideWithWorld(displacement: Vector3): void;
  12739. private _onCollisionPositionChange;
  12740. /** @hidden */
  12741. _checkInputs(): void;
  12742. /** @hidden */
  12743. _decideIfNeedsToMove(): boolean;
  12744. /** @hidden */
  12745. _updatePosition(): void;
  12746. /**
  12747. * Destroy the camera and release the current resources hold by it.
  12748. */
  12749. dispose(): void;
  12750. /**
  12751. * Gets the current object class name.
  12752. * @return the class name
  12753. */
  12754. getClassName(): string;
  12755. }
  12756. }
  12757. declare module "babylonjs/Gamepads/gamepad" {
  12758. import { Observable } from "babylonjs/Misc/observable";
  12759. /**
  12760. * Represents a gamepad control stick position
  12761. */
  12762. export class StickValues {
  12763. /**
  12764. * The x component of the control stick
  12765. */
  12766. x: number;
  12767. /**
  12768. * The y component of the control stick
  12769. */
  12770. y: number;
  12771. /**
  12772. * Initializes the gamepad x and y control stick values
  12773. * @param x The x component of the gamepad control stick value
  12774. * @param y The y component of the gamepad control stick value
  12775. */
  12776. constructor(
  12777. /**
  12778. * The x component of the control stick
  12779. */
  12780. x: number,
  12781. /**
  12782. * The y component of the control stick
  12783. */
  12784. y: number);
  12785. }
  12786. /**
  12787. * An interface which manages callbacks for gamepad button changes
  12788. */
  12789. export interface GamepadButtonChanges {
  12790. /**
  12791. * Called when a gamepad has been changed
  12792. */
  12793. changed: boolean;
  12794. /**
  12795. * Called when a gamepad press event has been triggered
  12796. */
  12797. pressChanged: boolean;
  12798. /**
  12799. * Called when a touch event has been triggered
  12800. */
  12801. touchChanged: boolean;
  12802. /**
  12803. * Called when a value has changed
  12804. */
  12805. valueChanged: boolean;
  12806. }
  12807. /**
  12808. * Represents a gamepad
  12809. */
  12810. export class Gamepad {
  12811. /**
  12812. * The id of the gamepad
  12813. */
  12814. id: string;
  12815. /**
  12816. * The index of the gamepad
  12817. */
  12818. index: number;
  12819. /**
  12820. * The browser gamepad
  12821. */
  12822. browserGamepad: any;
  12823. /**
  12824. * Specifies what type of gamepad this represents
  12825. */
  12826. type: number;
  12827. private _leftStick;
  12828. private _rightStick;
  12829. /** @hidden */
  12830. _isConnected: boolean;
  12831. private _leftStickAxisX;
  12832. private _leftStickAxisY;
  12833. private _rightStickAxisX;
  12834. private _rightStickAxisY;
  12835. /**
  12836. * Triggered when the left control stick has been changed
  12837. */
  12838. private _onleftstickchanged;
  12839. /**
  12840. * Triggered when the right control stick has been changed
  12841. */
  12842. private _onrightstickchanged;
  12843. /**
  12844. * Represents a gamepad controller
  12845. */
  12846. static GAMEPAD: number;
  12847. /**
  12848. * Represents a generic controller
  12849. */
  12850. static GENERIC: number;
  12851. /**
  12852. * Represents an XBox controller
  12853. */
  12854. static XBOX: number;
  12855. /**
  12856. * Represents a pose-enabled controller
  12857. */
  12858. static POSE_ENABLED: number;
  12859. /**
  12860. * Specifies whether the left control stick should be Y-inverted
  12861. */
  12862. protected _invertLeftStickY: boolean;
  12863. /**
  12864. * Specifies if the gamepad has been connected
  12865. */
  12866. readonly isConnected: boolean;
  12867. /**
  12868. * Initializes the gamepad
  12869. * @param id The id of the gamepad
  12870. * @param index The index of the gamepad
  12871. * @param browserGamepad The browser gamepad
  12872. * @param leftStickX The x component of the left joystick
  12873. * @param leftStickY The y component of the left joystick
  12874. * @param rightStickX The x component of the right joystick
  12875. * @param rightStickY The y component of the right joystick
  12876. */
  12877. constructor(
  12878. /**
  12879. * The id of the gamepad
  12880. */
  12881. id: string,
  12882. /**
  12883. * The index of the gamepad
  12884. */
  12885. index: number,
  12886. /**
  12887. * The browser gamepad
  12888. */
  12889. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12890. /**
  12891. * Callback triggered when the left joystick has changed
  12892. * @param callback
  12893. */
  12894. onleftstickchanged(callback: (values: StickValues) => void): void;
  12895. /**
  12896. * Callback triggered when the right joystick has changed
  12897. * @param callback
  12898. */
  12899. onrightstickchanged(callback: (values: StickValues) => void): void;
  12900. /**
  12901. * Gets the left joystick
  12902. */
  12903. /**
  12904. * Sets the left joystick values
  12905. */
  12906. leftStick: StickValues;
  12907. /**
  12908. * Gets the right joystick
  12909. */
  12910. /**
  12911. * Sets the right joystick value
  12912. */
  12913. rightStick: StickValues;
  12914. /**
  12915. * Updates the gamepad joystick positions
  12916. */
  12917. update(): void;
  12918. /**
  12919. * Disposes the gamepad
  12920. */
  12921. dispose(): void;
  12922. }
  12923. /**
  12924. * Represents a generic gamepad
  12925. */
  12926. export class GenericPad extends Gamepad {
  12927. private _buttons;
  12928. private _onbuttondown;
  12929. private _onbuttonup;
  12930. /**
  12931. * Observable triggered when a button has been pressed
  12932. */
  12933. onButtonDownObservable: Observable<number>;
  12934. /**
  12935. * Observable triggered when a button has been released
  12936. */
  12937. onButtonUpObservable: Observable<number>;
  12938. /**
  12939. * Callback triggered when a button has been pressed
  12940. * @param callback Called when a button has been pressed
  12941. */
  12942. onbuttondown(callback: (buttonPressed: number) => void): void;
  12943. /**
  12944. * Callback triggered when a button has been released
  12945. * @param callback Called when a button has been released
  12946. */
  12947. onbuttonup(callback: (buttonReleased: number) => void): void;
  12948. /**
  12949. * Initializes the generic gamepad
  12950. * @param id The id of the generic gamepad
  12951. * @param index The index of the generic gamepad
  12952. * @param browserGamepad The browser gamepad
  12953. */
  12954. constructor(id: string, index: number, browserGamepad: any);
  12955. private _setButtonValue;
  12956. /**
  12957. * Updates the generic gamepad
  12958. */
  12959. update(): void;
  12960. /**
  12961. * Disposes the generic gamepad
  12962. */
  12963. dispose(): void;
  12964. }
  12965. }
  12966. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Nullable } from "babylonjs/types";
  12969. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12972. import { Ray } from "babylonjs/Culling/ray";
  12973. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12974. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12975. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12976. /**
  12977. * Defines the types of pose enabled controllers that are supported
  12978. */
  12979. export enum PoseEnabledControllerType {
  12980. /**
  12981. * HTC Vive
  12982. */
  12983. VIVE = 0,
  12984. /**
  12985. * Oculus Rift
  12986. */
  12987. OCULUS = 1,
  12988. /**
  12989. * Windows mixed reality
  12990. */
  12991. WINDOWS = 2,
  12992. /**
  12993. * Samsung gear VR
  12994. */
  12995. GEAR_VR = 3,
  12996. /**
  12997. * Google Daydream
  12998. */
  12999. DAYDREAM = 4,
  13000. /**
  13001. * Generic
  13002. */
  13003. GENERIC = 5
  13004. }
  13005. /**
  13006. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13007. */
  13008. export interface MutableGamepadButton {
  13009. /**
  13010. * Value of the button/trigger
  13011. */
  13012. value: number;
  13013. /**
  13014. * If the button/trigger is currently touched
  13015. */
  13016. touched: boolean;
  13017. /**
  13018. * If the button/trigger is currently pressed
  13019. */
  13020. pressed: boolean;
  13021. }
  13022. /**
  13023. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13024. * @hidden
  13025. */
  13026. export interface ExtendedGamepadButton extends GamepadButton {
  13027. /**
  13028. * If the button/trigger is currently pressed
  13029. */
  13030. readonly pressed: boolean;
  13031. /**
  13032. * If the button/trigger is currently touched
  13033. */
  13034. readonly touched: boolean;
  13035. /**
  13036. * Value of the button/trigger
  13037. */
  13038. readonly value: number;
  13039. }
  13040. /** @hidden */
  13041. export interface _GamePadFactory {
  13042. /**
  13043. * Returns wether or not the current gamepad can be created for this type of controller.
  13044. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13045. * @returns true if it can be created, otherwise false
  13046. */
  13047. canCreate(gamepadInfo: any): boolean;
  13048. /**
  13049. * Creates a new instance of the Gamepad.
  13050. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13051. * @returns the new gamepad instance
  13052. */
  13053. create(gamepadInfo: any): Gamepad;
  13054. }
  13055. /**
  13056. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13057. */
  13058. export class PoseEnabledControllerHelper {
  13059. /** @hidden */
  13060. static _ControllerFactories: _GamePadFactory[];
  13061. /** @hidden */
  13062. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13063. /**
  13064. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13065. * @param vrGamepad the gamepad to initialized
  13066. * @returns a vr controller of the type the gamepad identified as
  13067. */
  13068. static InitiateController(vrGamepad: any): Gamepad;
  13069. }
  13070. /**
  13071. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13072. */
  13073. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13074. private _deviceRoomPosition;
  13075. private _deviceRoomRotationQuaternion;
  13076. /**
  13077. * The device position in babylon space
  13078. */
  13079. devicePosition: Vector3;
  13080. /**
  13081. * The device rotation in babylon space
  13082. */
  13083. deviceRotationQuaternion: Quaternion;
  13084. /**
  13085. * The scale factor of the device in babylon space
  13086. */
  13087. deviceScaleFactor: number;
  13088. /**
  13089. * (Likely devicePosition should be used instead) The device position in its room space
  13090. */
  13091. position: Vector3;
  13092. /**
  13093. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13094. */
  13095. rotationQuaternion: Quaternion;
  13096. /**
  13097. * The type of controller (Eg. Windows mixed reality)
  13098. */
  13099. controllerType: PoseEnabledControllerType;
  13100. protected _calculatedPosition: Vector3;
  13101. private _calculatedRotation;
  13102. /**
  13103. * The raw pose from the device
  13104. */
  13105. rawPose: DevicePose;
  13106. private _trackPosition;
  13107. private _maxRotationDistFromHeadset;
  13108. private _draggedRoomRotation;
  13109. /**
  13110. * @hidden
  13111. */
  13112. _disableTrackPosition(fixedPosition: Vector3): void;
  13113. /**
  13114. * Internal, the mesh attached to the controller
  13115. * @hidden
  13116. */
  13117. _mesh: Nullable<AbstractMesh>;
  13118. private _poseControlledCamera;
  13119. private _leftHandSystemQuaternion;
  13120. /**
  13121. * Internal, matrix used to convert room space to babylon space
  13122. * @hidden
  13123. */
  13124. _deviceToWorld: Matrix;
  13125. /**
  13126. * Node to be used when casting a ray from the controller
  13127. * @hidden
  13128. */
  13129. _pointingPoseNode: Nullable<TransformNode>;
  13130. /**
  13131. * Name of the child mesh that can be used to cast a ray from the controller
  13132. */
  13133. static readonly POINTING_POSE: string;
  13134. /**
  13135. * Creates a new PoseEnabledController from a gamepad
  13136. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13137. */
  13138. constructor(browserGamepad: any);
  13139. private _workingMatrix;
  13140. /**
  13141. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13142. */
  13143. update(): void;
  13144. /**
  13145. * Updates only the pose device and mesh without doing any button event checking
  13146. */
  13147. protected _updatePoseAndMesh(): void;
  13148. /**
  13149. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13150. * @param poseData raw pose fromthe device
  13151. */
  13152. updateFromDevice(poseData: DevicePose): void;
  13153. /**
  13154. * @hidden
  13155. */
  13156. _meshAttachedObservable: Observable<AbstractMesh>;
  13157. /**
  13158. * Attaches a mesh to the controller
  13159. * @param mesh the mesh to be attached
  13160. */
  13161. attachToMesh(mesh: AbstractMesh): void;
  13162. /**
  13163. * Attaches the controllers mesh to a camera
  13164. * @param camera the camera the mesh should be attached to
  13165. */
  13166. attachToPoseControlledCamera(camera: TargetCamera): void;
  13167. /**
  13168. * Disposes of the controller
  13169. */
  13170. dispose(): void;
  13171. /**
  13172. * The mesh that is attached to the controller
  13173. */
  13174. readonly mesh: Nullable<AbstractMesh>;
  13175. /**
  13176. * Gets the ray of the controller in the direction the controller is pointing
  13177. * @param length the length the resulting ray should be
  13178. * @returns a ray in the direction the controller is pointing
  13179. */
  13180. getForwardRay(length?: number): Ray;
  13181. }
  13182. }
  13183. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13184. import { Observable } from "babylonjs/Misc/observable";
  13185. import { Scene } from "babylonjs/scene";
  13186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13187. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13188. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13189. /**
  13190. * Defines the WebVRController object that represents controllers tracked in 3D space
  13191. */
  13192. export abstract class WebVRController extends PoseEnabledController {
  13193. /**
  13194. * Internal, the default controller model for the controller
  13195. */
  13196. protected _defaultModel: AbstractMesh;
  13197. /**
  13198. * Fired when the trigger state has changed
  13199. */
  13200. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13201. /**
  13202. * Fired when the main button state has changed
  13203. */
  13204. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13205. /**
  13206. * Fired when the secondary button state has changed
  13207. */
  13208. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13209. /**
  13210. * Fired when the pad state has changed
  13211. */
  13212. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13213. /**
  13214. * Fired when controllers stick values have changed
  13215. */
  13216. onPadValuesChangedObservable: Observable<StickValues>;
  13217. /**
  13218. * Array of button availible on the controller
  13219. */
  13220. protected _buttons: Array<MutableGamepadButton>;
  13221. private _onButtonStateChange;
  13222. /**
  13223. * Fired when a controller button's state has changed
  13224. * @param callback the callback containing the button that was modified
  13225. */
  13226. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13227. /**
  13228. * X and Y axis corrisponding to the controllers joystick
  13229. */
  13230. pad: StickValues;
  13231. /**
  13232. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13233. */
  13234. hand: string;
  13235. /**
  13236. * The default controller model for the controller
  13237. */
  13238. readonly defaultModel: AbstractMesh;
  13239. /**
  13240. * Creates a new WebVRController from a gamepad
  13241. * @param vrGamepad the gamepad that the WebVRController should be created from
  13242. */
  13243. constructor(vrGamepad: any);
  13244. /**
  13245. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13246. */
  13247. update(): void;
  13248. /**
  13249. * Function to be called when a button is modified
  13250. */
  13251. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13252. /**
  13253. * Loads a mesh and attaches it to the controller
  13254. * @param scene the scene the mesh should be added to
  13255. * @param meshLoaded callback for when the mesh has been loaded
  13256. */
  13257. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13258. private _setButtonValue;
  13259. private _changes;
  13260. private _checkChanges;
  13261. /**
  13262. * Disposes of th webVRCOntroller
  13263. */
  13264. dispose(): void;
  13265. }
  13266. }
  13267. declare module "babylonjs/Lights/hemisphericLight" {
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Scene } from "babylonjs/scene";
  13270. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13271. import { Effect } from "babylonjs/Materials/effect";
  13272. import { Light } from "babylonjs/Lights/light";
  13273. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13274. /**
  13275. * The HemisphericLight simulates the ambient environment light,
  13276. * so the passed direction is the light reflection direction, not the incoming direction.
  13277. */
  13278. export class HemisphericLight extends Light {
  13279. /**
  13280. * The groundColor is the light in the opposite direction to the one specified during creation.
  13281. * 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.
  13282. */
  13283. groundColor: Color3;
  13284. /**
  13285. * The light reflection direction, not the incoming direction.
  13286. */
  13287. direction: Vector3;
  13288. /**
  13289. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13290. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13291. * The HemisphericLight can't cast shadows.
  13292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13293. * @param name The friendly name of the light
  13294. * @param direction The direction of the light reflection
  13295. * @param scene The scene the light belongs to
  13296. */
  13297. constructor(name: string, direction: Vector3, scene: Scene);
  13298. protected _buildUniformLayout(): void;
  13299. /**
  13300. * Returns the string "HemisphericLight".
  13301. * @return The class name
  13302. */
  13303. getClassName(): string;
  13304. /**
  13305. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13306. * Returns the updated direction.
  13307. * @param target The target the direction should point to
  13308. * @return The computed direction
  13309. */
  13310. setDirectionToTarget(target: Vector3): Vector3;
  13311. /**
  13312. * Returns the shadow generator associated to the light.
  13313. * @returns Always null for hemispheric lights because it does not support shadows.
  13314. */
  13315. getShadowGenerator(): Nullable<IShadowGenerator>;
  13316. /**
  13317. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13318. * @param effect The effect to update
  13319. * @param lightIndex The index of the light in the effect to update
  13320. * @returns The hemispheric light
  13321. */
  13322. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13323. /**
  13324. * Computes the world matrix of the node
  13325. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13326. * @param useWasUpdatedFlag defines a reserved property
  13327. * @returns the world matrix
  13328. */
  13329. computeWorldMatrix(): Matrix;
  13330. /**
  13331. * Returns the integer 3.
  13332. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13333. */
  13334. getTypeID(): number;
  13335. /**
  13336. * Prepares the list of defines specific to the light type.
  13337. * @param defines the list of defines
  13338. * @param lightIndex defines the index of the light for the effect
  13339. */
  13340. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13341. }
  13342. }
  13343. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13344. /** @hidden */
  13345. export var vrMultiviewToSingleviewPixelShader: {
  13346. name: string;
  13347. shader: string;
  13348. };
  13349. }
  13350. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13352. import { Scene } from "babylonjs/scene";
  13353. /**
  13354. * Renders to multiple views with a single draw call
  13355. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13356. */
  13357. export class MultiviewRenderTarget extends RenderTargetTexture {
  13358. /**
  13359. * Creates a multiview render target
  13360. * @param scene scene used with the render target
  13361. * @param size the size of the render target (used for each view)
  13362. */
  13363. constructor(scene: Scene, size?: number | {
  13364. width: number;
  13365. height: number;
  13366. } | {
  13367. ratio: number;
  13368. });
  13369. /**
  13370. * @hidden
  13371. * @param faceIndex the face index, if its a cube texture
  13372. */
  13373. _bindFrameBuffer(faceIndex?: number): void;
  13374. /**
  13375. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13376. * @returns the view count
  13377. */
  13378. getViewCount(): number;
  13379. }
  13380. }
  13381. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13382. import { Camera } from "babylonjs/Cameras/camera";
  13383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13384. import { Nullable } from "babylonjs/types";
  13385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13386. import { Matrix } from "babylonjs/Maths/math";
  13387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13388. module "babylonjs/Engines/engine" {
  13389. interface Engine {
  13390. /**
  13391. * Creates a new multiview render target
  13392. * @param width defines the width of the texture
  13393. * @param height defines the height of the texture
  13394. * @returns the created multiview texture
  13395. */
  13396. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13397. /**
  13398. * Binds a multiview framebuffer to be drawn to
  13399. * @param multiviewTexture texture to bind
  13400. */
  13401. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13402. }
  13403. }
  13404. module "babylonjs/Cameras/camera" {
  13405. interface Camera {
  13406. /**
  13407. * @hidden
  13408. * 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)
  13409. */
  13410. _useMultiviewToSingleView: boolean;
  13411. /**
  13412. * @hidden
  13413. * 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)
  13414. */
  13415. _multiviewTexture: Nullable<RenderTargetTexture>;
  13416. /**
  13417. * @hidden
  13418. * ensures the multiview texture of the camera exists and has the specified width/height
  13419. * @param width height to set on the multiview texture
  13420. * @param height width to set on the multiview texture
  13421. */
  13422. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13423. }
  13424. }
  13425. module "babylonjs/scene" {
  13426. interface Scene {
  13427. /** @hidden */
  13428. _transformMatrixR: Matrix;
  13429. /** @hidden */
  13430. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13431. /** @hidden */
  13432. _createMultiviewUbo(): void;
  13433. /** @hidden */
  13434. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13435. /** @hidden */
  13436. _renderMultiviewToSingleView(camera: Camera): void;
  13437. }
  13438. }
  13439. }
  13440. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13441. import { Camera } from "babylonjs/Cameras/camera";
  13442. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13443. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13444. import "babylonjs/Engines/Extensions/engine.multiview";
  13445. /**
  13446. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13447. * This will not be used for webXR as it supports displaying texture arrays directly
  13448. */
  13449. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13450. /**
  13451. * Initializes a VRMultiviewToSingleview
  13452. * @param name name of the post process
  13453. * @param camera camera to be applied to
  13454. * @param scaleFactor scaling factor to the size of the output texture
  13455. */
  13456. constructor(name: string, camera: Camera, scaleFactor: number);
  13457. }
  13458. }
  13459. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13460. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13461. import { Nullable } from "babylonjs/types";
  13462. import { Size } from "babylonjs/Maths/math";
  13463. import { Observable } from "babylonjs/Misc/observable";
  13464. module "babylonjs/Engines/engine" {
  13465. /**
  13466. * Defines the interface used by display changed events
  13467. */
  13468. interface IDisplayChangedEventArgs {
  13469. /** Gets the vrDisplay object (if any) */
  13470. vrDisplay: Nullable<any>;
  13471. /** Gets a boolean indicating if webVR is supported */
  13472. vrSupported: boolean;
  13473. }
  13474. interface Engine {
  13475. /** @hidden */
  13476. _vrDisplay: any;
  13477. /** @hidden */
  13478. _vrSupported: boolean;
  13479. /** @hidden */
  13480. _oldSize: Size;
  13481. /** @hidden */
  13482. _oldHardwareScaleFactor: number;
  13483. /** @hidden */
  13484. _vrExclusivePointerMode: boolean;
  13485. /** @hidden */
  13486. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13487. /** @hidden */
  13488. _onVRDisplayPointerRestricted: () => void;
  13489. /** @hidden */
  13490. _onVRDisplayPointerUnrestricted: () => void;
  13491. /** @hidden */
  13492. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13493. /** @hidden */
  13494. _onVrDisplayDisconnect: Nullable<() => void>;
  13495. /** @hidden */
  13496. _onVrDisplayPresentChange: Nullable<() => void>;
  13497. /**
  13498. * Observable signaled when VR display mode changes
  13499. */
  13500. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13501. /**
  13502. * Observable signaled when VR request present is complete
  13503. */
  13504. onVRRequestPresentComplete: Observable<boolean>;
  13505. /**
  13506. * Observable signaled when VR request present starts
  13507. */
  13508. onVRRequestPresentStart: Observable<Engine>;
  13509. /**
  13510. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13511. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13512. */
  13513. isInVRExclusivePointerMode: boolean;
  13514. /**
  13515. * Gets a boolean indicating if a webVR device was detected
  13516. * @returns true if a webVR device was detected
  13517. */
  13518. isVRDevicePresent(): boolean;
  13519. /**
  13520. * Gets the current webVR device
  13521. * @returns the current webVR device (or null)
  13522. */
  13523. getVRDevice(): any;
  13524. /**
  13525. * Initializes a webVR display and starts listening to display change events
  13526. * The onVRDisplayChangedObservable will be notified upon these changes
  13527. * @returns A promise containing a VRDisplay and if vr is supported
  13528. */
  13529. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13530. /** @hidden */
  13531. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13532. /**
  13533. * Call this function to switch to webVR mode
  13534. * Will do nothing if webVR is not supported or if there is no webVR device
  13535. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13536. */
  13537. enableVR(): void;
  13538. /** @hidden */
  13539. _onVRFullScreenTriggered(): void;
  13540. }
  13541. }
  13542. }
  13543. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13544. import { Nullable } from "babylonjs/types";
  13545. import { Observable } from "babylonjs/Misc/observable";
  13546. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13547. import { Scene } from "babylonjs/scene";
  13548. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13549. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13550. import { Node } from "babylonjs/node";
  13551. import { Ray } from "babylonjs/Culling/ray";
  13552. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13553. import "babylonjs/Engines/Extensions/engine.webVR";
  13554. /**
  13555. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13556. * IMPORTANT!! The data is right-hand data.
  13557. * @export
  13558. * @interface DevicePose
  13559. */
  13560. export interface DevicePose {
  13561. /**
  13562. * The position of the device, values in array are [x,y,z].
  13563. */
  13564. readonly position: Nullable<Float32Array>;
  13565. /**
  13566. * The linearVelocity of the device, values in array are [x,y,z].
  13567. */
  13568. readonly linearVelocity: Nullable<Float32Array>;
  13569. /**
  13570. * The linearAcceleration of the device, values in array are [x,y,z].
  13571. */
  13572. readonly linearAcceleration: Nullable<Float32Array>;
  13573. /**
  13574. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13575. */
  13576. readonly orientation: Nullable<Float32Array>;
  13577. /**
  13578. * The angularVelocity of the device, values in array are [x,y,z].
  13579. */
  13580. readonly angularVelocity: Nullable<Float32Array>;
  13581. /**
  13582. * The angularAcceleration of the device, values in array are [x,y,z].
  13583. */
  13584. readonly angularAcceleration: Nullable<Float32Array>;
  13585. }
  13586. /**
  13587. * Interface representing a pose controlled object in Babylon.
  13588. * A pose controlled object has both regular pose values as well as pose values
  13589. * from an external device such as a VR head mounted display
  13590. */
  13591. export interface PoseControlled {
  13592. /**
  13593. * The position of the object in babylon space.
  13594. */
  13595. position: Vector3;
  13596. /**
  13597. * The rotation quaternion of the object in babylon space.
  13598. */
  13599. rotationQuaternion: Quaternion;
  13600. /**
  13601. * The position of the device in babylon space.
  13602. */
  13603. devicePosition?: Vector3;
  13604. /**
  13605. * The rotation quaternion of the device in babylon space.
  13606. */
  13607. deviceRotationQuaternion: Quaternion;
  13608. /**
  13609. * The raw pose coming from the device.
  13610. */
  13611. rawPose: Nullable<DevicePose>;
  13612. /**
  13613. * The scale of the device to be used when translating from device space to babylon space.
  13614. */
  13615. deviceScaleFactor: number;
  13616. /**
  13617. * Updates the poseControlled values based on the input device pose.
  13618. * @param poseData the pose data to update the object with
  13619. */
  13620. updateFromDevice(poseData: DevicePose): void;
  13621. }
  13622. /**
  13623. * Set of options to customize the webVRCamera
  13624. */
  13625. export interface WebVROptions {
  13626. /**
  13627. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13628. */
  13629. trackPosition?: boolean;
  13630. /**
  13631. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13632. */
  13633. positionScale?: number;
  13634. /**
  13635. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13636. */
  13637. displayName?: string;
  13638. /**
  13639. * Should the native controller meshes be initialized. (default: true)
  13640. */
  13641. controllerMeshes?: boolean;
  13642. /**
  13643. * Creating a default HemiLight only on controllers. (default: true)
  13644. */
  13645. defaultLightingOnControllers?: boolean;
  13646. /**
  13647. * If you don't want to use the default VR button of the helper. (default: false)
  13648. */
  13649. useCustomVRButton?: boolean;
  13650. /**
  13651. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13652. */
  13653. customVRButton?: HTMLButtonElement;
  13654. /**
  13655. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13656. */
  13657. rayLength?: number;
  13658. /**
  13659. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13660. */
  13661. defaultHeight?: number;
  13662. /**
  13663. * If multiview should be used if availible (default: false)
  13664. */
  13665. useMultiview?: boolean;
  13666. }
  13667. /**
  13668. * This represents a WebVR camera.
  13669. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13670. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13671. */
  13672. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13673. private webVROptions;
  13674. /**
  13675. * @hidden
  13676. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13677. */
  13678. _vrDevice: any;
  13679. /**
  13680. * The rawPose of the vrDevice.
  13681. */
  13682. rawPose: Nullable<DevicePose>;
  13683. private _onVREnabled;
  13684. private _specsVersion;
  13685. private _attached;
  13686. private _frameData;
  13687. protected _descendants: Array<Node>;
  13688. private _deviceRoomPosition;
  13689. /** @hidden */
  13690. _deviceRoomRotationQuaternion: Quaternion;
  13691. private _standingMatrix;
  13692. /**
  13693. * Represents device position in babylon space.
  13694. */
  13695. devicePosition: Vector3;
  13696. /**
  13697. * Represents device rotation in babylon space.
  13698. */
  13699. deviceRotationQuaternion: Quaternion;
  13700. /**
  13701. * The scale of the device to be used when translating from device space to babylon space.
  13702. */
  13703. deviceScaleFactor: number;
  13704. private _deviceToWorld;
  13705. private _worldToDevice;
  13706. /**
  13707. * References to the webVR controllers for the vrDevice.
  13708. */
  13709. controllers: Array<WebVRController>;
  13710. /**
  13711. * Emits an event when a controller is attached.
  13712. */
  13713. onControllersAttachedObservable: Observable<WebVRController[]>;
  13714. /**
  13715. * Emits an event when a controller's mesh has been loaded;
  13716. */
  13717. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13718. /**
  13719. * Emits an event when the HMD's pose has been updated.
  13720. */
  13721. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13722. private _poseSet;
  13723. /**
  13724. * If the rig cameras be used as parent instead of this camera.
  13725. */
  13726. rigParenting: boolean;
  13727. private _lightOnControllers;
  13728. private _defaultHeight?;
  13729. /**
  13730. * Instantiates a WebVRFreeCamera.
  13731. * @param name The name of the WebVRFreeCamera
  13732. * @param position The starting anchor position for the camera
  13733. * @param scene The scene the camera belongs to
  13734. * @param webVROptions a set of customizable options for the webVRCamera
  13735. */
  13736. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13737. /**
  13738. * Gets the device distance from the ground in meters.
  13739. * @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.
  13740. */
  13741. deviceDistanceToRoomGround(): number;
  13742. /**
  13743. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13744. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13745. */
  13746. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13747. /**
  13748. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13749. * @returns A promise with a boolean set to if the standing matrix is supported.
  13750. */
  13751. useStandingMatrixAsync(): Promise<boolean>;
  13752. /**
  13753. * Disposes the camera
  13754. */
  13755. dispose(): void;
  13756. /**
  13757. * Gets a vrController by name.
  13758. * @param name The name of the controller to retreive
  13759. * @returns the controller matching the name specified or null if not found
  13760. */
  13761. getControllerByName(name: string): Nullable<WebVRController>;
  13762. private _leftController;
  13763. /**
  13764. * The controller corrisponding to the users left hand.
  13765. */
  13766. readonly leftController: Nullable<WebVRController>;
  13767. private _rightController;
  13768. /**
  13769. * The controller corrisponding to the users right hand.
  13770. */
  13771. readonly rightController: Nullable<WebVRController>;
  13772. /**
  13773. * Casts a ray forward from the vrCamera's gaze.
  13774. * @param length Length of the ray (default: 100)
  13775. * @returns the ray corrisponding to the gaze
  13776. */
  13777. getForwardRay(length?: number): Ray;
  13778. /**
  13779. * @hidden
  13780. * Updates the camera based on device's frame data
  13781. */
  13782. _checkInputs(): void;
  13783. /**
  13784. * Updates the poseControlled values based on the input device pose.
  13785. * @param poseData Pose coming from the device
  13786. */
  13787. updateFromDevice(poseData: DevicePose): void;
  13788. private _htmlElementAttached;
  13789. private _detachIfAttached;
  13790. /**
  13791. * WebVR's attach control will start broadcasting frames to the device.
  13792. * Note that in certain browsers (chrome for example) this function must be called
  13793. * within a user-interaction callback. Example:
  13794. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13795. *
  13796. * @param element html element to attach the vrDevice to
  13797. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13798. */
  13799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13800. /**
  13801. * Detaches the camera from the html element and disables VR
  13802. *
  13803. * @param element html element to detach from
  13804. */
  13805. detachControl(element: HTMLElement): void;
  13806. /**
  13807. * @returns the name of this class
  13808. */
  13809. getClassName(): string;
  13810. /**
  13811. * Calls resetPose on the vrDisplay
  13812. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13813. */
  13814. resetToCurrentRotation(): void;
  13815. /**
  13816. * @hidden
  13817. * Updates the rig cameras (left and right eye)
  13818. */
  13819. _updateRigCameras(): void;
  13820. private _workingVector;
  13821. private _oneVector;
  13822. private _workingMatrix;
  13823. private updateCacheCalled;
  13824. private _correctPositionIfNotTrackPosition;
  13825. /**
  13826. * @hidden
  13827. * Updates the cached values of the camera
  13828. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13829. */
  13830. _updateCache(ignoreParentClass?: boolean): void;
  13831. /**
  13832. * @hidden
  13833. * Get current device position in babylon world
  13834. */
  13835. _computeDevicePosition(): void;
  13836. /**
  13837. * Updates the current device position and rotation in the babylon world
  13838. */
  13839. update(): void;
  13840. /**
  13841. * @hidden
  13842. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13843. * @returns an identity matrix
  13844. */
  13845. _getViewMatrix(): Matrix;
  13846. private _tmpMatrix;
  13847. /**
  13848. * This function is called by the two RIG cameras.
  13849. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13850. * @hidden
  13851. */
  13852. _getWebVRViewMatrix(): Matrix;
  13853. /** @hidden */
  13854. _getWebVRProjectionMatrix(): Matrix;
  13855. private _onGamepadConnectedObserver;
  13856. private _onGamepadDisconnectedObserver;
  13857. private _updateCacheWhenTrackingDisabledObserver;
  13858. /**
  13859. * Initializes the controllers and their meshes
  13860. */
  13861. initControllers(): void;
  13862. }
  13863. }
  13864. declare module "babylonjs/PostProcesses/postProcess" {
  13865. import { Nullable } from "babylonjs/types";
  13866. import { SmartArray } from "babylonjs/Misc/smartArray";
  13867. import { Observable } from "babylonjs/Misc/observable";
  13868. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13869. import { Camera } from "babylonjs/Cameras/camera";
  13870. import { Effect } from "babylonjs/Materials/effect";
  13871. import "babylonjs/Shaders/postprocess.vertex";
  13872. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13874. import { Engine } from "babylonjs/Engines/engine";
  13875. /**
  13876. * Size options for a post process
  13877. */
  13878. export type PostProcessOptions = {
  13879. width: number;
  13880. height: number;
  13881. };
  13882. /**
  13883. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13884. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13885. */
  13886. export class PostProcess {
  13887. /** Name of the PostProcess. */
  13888. name: string;
  13889. /**
  13890. * Gets or sets the unique id of the post process
  13891. */
  13892. uniqueId: number;
  13893. /**
  13894. * Width of the texture to apply the post process on
  13895. */
  13896. width: number;
  13897. /**
  13898. * Height of the texture to apply the post process on
  13899. */
  13900. height: number;
  13901. /**
  13902. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13903. * @hidden
  13904. */
  13905. _outputTexture: Nullable<InternalTexture>;
  13906. /**
  13907. * Sampling mode used by the shader
  13908. * See https://doc.babylonjs.com/classes/3.1/texture
  13909. */
  13910. renderTargetSamplingMode: number;
  13911. /**
  13912. * Clear color to use when screen clearing
  13913. */
  13914. clearColor: Color4;
  13915. /**
  13916. * If the buffer needs to be cleared before applying the post process. (default: true)
  13917. * Should be set to false if shader will overwrite all previous pixels.
  13918. */
  13919. autoClear: boolean;
  13920. /**
  13921. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13922. */
  13923. alphaMode: number;
  13924. /**
  13925. * Sets the setAlphaBlendConstants of the babylon engine
  13926. */
  13927. alphaConstants: Color4;
  13928. /**
  13929. * Animations to be used for the post processing
  13930. */
  13931. animations: import("babylonjs/Animations/animation").Animation[];
  13932. /**
  13933. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13934. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13935. */
  13936. enablePixelPerfectMode: boolean;
  13937. /**
  13938. * Force the postprocess to be applied without taking in account viewport
  13939. */
  13940. forceFullscreenViewport: boolean;
  13941. /**
  13942. * List of inspectable custom properties (used by the Inspector)
  13943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13944. */
  13945. inspectableCustomProperties: IInspectable[];
  13946. /**
  13947. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13948. *
  13949. * | Value | Type | Description |
  13950. * | ----- | ----------------------------------- | ----------- |
  13951. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13952. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13953. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13954. *
  13955. */
  13956. scaleMode: number;
  13957. /**
  13958. * Force textures to be a power of two (default: false)
  13959. */
  13960. alwaysForcePOT: boolean;
  13961. private _samples;
  13962. /**
  13963. * Number of sample textures (default: 1)
  13964. */
  13965. samples: number;
  13966. /**
  13967. * Modify the scale of the post process to be the same as the viewport (default: false)
  13968. */
  13969. adaptScaleToCurrentViewport: boolean;
  13970. private _camera;
  13971. private _scene;
  13972. private _engine;
  13973. private _options;
  13974. private _reusable;
  13975. private _textureType;
  13976. /**
  13977. * Smart array of input and output textures for the post process.
  13978. * @hidden
  13979. */
  13980. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13981. /**
  13982. * The index in _textures that corresponds to the output texture.
  13983. * @hidden
  13984. */
  13985. _currentRenderTextureInd: number;
  13986. private _effect;
  13987. private _samplers;
  13988. private _fragmentUrl;
  13989. private _vertexUrl;
  13990. private _parameters;
  13991. private _scaleRatio;
  13992. protected _indexParameters: any;
  13993. private _shareOutputWithPostProcess;
  13994. private _texelSize;
  13995. private _forcedOutputTexture;
  13996. /**
  13997. * Returns the fragment url or shader name used in the post process.
  13998. * @returns the fragment url or name in the shader store.
  13999. */
  14000. getEffectName(): string;
  14001. /**
  14002. * An event triggered when the postprocess is activated.
  14003. */
  14004. onActivateObservable: Observable<Camera>;
  14005. private _onActivateObserver;
  14006. /**
  14007. * A function that is added to the onActivateObservable
  14008. */
  14009. onActivate: Nullable<(camera: Camera) => void>;
  14010. /**
  14011. * An event triggered when the postprocess changes its size.
  14012. */
  14013. onSizeChangedObservable: Observable<PostProcess>;
  14014. private _onSizeChangedObserver;
  14015. /**
  14016. * A function that is added to the onSizeChangedObservable
  14017. */
  14018. onSizeChanged: (postProcess: PostProcess) => void;
  14019. /**
  14020. * An event triggered when the postprocess applies its effect.
  14021. */
  14022. onApplyObservable: Observable<Effect>;
  14023. private _onApplyObserver;
  14024. /**
  14025. * A function that is added to the onApplyObservable
  14026. */
  14027. onApply: (effect: Effect) => void;
  14028. /**
  14029. * An event triggered before rendering the postprocess
  14030. */
  14031. onBeforeRenderObservable: Observable<Effect>;
  14032. private _onBeforeRenderObserver;
  14033. /**
  14034. * A function that is added to the onBeforeRenderObservable
  14035. */
  14036. onBeforeRender: (effect: Effect) => void;
  14037. /**
  14038. * An event triggered after rendering the postprocess
  14039. */
  14040. onAfterRenderObservable: Observable<Effect>;
  14041. private _onAfterRenderObserver;
  14042. /**
  14043. * A function that is added to the onAfterRenderObservable
  14044. */
  14045. onAfterRender: (efect: Effect) => void;
  14046. /**
  14047. * 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
  14048. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14049. */
  14050. inputTexture: InternalTexture;
  14051. /**
  14052. * Gets the camera which post process is applied to.
  14053. * @returns The camera the post process is applied to.
  14054. */
  14055. getCamera(): Camera;
  14056. /**
  14057. * Gets the texel size of the postprocess.
  14058. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14059. */
  14060. readonly texelSize: Vector2;
  14061. /**
  14062. * Creates a new instance PostProcess
  14063. * @param name The name of the PostProcess.
  14064. * @param fragmentUrl The url of the fragment shader to be used.
  14065. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14066. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14067. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14068. * @param camera The camera to apply the render pass to.
  14069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14070. * @param engine The engine which the post process will be applied. (default: current engine)
  14071. * @param reusable If the post process can be reused on the same frame. (default: false)
  14072. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14073. * @param textureType Type of textures used when performing the post process. (default: 0)
  14074. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14075. * @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
  14076. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14077. */
  14078. constructor(
  14079. /** Name of the PostProcess. */
  14080. 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);
  14081. /**
  14082. * Gets a string idenfifying the name of the class
  14083. * @returns "PostProcess" string
  14084. */
  14085. getClassName(): string;
  14086. /**
  14087. * Gets the engine which this post process belongs to.
  14088. * @returns The engine the post process was enabled with.
  14089. */
  14090. getEngine(): Engine;
  14091. /**
  14092. * The effect that is created when initializing the post process.
  14093. * @returns The created effect corrisponding the the postprocess.
  14094. */
  14095. getEffect(): Effect;
  14096. /**
  14097. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14098. * @param postProcess The post process to share the output with.
  14099. * @returns This post process.
  14100. */
  14101. shareOutputWith(postProcess: PostProcess): PostProcess;
  14102. /**
  14103. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14104. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14105. */
  14106. useOwnOutput(): void;
  14107. /**
  14108. * Updates the effect with the current post process compile time values and recompiles the shader.
  14109. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14110. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14111. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14112. * @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
  14113. * @param onCompiled Called when the shader has been compiled.
  14114. * @param onError Called if there is an error when compiling a shader.
  14115. */
  14116. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14117. /**
  14118. * The post process is reusable if it can be used multiple times within one frame.
  14119. * @returns If the post process is reusable
  14120. */
  14121. isReusable(): boolean;
  14122. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14123. markTextureDirty(): void;
  14124. /**
  14125. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14126. * 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.
  14127. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14128. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14129. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14130. * @returns The target texture that was bound to be written to.
  14131. */
  14132. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14133. /**
  14134. * If the post process is supported.
  14135. */
  14136. readonly isSupported: boolean;
  14137. /**
  14138. * The aspect ratio of the output texture.
  14139. */
  14140. readonly aspectRatio: number;
  14141. /**
  14142. * Get a value indicating if the post-process is ready to be used
  14143. * @returns true if the post-process is ready (shader is compiled)
  14144. */
  14145. isReady(): boolean;
  14146. /**
  14147. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14148. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14149. */
  14150. apply(): Nullable<Effect>;
  14151. private _disposeTextures;
  14152. /**
  14153. * Disposes the post process.
  14154. * @param camera The camera to dispose the post process on.
  14155. */
  14156. dispose(camera?: Camera): void;
  14157. }
  14158. }
  14159. declare module "babylonjs/PostProcesses/postProcessManager" {
  14160. import { Nullable } from "babylonjs/types";
  14161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14163. import { Scene } from "babylonjs/scene";
  14164. /**
  14165. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14166. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14167. */
  14168. export class PostProcessManager {
  14169. private _scene;
  14170. private _indexBuffer;
  14171. private _vertexBuffers;
  14172. /**
  14173. * Creates a new instance PostProcess
  14174. * @param scene The scene that the post process is associated with.
  14175. */
  14176. constructor(scene: Scene);
  14177. private _prepareBuffers;
  14178. private _buildIndexBuffer;
  14179. /**
  14180. * Rebuilds the vertex buffers of the manager.
  14181. * @hidden
  14182. */
  14183. _rebuild(): void;
  14184. /**
  14185. * Prepares a frame to be run through a post process.
  14186. * @param sourceTexture The input texture to the post procesess. (default: null)
  14187. * @param postProcesses An array of post processes to be run. (default: null)
  14188. * @returns True if the post processes were able to be run.
  14189. * @hidden
  14190. */
  14191. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14192. /**
  14193. * Manually render a set of post processes to a texture.
  14194. * @param postProcesses An array of post processes to be run.
  14195. * @param targetTexture The target texture to render to.
  14196. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14197. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14198. * @param lodLevel defines which lod of the texture to render to
  14199. */
  14200. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14201. /**
  14202. * Finalize the result of the output of the postprocesses.
  14203. * @param doNotPresent If true the result will not be displayed to the screen.
  14204. * @param targetTexture The target texture to render to.
  14205. * @param faceIndex The index of the face to bind the target texture to.
  14206. * @param postProcesses The array of post processes to render.
  14207. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14208. * @hidden
  14209. */
  14210. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14211. /**
  14212. * Disposes of the post process manager.
  14213. */
  14214. dispose(): void;
  14215. }
  14216. }
  14217. declare module "babylonjs/Layers/layerSceneComponent" {
  14218. import { Scene } from "babylonjs/scene";
  14219. import { ISceneComponent } from "babylonjs/sceneComponent";
  14220. import { Layer } from "babylonjs/Layers/layer";
  14221. module "babylonjs/abstractScene" {
  14222. interface AbstractScene {
  14223. /**
  14224. * The list of layers (background and foreground) of the scene
  14225. */
  14226. layers: Array<Layer>;
  14227. }
  14228. }
  14229. /**
  14230. * Defines the layer scene component responsible to manage any layers
  14231. * in a given scene.
  14232. */
  14233. export class LayerSceneComponent implements ISceneComponent {
  14234. /**
  14235. * The component name helpfull to identify the component in the list of scene components.
  14236. */
  14237. readonly name: string;
  14238. /**
  14239. * The scene the component belongs to.
  14240. */
  14241. scene: Scene;
  14242. private _engine;
  14243. /**
  14244. * Creates a new instance of the component for the given scene
  14245. * @param scene Defines the scene to register the component in
  14246. */
  14247. constructor(scene: Scene);
  14248. /**
  14249. * Registers the component in a given scene
  14250. */
  14251. register(): void;
  14252. /**
  14253. * Rebuilds the elements related to this component in case of
  14254. * context lost for instance.
  14255. */
  14256. rebuild(): void;
  14257. /**
  14258. * Disposes the component and the associated ressources.
  14259. */
  14260. dispose(): void;
  14261. private _draw;
  14262. private _drawCameraPredicate;
  14263. private _drawCameraBackground;
  14264. private _drawCameraForeground;
  14265. private _drawRenderTargetPredicate;
  14266. private _drawRenderTargetBackground;
  14267. private _drawRenderTargetForeground;
  14268. }
  14269. }
  14270. declare module "babylonjs/Shaders/layer.fragment" {
  14271. /** @hidden */
  14272. export var layerPixelShader: {
  14273. name: string;
  14274. shader: string;
  14275. };
  14276. }
  14277. declare module "babylonjs/Shaders/layer.vertex" {
  14278. /** @hidden */
  14279. export var layerVertexShader: {
  14280. name: string;
  14281. shader: string;
  14282. };
  14283. }
  14284. declare module "babylonjs/Layers/layer" {
  14285. import { Observable } from "babylonjs/Misc/observable";
  14286. import { Nullable } from "babylonjs/types";
  14287. import { Scene } from "babylonjs/scene";
  14288. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14289. import { Texture } from "babylonjs/Materials/Textures/texture";
  14290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14291. import "babylonjs/Shaders/layer.fragment";
  14292. import "babylonjs/Shaders/layer.vertex";
  14293. /**
  14294. * This represents a full screen 2d layer.
  14295. * This can be useful to display a picture in the background of your scene for instance.
  14296. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14297. */
  14298. export class Layer {
  14299. /**
  14300. * Define the name of the layer.
  14301. */
  14302. name: string;
  14303. /**
  14304. * Define the texture the layer should display.
  14305. */
  14306. texture: Nullable<Texture>;
  14307. /**
  14308. * Is the layer in background or foreground.
  14309. */
  14310. isBackground: boolean;
  14311. /**
  14312. * Define the color of the layer (instead of texture).
  14313. */
  14314. color: Color4;
  14315. /**
  14316. * Define the scale of the layer in order to zoom in out of the texture.
  14317. */
  14318. scale: Vector2;
  14319. /**
  14320. * Define an offset for the layer in order to shift the texture.
  14321. */
  14322. offset: Vector2;
  14323. /**
  14324. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14325. */
  14326. alphaBlendingMode: number;
  14327. /**
  14328. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14329. * Alpha test will not mix with the background color in case of transparency.
  14330. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14331. */
  14332. alphaTest: boolean;
  14333. /**
  14334. * Define a mask to restrict the layer to only some of the scene cameras.
  14335. */
  14336. layerMask: number;
  14337. /**
  14338. * Define the list of render target the layer is visible into.
  14339. */
  14340. renderTargetTextures: RenderTargetTexture[];
  14341. /**
  14342. * Define if the layer is only used in renderTarget or if it also
  14343. * renders in the main frame buffer of the canvas.
  14344. */
  14345. renderOnlyInRenderTargetTextures: boolean;
  14346. private _scene;
  14347. private _vertexBuffers;
  14348. private _indexBuffer;
  14349. private _effect;
  14350. private _alphaTestEffect;
  14351. /**
  14352. * An event triggered when the layer is disposed.
  14353. */
  14354. onDisposeObservable: Observable<Layer>;
  14355. private _onDisposeObserver;
  14356. /**
  14357. * Back compatibility with callback before the onDisposeObservable existed.
  14358. * The set callback will be triggered when the layer has been disposed.
  14359. */
  14360. onDispose: () => void;
  14361. /**
  14362. * An event triggered before rendering the scene
  14363. */
  14364. onBeforeRenderObservable: Observable<Layer>;
  14365. private _onBeforeRenderObserver;
  14366. /**
  14367. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14368. * The set callback will be triggered just before rendering the layer.
  14369. */
  14370. onBeforeRender: () => void;
  14371. /**
  14372. * An event triggered after rendering the scene
  14373. */
  14374. onAfterRenderObservable: Observable<Layer>;
  14375. private _onAfterRenderObserver;
  14376. /**
  14377. * Back compatibility with callback before the onAfterRenderObservable existed.
  14378. * The set callback will be triggered just after rendering the layer.
  14379. */
  14380. onAfterRender: () => void;
  14381. /**
  14382. * Instantiates a new layer.
  14383. * This represents a full screen 2d layer.
  14384. * This can be useful to display a picture in the background of your scene for instance.
  14385. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14386. * @param name Define the name of the layer in the scene
  14387. * @param imgUrl Define the url of the texture to display in the layer
  14388. * @param scene Define the scene the layer belongs to
  14389. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14390. * @param color Defines a color for the layer
  14391. */
  14392. constructor(
  14393. /**
  14394. * Define the name of the layer.
  14395. */
  14396. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14397. private _createIndexBuffer;
  14398. /** @hidden */
  14399. _rebuild(): void;
  14400. /**
  14401. * Renders the layer in the scene.
  14402. */
  14403. render(): void;
  14404. /**
  14405. * Disposes and releases the associated ressources.
  14406. */
  14407. dispose(): void;
  14408. }
  14409. }
  14410. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14411. import { Scene } from "babylonjs/scene";
  14412. import { ISceneComponent } from "babylonjs/sceneComponent";
  14413. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14414. module "babylonjs/abstractScene" {
  14415. interface AbstractScene {
  14416. /**
  14417. * The list of procedural textures added to the scene
  14418. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14419. */
  14420. proceduralTextures: Array<ProceduralTexture>;
  14421. }
  14422. }
  14423. /**
  14424. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14425. * in a given scene.
  14426. */
  14427. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14428. /**
  14429. * The component name helpfull to identify the component in the list of scene components.
  14430. */
  14431. readonly name: string;
  14432. /**
  14433. * The scene the component belongs to.
  14434. */
  14435. scene: Scene;
  14436. /**
  14437. * Creates a new instance of the component for the given scene
  14438. * @param scene Defines the scene to register the component in
  14439. */
  14440. constructor(scene: Scene);
  14441. /**
  14442. * Registers the component in a given scene
  14443. */
  14444. register(): void;
  14445. /**
  14446. * Rebuilds the elements related to this component in case of
  14447. * context lost for instance.
  14448. */
  14449. rebuild(): void;
  14450. /**
  14451. * Disposes the component and the associated ressources.
  14452. */
  14453. dispose(): void;
  14454. private _beforeClear;
  14455. }
  14456. }
  14457. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14459. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14460. module "babylonjs/Engines/engine" {
  14461. interface Engine {
  14462. /**
  14463. * Creates a new render target cube texture
  14464. * @param size defines the size of the texture
  14465. * @param options defines the options used to create the texture
  14466. * @returns a new render target cube texture stored in an InternalTexture
  14467. */
  14468. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14469. }
  14470. }
  14471. }
  14472. declare module "babylonjs/Shaders/procedural.vertex" {
  14473. /** @hidden */
  14474. export var proceduralVertexShader: {
  14475. name: string;
  14476. shader: string;
  14477. };
  14478. }
  14479. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14480. import { Observable } from "babylonjs/Misc/observable";
  14481. import { Nullable } from "babylonjs/types";
  14482. import { Scene } from "babylonjs/scene";
  14483. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14484. import { Effect } from "babylonjs/Materials/effect";
  14485. import { Texture } from "babylonjs/Materials/Textures/texture";
  14486. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14487. import "babylonjs/Shaders/procedural.vertex";
  14488. /**
  14489. * 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.
  14490. * This is the base class of any Procedural texture and contains most of the shareable code.
  14491. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14492. */
  14493. export class ProceduralTexture extends Texture {
  14494. isCube: boolean;
  14495. /**
  14496. * Define if the texture is enabled or not (disabled texture will not render)
  14497. */
  14498. isEnabled: boolean;
  14499. /**
  14500. * Define if the texture must be cleared before rendering (default is true)
  14501. */
  14502. autoClear: boolean;
  14503. /**
  14504. * Callback called when the texture is generated
  14505. */
  14506. onGenerated: () => void;
  14507. /**
  14508. * Event raised when the texture is generated
  14509. */
  14510. onGeneratedObservable: Observable<ProceduralTexture>;
  14511. /** @hidden */
  14512. _generateMipMaps: boolean;
  14513. /** @hidden **/
  14514. _effect: Effect;
  14515. /** @hidden */
  14516. _textures: {
  14517. [key: string]: Texture;
  14518. };
  14519. private _size;
  14520. private _currentRefreshId;
  14521. private _refreshRate;
  14522. private _vertexBuffers;
  14523. private _indexBuffer;
  14524. private _uniforms;
  14525. private _samplers;
  14526. private _fragment;
  14527. private _floats;
  14528. private _ints;
  14529. private _floatsArrays;
  14530. private _colors3;
  14531. private _colors4;
  14532. private _vectors2;
  14533. private _vectors3;
  14534. private _matrices;
  14535. private _fallbackTexture;
  14536. private _fallbackTextureUsed;
  14537. private _engine;
  14538. private _cachedDefines;
  14539. private _contentUpdateId;
  14540. private _contentData;
  14541. /**
  14542. * Instantiates a new procedural texture.
  14543. * 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.
  14544. * This is the base class of any Procedural texture and contains most of the shareable code.
  14545. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14546. * @param name Define the name of the texture
  14547. * @param size Define the size of the texture to create
  14548. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14549. * @param scene Define the scene the texture belongs to
  14550. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14551. * @param generateMipMaps Define if the texture should creates mip maps or not
  14552. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14553. */
  14554. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14555. /**
  14556. * The effect that is created when initializing the post process.
  14557. * @returns The created effect corrisponding the the postprocess.
  14558. */
  14559. getEffect(): Effect;
  14560. /**
  14561. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14562. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14563. */
  14564. getContent(): Nullable<ArrayBufferView>;
  14565. private _createIndexBuffer;
  14566. /** @hidden */
  14567. _rebuild(): void;
  14568. /**
  14569. * Resets the texture in order to recreate its associated resources.
  14570. * This can be called in case of context loss
  14571. */
  14572. reset(): void;
  14573. protected _getDefines(): string;
  14574. /**
  14575. * Is the texture ready to be used ? (rendered at least once)
  14576. * @returns true if ready, otherwise, false.
  14577. */
  14578. isReady(): boolean;
  14579. /**
  14580. * Resets the refresh counter of the texture and start bak from scratch.
  14581. * Could be useful to regenerate the texture if it is setup to render only once.
  14582. */
  14583. resetRefreshCounter(): void;
  14584. /**
  14585. * Set the fragment shader to use in order to render the texture.
  14586. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14587. */
  14588. setFragment(fragment: any): void;
  14589. /**
  14590. * Define the refresh rate of the texture or the rendering frequency.
  14591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14592. */
  14593. refreshRate: number;
  14594. /** @hidden */
  14595. _shouldRender(): boolean;
  14596. /**
  14597. * Get the size the texture is rendering at.
  14598. * @returns the size (texture is always squared)
  14599. */
  14600. getRenderSize(): number;
  14601. /**
  14602. * Resize the texture to new value.
  14603. * @param size Define the new size the texture should have
  14604. * @param generateMipMaps Define whether the new texture should create mip maps
  14605. */
  14606. resize(size: number, generateMipMaps: boolean): void;
  14607. private _checkUniform;
  14608. /**
  14609. * Set a texture in the shader program used to render.
  14610. * @param name Define the name of the uniform samplers as defined in the shader
  14611. * @param texture Define the texture to bind to this sampler
  14612. * @return the texture itself allowing "fluent" like uniform updates
  14613. */
  14614. setTexture(name: string, texture: Texture): ProceduralTexture;
  14615. /**
  14616. * Set a float in the shader.
  14617. * @param name Define the name of the uniform as defined in the shader
  14618. * @param value Define the value to give to the uniform
  14619. * @return the texture itself allowing "fluent" like uniform updates
  14620. */
  14621. setFloat(name: string, value: number): ProceduralTexture;
  14622. /**
  14623. * Set a int in the shader.
  14624. * @param name Define the name of the uniform as defined in the shader
  14625. * @param value Define the value to give to the uniform
  14626. * @return the texture itself allowing "fluent" like uniform updates
  14627. */
  14628. setInt(name: string, value: number): ProceduralTexture;
  14629. /**
  14630. * Set an array of floats in the shader.
  14631. * @param name Define the name of the uniform as defined in the shader
  14632. * @param value Define the value to give to the uniform
  14633. * @return the texture itself allowing "fluent" like uniform updates
  14634. */
  14635. setFloats(name: string, value: number[]): ProceduralTexture;
  14636. /**
  14637. * Set a vec3 in the shader from a Color3.
  14638. * @param name Define the name of the uniform as defined in the shader
  14639. * @param value Define the value to give to the uniform
  14640. * @return the texture itself allowing "fluent" like uniform updates
  14641. */
  14642. setColor3(name: string, value: Color3): ProceduralTexture;
  14643. /**
  14644. * Set a vec4 in the shader from a Color4.
  14645. * @param name Define the name of the uniform as defined in the shader
  14646. * @param value Define the value to give to the uniform
  14647. * @return the texture itself allowing "fluent" like uniform updates
  14648. */
  14649. setColor4(name: string, value: Color4): ProceduralTexture;
  14650. /**
  14651. * Set a vec2 in the shader from a Vector2.
  14652. * @param name Define the name of the uniform as defined in the shader
  14653. * @param value Define the value to give to the uniform
  14654. * @return the texture itself allowing "fluent" like uniform updates
  14655. */
  14656. setVector2(name: string, value: Vector2): ProceduralTexture;
  14657. /**
  14658. * Set a vec3 in the shader from a Vector3.
  14659. * @param name Define the name of the uniform as defined in the shader
  14660. * @param value Define the value to give to the uniform
  14661. * @return the texture itself allowing "fluent" like uniform updates
  14662. */
  14663. setVector3(name: string, value: Vector3): ProceduralTexture;
  14664. /**
  14665. * Set a mat4 in the shader from a MAtrix.
  14666. * @param name Define the name of the uniform as defined in the shader
  14667. * @param value Define the value to give to the uniform
  14668. * @return the texture itself allowing "fluent" like uniform updates
  14669. */
  14670. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14671. /**
  14672. * Render the texture to its associated render target.
  14673. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14674. */
  14675. render(useCameraPostProcess?: boolean): void;
  14676. /**
  14677. * Clone the texture.
  14678. * @returns the cloned texture
  14679. */
  14680. clone(): ProceduralTexture;
  14681. /**
  14682. * Dispose the texture and release its asoociated resources.
  14683. */
  14684. dispose(): void;
  14685. }
  14686. }
  14687. declare module "babylonjs/Particles/baseParticleSystem" {
  14688. import { Nullable } from "babylonjs/types";
  14689. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14691. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14692. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14693. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14694. import { Scene } from "babylonjs/scene";
  14695. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14696. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14697. import { Texture } from "babylonjs/Materials/Textures/texture";
  14698. import { Animation } from "babylonjs/Animations/animation";
  14699. /**
  14700. * This represents the base class for particle system in Babylon.
  14701. * 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.
  14702. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14703. * @example https://doc.babylonjs.com/babylon101/particles
  14704. */
  14705. export class BaseParticleSystem {
  14706. /**
  14707. * Source color is added to the destination color without alpha affecting the result
  14708. */
  14709. static BLENDMODE_ONEONE: number;
  14710. /**
  14711. * Blend current color and particle color using particle’s alpha
  14712. */
  14713. static BLENDMODE_STANDARD: number;
  14714. /**
  14715. * Add current color and particle color multiplied by particle’s alpha
  14716. */
  14717. static BLENDMODE_ADD: number;
  14718. /**
  14719. * Multiply current color with particle color
  14720. */
  14721. static BLENDMODE_MULTIPLY: number;
  14722. /**
  14723. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14724. */
  14725. static BLENDMODE_MULTIPLYADD: number;
  14726. /**
  14727. * List of animations used by the particle system.
  14728. */
  14729. animations: Animation[];
  14730. /**
  14731. * The id of the Particle system.
  14732. */
  14733. id: string;
  14734. /**
  14735. * The friendly name of the Particle system.
  14736. */
  14737. name: string;
  14738. /**
  14739. * The rendering group used by the Particle system to chose when to render.
  14740. */
  14741. renderingGroupId: number;
  14742. /**
  14743. * The emitter represents the Mesh or position we are attaching the particle system to.
  14744. */
  14745. emitter: Nullable<AbstractMesh | Vector3>;
  14746. /**
  14747. * The maximum number of particles to emit per frame
  14748. */
  14749. emitRate: number;
  14750. /**
  14751. * If you want to launch only a few particles at once, that can be done, as well.
  14752. */
  14753. manualEmitCount: number;
  14754. /**
  14755. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14756. */
  14757. updateSpeed: number;
  14758. /**
  14759. * The amount of time the particle system is running (depends of the overall update speed).
  14760. */
  14761. targetStopDuration: number;
  14762. /**
  14763. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14764. */
  14765. disposeOnStop: boolean;
  14766. /**
  14767. * Minimum power of emitting particles.
  14768. */
  14769. minEmitPower: number;
  14770. /**
  14771. * Maximum power of emitting particles.
  14772. */
  14773. maxEmitPower: number;
  14774. /**
  14775. * Minimum life time of emitting particles.
  14776. */
  14777. minLifeTime: number;
  14778. /**
  14779. * Maximum life time of emitting particles.
  14780. */
  14781. maxLifeTime: number;
  14782. /**
  14783. * Minimum Size of emitting particles.
  14784. */
  14785. minSize: number;
  14786. /**
  14787. * Maximum Size of emitting particles.
  14788. */
  14789. maxSize: number;
  14790. /**
  14791. * Minimum scale of emitting particles on X axis.
  14792. */
  14793. minScaleX: number;
  14794. /**
  14795. * Maximum scale of emitting particles on X axis.
  14796. */
  14797. maxScaleX: number;
  14798. /**
  14799. * Minimum scale of emitting particles on Y axis.
  14800. */
  14801. minScaleY: number;
  14802. /**
  14803. * Maximum scale of emitting particles on Y axis.
  14804. */
  14805. maxScaleY: number;
  14806. /**
  14807. * Gets or sets the minimal initial rotation in radians.
  14808. */
  14809. minInitialRotation: number;
  14810. /**
  14811. * Gets or sets the maximal initial rotation in radians.
  14812. */
  14813. maxInitialRotation: number;
  14814. /**
  14815. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14816. */
  14817. minAngularSpeed: number;
  14818. /**
  14819. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14820. */
  14821. maxAngularSpeed: number;
  14822. /**
  14823. * The texture used to render each particle. (this can be a spritesheet)
  14824. */
  14825. particleTexture: Nullable<Texture>;
  14826. /**
  14827. * The layer mask we are rendering the particles through.
  14828. */
  14829. layerMask: number;
  14830. /**
  14831. * This can help using your own shader to render the particle system.
  14832. * The according effect will be created
  14833. */
  14834. customShader: any;
  14835. /**
  14836. * By default particle system starts as soon as they are created. This prevents the
  14837. * automatic start to happen and let you decide when to start emitting particles.
  14838. */
  14839. preventAutoStart: boolean;
  14840. private _noiseTexture;
  14841. /**
  14842. * Gets or sets a texture used to add random noise to particle positions
  14843. */
  14844. noiseTexture: Nullable<ProceduralTexture>;
  14845. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14846. noiseStrength: Vector3;
  14847. /**
  14848. * Callback triggered when the particle animation is ending.
  14849. */
  14850. onAnimationEnd: Nullable<() => void>;
  14851. /**
  14852. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14853. */
  14854. blendMode: number;
  14855. /**
  14856. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14857. * to override the particles.
  14858. */
  14859. forceDepthWrite: boolean;
  14860. /** 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 */
  14861. preWarmCycles: number;
  14862. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14863. preWarmStepOffset: number;
  14864. /**
  14865. * 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)
  14866. */
  14867. spriteCellChangeSpeed: number;
  14868. /**
  14869. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14870. */
  14871. startSpriteCellID: number;
  14872. /**
  14873. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14874. */
  14875. endSpriteCellID: number;
  14876. /**
  14877. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14878. */
  14879. spriteCellWidth: number;
  14880. /**
  14881. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14882. */
  14883. spriteCellHeight: number;
  14884. /**
  14885. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14886. */
  14887. spriteRandomStartCell: boolean;
  14888. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14889. translationPivot: Vector2;
  14890. /** @hidden */
  14891. protected _isAnimationSheetEnabled: boolean;
  14892. /**
  14893. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14894. */
  14895. beginAnimationOnStart: boolean;
  14896. /**
  14897. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14898. */
  14899. beginAnimationFrom: number;
  14900. /**
  14901. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14902. */
  14903. beginAnimationTo: number;
  14904. /**
  14905. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14906. */
  14907. beginAnimationLoop: boolean;
  14908. /**
  14909. * Gets or sets a world offset applied to all particles
  14910. */
  14911. worldOffset: Vector3;
  14912. /**
  14913. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14914. */
  14915. isAnimationSheetEnabled: boolean;
  14916. /**
  14917. * Get hosting scene
  14918. * @returns the scene
  14919. */
  14920. getScene(): Scene;
  14921. /**
  14922. * You can use gravity if you want to give an orientation to your particles.
  14923. */
  14924. gravity: Vector3;
  14925. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14926. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14928. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14929. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14931. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14932. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14933. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14934. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14935. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14937. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14938. /**
  14939. * Defines the delay in milliseconds before starting the system (0 by default)
  14940. */
  14941. startDelay: number;
  14942. /**
  14943. * Gets the current list of drag gradients.
  14944. * You must use addDragGradient and removeDragGradient to udpate this list
  14945. * @returns the list of drag gradients
  14946. */
  14947. getDragGradients(): Nullable<Array<FactorGradient>>;
  14948. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14949. limitVelocityDamping: number;
  14950. /**
  14951. * Gets the current list of limit velocity gradients.
  14952. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14953. * @returns the list of limit velocity gradients
  14954. */
  14955. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14956. /**
  14957. * Gets the current list of color gradients.
  14958. * You must use addColorGradient and removeColorGradient to udpate this list
  14959. * @returns the list of color gradients
  14960. */
  14961. getColorGradients(): Nullable<Array<ColorGradient>>;
  14962. /**
  14963. * Gets the current list of size gradients.
  14964. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14965. * @returns the list of size gradients
  14966. */
  14967. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14968. /**
  14969. * Gets the current list of color remap gradients.
  14970. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14971. * @returns the list of color remap gradients
  14972. */
  14973. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Gets the current list of alpha remap gradients.
  14976. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14977. * @returns the list of alpha remap gradients
  14978. */
  14979. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14980. /**
  14981. * Gets the current list of life time gradients.
  14982. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14983. * @returns the list of life time gradients
  14984. */
  14985. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14986. /**
  14987. * Gets the current list of angular speed gradients.
  14988. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14989. * @returns the list of angular speed gradients
  14990. */
  14991. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14992. /**
  14993. * Gets the current list of velocity gradients.
  14994. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14995. * @returns the list of velocity gradients
  14996. */
  14997. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14998. /**
  14999. * Gets the current list of start size gradients.
  15000. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15001. * @returns the list of start size gradients
  15002. */
  15003. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15004. /**
  15005. * Gets the current list of emit rate gradients.
  15006. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15007. * @returns the list of emit rate gradients
  15008. */
  15009. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15010. /**
  15011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15013. */
  15014. direction1: Vector3;
  15015. /**
  15016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15017. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15018. */
  15019. direction2: Vector3;
  15020. /**
  15021. * 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.
  15022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15023. */
  15024. minEmitBox: Vector3;
  15025. /**
  15026. * 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.
  15027. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15028. */
  15029. maxEmitBox: Vector3;
  15030. /**
  15031. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15032. */
  15033. color1: Color4;
  15034. /**
  15035. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15036. */
  15037. color2: Color4;
  15038. /**
  15039. * Color the particle will have at the end of its lifetime
  15040. */
  15041. colorDead: Color4;
  15042. /**
  15043. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15044. */
  15045. textureMask: Color4;
  15046. /**
  15047. * The particle emitter type defines the emitter used by the particle system.
  15048. * It can be for example box, sphere, or cone...
  15049. */
  15050. particleEmitterType: IParticleEmitterType;
  15051. /** @hidden */
  15052. _isSubEmitter: boolean;
  15053. /**
  15054. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15055. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15056. */
  15057. billboardMode: number;
  15058. protected _isBillboardBased: boolean;
  15059. /**
  15060. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15061. */
  15062. isBillboardBased: boolean;
  15063. /**
  15064. * The scene the particle system belongs to.
  15065. */
  15066. protected _scene: Scene;
  15067. /**
  15068. * Local cache of defines for image processing.
  15069. */
  15070. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15071. /**
  15072. * Default configuration related to image processing available in the standard Material.
  15073. */
  15074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15075. /**
  15076. * Gets the image processing configuration used either in this material.
  15077. */
  15078. /**
  15079. * Sets the Default image processing configuration used either in the this material.
  15080. *
  15081. * If sets to null, the scene one is in use.
  15082. */
  15083. imageProcessingConfiguration: ImageProcessingConfiguration;
  15084. /**
  15085. * Attaches a new image processing configuration to the Standard Material.
  15086. * @param configuration
  15087. */
  15088. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15089. /** @hidden */
  15090. protected _reset(): void;
  15091. /** @hidden */
  15092. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15093. /**
  15094. * Instantiates a particle system.
  15095. * 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.
  15096. * @param name The name of the particle system
  15097. */
  15098. constructor(name: string);
  15099. /**
  15100. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15103. * @returns the emitter
  15104. */
  15105. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15106. /**
  15107. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15108. * @param radius The radius of the hemisphere to emit from
  15109. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15110. * @returns the emitter
  15111. */
  15112. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15113. /**
  15114. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15115. * @param radius The radius of the sphere to emit from
  15116. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15117. * @returns the emitter
  15118. */
  15119. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15120. /**
  15121. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15122. * @param radius The radius of the sphere to emit from
  15123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15125. * @returns the emitter
  15126. */
  15127. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15128. /**
  15129. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15130. * @param radius The radius of the emission cylinder
  15131. * @param height The height of the emission cylinder
  15132. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15133. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15134. * @returns the emitter
  15135. */
  15136. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15137. /**
  15138. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15139. * @param radius The radius of the cylinder to emit from
  15140. * @param height The height of the emission cylinder
  15141. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15142. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15144. * @returns the emitter
  15145. */
  15146. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15147. /**
  15148. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15149. * @param radius The radius of the cone to emit from
  15150. * @param angle The base angle of the cone
  15151. * @returns the emitter
  15152. */
  15153. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15154. /**
  15155. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15156. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15158. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15160. * @returns the emitter
  15161. */
  15162. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15163. }
  15164. }
  15165. declare module "babylonjs/Particles/subEmitter" {
  15166. import { Scene } from "babylonjs/scene";
  15167. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15168. /**
  15169. * Type of sub emitter
  15170. */
  15171. export enum SubEmitterType {
  15172. /**
  15173. * Attached to the particle over it's lifetime
  15174. */
  15175. ATTACHED = 0,
  15176. /**
  15177. * Created when the particle dies
  15178. */
  15179. END = 1
  15180. }
  15181. /**
  15182. * Sub emitter class used to emit particles from an existing particle
  15183. */
  15184. export class SubEmitter {
  15185. /**
  15186. * the particle system to be used by the sub emitter
  15187. */
  15188. particleSystem: ParticleSystem;
  15189. /**
  15190. * Type of the submitter (Default: END)
  15191. */
  15192. type: SubEmitterType;
  15193. /**
  15194. * 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)
  15195. * Note: This only is supported when using an emitter of type Mesh
  15196. */
  15197. inheritDirection: boolean;
  15198. /**
  15199. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15200. */
  15201. inheritedVelocityAmount: number;
  15202. /**
  15203. * Creates a sub emitter
  15204. * @param particleSystem the particle system to be used by the sub emitter
  15205. */
  15206. constructor(
  15207. /**
  15208. * the particle system to be used by the sub emitter
  15209. */
  15210. particleSystem: ParticleSystem);
  15211. /**
  15212. * Clones the sub emitter
  15213. * @returns the cloned sub emitter
  15214. */
  15215. clone(): SubEmitter;
  15216. /**
  15217. * Serialize current object to a JSON object
  15218. * @returns the serialized object
  15219. */
  15220. serialize(): any;
  15221. /** @hidden */
  15222. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15223. /**
  15224. * Creates a new SubEmitter from a serialized JSON version
  15225. * @param serializationObject defines the JSON object to read from
  15226. * @param scene defines the hosting scene
  15227. * @param rootUrl defines the rootUrl for data loading
  15228. * @returns a new SubEmitter
  15229. */
  15230. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15231. /** Release associated resources */
  15232. dispose(): void;
  15233. }
  15234. }
  15235. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15236. /** @hidden */
  15237. export var clipPlaneFragmentDeclaration: {
  15238. name: string;
  15239. shader: string;
  15240. };
  15241. }
  15242. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15243. /** @hidden */
  15244. export var imageProcessingDeclaration: {
  15245. name: string;
  15246. shader: string;
  15247. };
  15248. }
  15249. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15250. /** @hidden */
  15251. export var imageProcessingFunctions: {
  15252. name: string;
  15253. shader: string;
  15254. };
  15255. }
  15256. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15257. /** @hidden */
  15258. export var clipPlaneFragment: {
  15259. name: string;
  15260. shader: string;
  15261. };
  15262. }
  15263. declare module "babylonjs/Shaders/particles.fragment" {
  15264. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15266. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15268. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15269. /** @hidden */
  15270. export var particlesPixelShader: {
  15271. name: string;
  15272. shader: string;
  15273. };
  15274. }
  15275. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15276. /** @hidden */
  15277. export var clipPlaneVertexDeclaration: {
  15278. name: string;
  15279. shader: string;
  15280. };
  15281. }
  15282. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15283. /** @hidden */
  15284. export var clipPlaneVertex: {
  15285. name: string;
  15286. shader: string;
  15287. };
  15288. }
  15289. declare module "babylonjs/Shaders/particles.vertex" {
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15291. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15292. /** @hidden */
  15293. export var particlesVertexShader: {
  15294. name: string;
  15295. shader: string;
  15296. };
  15297. }
  15298. declare module "babylonjs/Particles/particleSystem" {
  15299. import { Nullable } from "babylonjs/types";
  15300. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15301. import { Observable } from "babylonjs/Misc/observable";
  15302. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15303. import { Effect } from "babylonjs/Materials/effect";
  15304. import { Scene, IDisposable } from "babylonjs/scene";
  15305. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15306. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15307. import { Particle } from "babylonjs/Particles/particle";
  15308. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15309. import "babylonjs/Shaders/particles.fragment";
  15310. import "babylonjs/Shaders/particles.vertex";
  15311. /**
  15312. * This represents a particle system in Babylon.
  15313. * 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.
  15314. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15315. * @example https://doc.babylonjs.com/babylon101/particles
  15316. */
  15317. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15318. /**
  15319. * Billboard mode will only apply to Y axis
  15320. */
  15321. static readonly BILLBOARDMODE_Y: number;
  15322. /**
  15323. * Billboard mode will apply to all axes
  15324. */
  15325. static readonly BILLBOARDMODE_ALL: number;
  15326. /**
  15327. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15328. */
  15329. static readonly BILLBOARDMODE_STRETCHED: number;
  15330. /**
  15331. * This function can be defined to provide custom update for active particles.
  15332. * This function will be called instead of regular update (age, position, color, etc.).
  15333. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15334. */
  15335. updateFunction: (particles: Particle[]) => void;
  15336. private _emitterWorldMatrix;
  15337. /**
  15338. * This function can be defined to specify initial direction for every new particle.
  15339. * It by default use the emitterType defined function
  15340. */
  15341. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15342. /**
  15343. * This function can be defined to specify initial position for every new particle.
  15344. * It by default use the emitterType defined function
  15345. */
  15346. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15347. /**
  15348. * @hidden
  15349. */
  15350. _inheritedVelocityOffset: Vector3;
  15351. /**
  15352. * An event triggered when the system is disposed
  15353. */
  15354. onDisposeObservable: Observable<ParticleSystem>;
  15355. private _onDisposeObserver;
  15356. /**
  15357. * Sets a callback that will be triggered when the system is disposed
  15358. */
  15359. onDispose: () => void;
  15360. private _particles;
  15361. private _epsilon;
  15362. private _capacity;
  15363. private _stockParticles;
  15364. private _newPartsExcess;
  15365. private _vertexData;
  15366. private _vertexBuffer;
  15367. private _vertexBuffers;
  15368. private _spriteBuffer;
  15369. private _indexBuffer;
  15370. private _effect;
  15371. private _customEffect;
  15372. private _cachedDefines;
  15373. private _scaledColorStep;
  15374. private _colorDiff;
  15375. private _scaledDirection;
  15376. private _scaledGravity;
  15377. private _currentRenderId;
  15378. private _alive;
  15379. private _useInstancing;
  15380. private _started;
  15381. private _stopped;
  15382. private _actualFrame;
  15383. private _scaledUpdateSpeed;
  15384. private _vertexBufferSize;
  15385. /** @hidden */
  15386. _currentEmitRateGradient: Nullable<FactorGradient>;
  15387. /** @hidden */
  15388. _currentEmitRate1: number;
  15389. /** @hidden */
  15390. _currentEmitRate2: number;
  15391. /** @hidden */
  15392. _currentStartSizeGradient: Nullable<FactorGradient>;
  15393. /** @hidden */
  15394. _currentStartSize1: number;
  15395. /** @hidden */
  15396. _currentStartSize2: number;
  15397. private readonly _rawTextureWidth;
  15398. private _rampGradientsTexture;
  15399. private _useRampGradients;
  15400. /** Gets or sets a boolean indicating that ramp gradients must be used
  15401. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15402. */
  15403. useRampGradients: boolean;
  15404. /**
  15405. * 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.
  15406. * 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: [])
  15407. */
  15408. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15409. private _subEmitters;
  15410. /**
  15411. * @hidden
  15412. * If the particle systems emitter should be disposed when the particle system is disposed
  15413. */
  15414. _disposeEmitterOnDispose: boolean;
  15415. /**
  15416. * The current active Sub-systems, this property is used by the root particle system only.
  15417. */
  15418. activeSubSystems: Array<ParticleSystem>;
  15419. private _rootParticleSystem;
  15420. /**
  15421. * Gets the current list of active particles
  15422. */
  15423. readonly particles: Particle[];
  15424. /**
  15425. * Returns the string "ParticleSystem"
  15426. * @returns a string containing the class name
  15427. */
  15428. getClassName(): string;
  15429. /**
  15430. * Instantiates a particle system.
  15431. * 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.
  15432. * @param name The name of the particle system
  15433. * @param capacity The max number of particles alive at the same time
  15434. * @param scene The scene the particle system belongs to
  15435. * @param customEffect a custom effect used to change the way particles are rendered by default
  15436. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15437. * @param epsilon Offset used to render the particles
  15438. */
  15439. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15440. private _addFactorGradient;
  15441. private _removeFactorGradient;
  15442. /**
  15443. * Adds a new life time gradient
  15444. * @param gradient defines the gradient to use (between 0 and 1)
  15445. * @param factor defines the life time factor to affect to the specified gradient
  15446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15447. * @returns the current particle system
  15448. */
  15449. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15450. /**
  15451. * Remove a specific life time gradient
  15452. * @param gradient defines the gradient to remove
  15453. * @returns the current particle system
  15454. */
  15455. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15456. /**
  15457. * Adds a new size gradient
  15458. * @param gradient defines the gradient to use (between 0 and 1)
  15459. * @param factor defines the size factor to affect to the specified gradient
  15460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15461. * @returns the current particle system
  15462. */
  15463. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15464. /**
  15465. * Remove a specific size gradient
  15466. * @param gradient defines the gradient to remove
  15467. * @returns the current particle system
  15468. */
  15469. removeSizeGradient(gradient: number): IParticleSystem;
  15470. /**
  15471. * Adds a new color remap gradient
  15472. * @param gradient defines the gradient to use (between 0 and 1)
  15473. * @param min defines the color remap minimal range
  15474. * @param max defines the color remap maximal range
  15475. * @returns the current particle system
  15476. */
  15477. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15478. /**
  15479. * Remove a specific color remap gradient
  15480. * @param gradient defines the gradient to remove
  15481. * @returns the current particle system
  15482. */
  15483. removeColorRemapGradient(gradient: number): IParticleSystem;
  15484. /**
  15485. * Adds a new alpha remap gradient
  15486. * @param gradient defines the gradient to use (between 0 and 1)
  15487. * @param min defines the alpha remap minimal range
  15488. * @param max defines the alpha remap maximal range
  15489. * @returns the current particle system
  15490. */
  15491. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15492. /**
  15493. * Remove a specific alpha remap gradient
  15494. * @param gradient defines the gradient to remove
  15495. * @returns the current particle system
  15496. */
  15497. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15498. /**
  15499. * Adds a new angular speed gradient
  15500. * @param gradient defines the gradient to use (between 0 and 1)
  15501. * @param factor defines the angular speed to affect to the specified gradient
  15502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15503. * @returns the current particle system
  15504. */
  15505. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15506. /**
  15507. * Remove a specific angular speed gradient
  15508. * @param gradient defines the gradient to remove
  15509. * @returns the current particle system
  15510. */
  15511. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15512. /**
  15513. * Adds a new velocity gradient
  15514. * @param gradient defines the gradient to use (between 0 and 1)
  15515. * @param factor defines the velocity to affect to the specified gradient
  15516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15517. * @returns the current particle system
  15518. */
  15519. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15520. /**
  15521. * Remove a specific velocity gradient
  15522. * @param gradient defines the gradient to remove
  15523. * @returns the current particle system
  15524. */
  15525. removeVelocityGradient(gradient: number): IParticleSystem;
  15526. /**
  15527. * Adds a new limit velocity gradient
  15528. * @param gradient defines the gradient to use (between 0 and 1)
  15529. * @param factor defines the limit velocity value to affect to the specified gradient
  15530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15531. * @returns the current particle system
  15532. */
  15533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15534. /**
  15535. * Remove a specific limit velocity gradient
  15536. * @param gradient defines the gradient to remove
  15537. * @returns the current particle system
  15538. */
  15539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15540. /**
  15541. * Adds a new drag gradient
  15542. * @param gradient defines the gradient to use (between 0 and 1)
  15543. * @param factor defines the drag value to affect to the specified gradient
  15544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15545. * @returns the current particle system
  15546. */
  15547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15548. /**
  15549. * Remove a specific drag gradient
  15550. * @param gradient defines the gradient to remove
  15551. * @returns the current particle system
  15552. */
  15553. removeDragGradient(gradient: number): IParticleSystem;
  15554. /**
  15555. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15556. * @param gradient defines the gradient to use (between 0 and 1)
  15557. * @param factor defines the emit rate value to affect to the specified gradient
  15558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15559. * @returns the current particle system
  15560. */
  15561. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15562. /**
  15563. * Remove a specific emit rate gradient
  15564. * @param gradient defines the gradient to remove
  15565. * @returns the current particle system
  15566. */
  15567. removeEmitRateGradient(gradient: number): IParticleSystem;
  15568. /**
  15569. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15570. * @param gradient defines the gradient to use (between 0 and 1)
  15571. * @param factor defines the start size value to affect to the specified gradient
  15572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15573. * @returns the current particle system
  15574. */
  15575. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15576. /**
  15577. * Remove a specific start size gradient
  15578. * @param gradient defines the gradient to remove
  15579. * @returns the current particle system
  15580. */
  15581. removeStartSizeGradient(gradient: number): IParticleSystem;
  15582. private _createRampGradientTexture;
  15583. /**
  15584. * Gets the current list of ramp gradients.
  15585. * You must use addRampGradient and removeRampGradient to udpate this list
  15586. * @returns the list of ramp gradients
  15587. */
  15588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15589. /**
  15590. * Adds a new ramp gradient used to remap particle colors
  15591. * @param gradient defines the gradient to use (between 0 and 1)
  15592. * @param color defines the color to affect to the specified gradient
  15593. * @returns the current particle system
  15594. */
  15595. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15596. /**
  15597. * Remove a specific ramp gradient
  15598. * @param gradient defines the gradient to remove
  15599. * @returns the current particle system
  15600. */
  15601. removeRampGradient(gradient: number): ParticleSystem;
  15602. /**
  15603. * Adds a new color gradient
  15604. * @param gradient defines the gradient to use (between 0 and 1)
  15605. * @param color1 defines the color to affect to the specified gradient
  15606. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15607. * @returns this particle system
  15608. */
  15609. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15610. /**
  15611. * Remove a specific color gradient
  15612. * @param gradient defines the gradient to remove
  15613. * @returns this particle system
  15614. */
  15615. removeColorGradient(gradient: number): IParticleSystem;
  15616. private _fetchR;
  15617. protected _reset(): void;
  15618. private _resetEffect;
  15619. private _createVertexBuffers;
  15620. private _createIndexBuffer;
  15621. /**
  15622. * Gets the maximum number of particles active at the same time.
  15623. * @returns The max number of active particles.
  15624. */
  15625. getCapacity(): number;
  15626. /**
  15627. * Gets whether there are still active particles in the system.
  15628. * @returns True if it is alive, otherwise false.
  15629. */
  15630. isAlive(): boolean;
  15631. /**
  15632. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15633. * @returns True if it has been started, otherwise false.
  15634. */
  15635. isStarted(): boolean;
  15636. private _prepareSubEmitterInternalArray;
  15637. /**
  15638. * Starts the particle system and begins to emit
  15639. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15640. */
  15641. start(delay?: number): void;
  15642. /**
  15643. * Stops the particle system.
  15644. * @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.
  15645. */
  15646. stop(stopSubEmitters?: boolean): void;
  15647. /**
  15648. * Remove all active particles
  15649. */
  15650. reset(): void;
  15651. /**
  15652. * @hidden (for internal use only)
  15653. */
  15654. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15655. /**
  15656. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15657. * Its lifetime will start back at 0.
  15658. */
  15659. recycleParticle: (particle: Particle) => void;
  15660. private _stopSubEmitters;
  15661. private _createParticle;
  15662. private _removeFromRoot;
  15663. private _emitFromParticle;
  15664. private _update;
  15665. /** @hidden */
  15666. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15667. /** @hidden */
  15668. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15669. /** @hidden */
  15670. private _getEffect;
  15671. /**
  15672. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15673. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15674. */
  15675. animate(preWarmOnly?: boolean): void;
  15676. private _appendParticleVertices;
  15677. /**
  15678. * Rebuilds the particle system.
  15679. */
  15680. rebuild(): void;
  15681. /**
  15682. * Is this system ready to be used/rendered
  15683. * @return true if the system is ready
  15684. */
  15685. isReady(): boolean;
  15686. private _render;
  15687. /**
  15688. * Renders the particle system in its current state.
  15689. * @returns the current number of particles
  15690. */
  15691. render(): number;
  15692. /**
  15693. * Disposes the particle system and free the associated resources
  15694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15695. */
  15696. dispose(disposeTexture?: boolean): void;
  15697. /**
  15698. * Clones the particle system.
  15699. * @param name The name of the cloned object
  15700. * @param newEmitter The new emitter to use
  15701. * @returns the cloned particle system
  15702. */
  15703. clone(name: string, newEmitter: any): ParticleSystem;
  15704. /**
  15705. * Serializes the particle system to a JSON object.
  15706. * @returns the JSON object
  15707. */
  15708. serialize(): any;
  15709. /** @hidden */
  15710. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15711. /** @hidden */
  15712. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15713. /**
  15714. * Parses a JSON object to create a particle system.
  15715. * @param parsedParticleSystem The JSON object to parse
  15716. * @param scene The scene to create the particle system in
  15717. * @param rootUrl The root url to use to load external dependencies like texture
  15718. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15719. * @returns the Parsed particle system
  15720. */
  15721. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15722. }
  15723. }
  15724. declare module "babylonjs/Particles/particle" {
  15725. import { Nullable } from "babylonjs/types";
  15726. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15727. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15728. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15729. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15730. /**
  15731. * A particle represents one of the element emitted by a particle system.
  15732. * This is mainly define by its coordinates, direction, velocity and age.
  15733. */
  15734. export class Particle {
  15735. /**
  15736. * The particle system the particle belongs to.
  15737. */
  15738. particleSystem: ParticleSystem;
  15739. private static _Count;
  15740. /**
  15741. * Unique ID of the particle
  15742. */
  15743. id: number;
  15744. /**
  15745. * The world position of the particle in the scene.
  15746. */
  15747. position: Vector3;
  15748. /**
  15749. * The world direction of the particle in the scene.
  15750. */
  15751. direction: Vector3;
  15752. /**
  15753. * The color of the particle.
  15754. */
  15755. color: Color4;
  15756. /**
  15757. * The color change of the particle per step.
  15758. */
  15759. colorStep: Color4;
  15760. /**
  15761. * Defines how long will the life of the particle be.
  15762. */
  15763. lifeTime: number;
  15764. /**
  15765. * The current age of the particle.
  15766. */
  15767. age: number;
  15768. /**
  15769. * The current size of the particle.
  15770. */
  15771. size: number;
  15772. /**
  15773. * The current scale of the particle.
  15774. */
  15775. scale: Vector2;
  15776. /**
  15777. * The current angle of the particle.
  15778. */
  15779. angle: number;
  15780. /**
  15781. * Defines how fast is the angle changing.
  15782. */
  15783. angularSpeed: number;
  15784. /**
  15785. * Defines the cell index used by the particle to be rendered from a sprite.
  15786. */
  15787. cellIndex: number;
  15788. /**
  15789. * The information required to support color remapping
  15790. */
  15791. remapData: Vector4;
  15792. /** @hidden */
  15793. _randomCellOffset?: number;
  15794. /** @hidden */
  15795. _initialDirection: Nullable<Vector3>;
  15796. /** @hidden */
  15797. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15798. /** @hidden */
  15799. _initialStartSpriteCellID: number;
  15800. /** @hidden */
  15801. _initialEndSpriteCellID: number;
  15802. /** @hidden */
  15803. _currentColorGradient: Nullable<ColorGradient>;
  15804. /** @hidden */
  15805. _currentColor1: Color4;
  15806. /** @hidden */
  15807. _currentColor2: Color4;
  15808. /** @hidden */
  15809. _currentSizeGradient: Nullable<FactorGradient>;
  15810. /** @hidden */
  15811. _currentSize1: number;
  15812. /** @hidden */
  15813. _currentSize2: number;
  15814. /** @hidden */
  15815. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15816. /** @hidden */
  15817. _currentAngularSpeed1: number;
  15818. /** @hidden */
  15819. _currentAngularSpeed2: number;
  15820. /** @hidden */
  15821. _currentVelocityGradient: Nullable<FactorGradient>;
  15822. /** @hidden */
  15823. _currentVelocity1: number;
  15824. /** @hidden */
  15825. _currentVelocity2: number;
  15826. /** @hidden */
  15827. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15828. /** @hidden */
  15829. _currentLimitVelocity1: number;
  15830. /** @hidden */
  15831. _currentLimitVelocity2: number;
  15832. /** @hidden */
  15833. _currentDragGradient: Nullable<FactorGradient>;
  15834. /** @hidden */
  15835. _currentDrag1: number;
  15836. /** @hidden */
  15837. _currentDrag2: number;
  15838. /** @hidden */
  15839. _randomNoiseCoordinates1: Vector3;
  15840. /** @hidden */
  15841. _randomNoiseCoordinates2: Vector3;
  15842. /**
  15843. * Creates a new instance Particle
  15844. * @param particleSystem the particle system the particle belongs to
  15845. */
  15846. constructor(
  15847. /**
  15848. * The particle system the particle belongs to.
  15849. */
  15850. particleSystem: ParticleSystem);
  15851. private updateCellInfoFromSystem;
  15852. /**
  15853. * Defines how the sprite cell index is updated for the particle
  15854. */
  15855. updateCellIndex(): void;
  15856. /** @hidden */
  15857. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15858. /** @hidden */
  15859. _inheritParticleInfoToSubEmitters(): void;
  15860. /** @hidden */
  15861. _reset(): void;
  15862. /**
  15863. * Copy the properties of particle to another one.
  15864. * @param other the particle to copy the information to.
  15865. */
  15866. copyTo(other: Particle): void;
  15867. }
  15868. }
  15869. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15870. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15871. import { Effect } from "babylonjs/Materials/effect";
  15872. import { Particle } from "babylonjs/Particles/particle";
  15873. /**
  15874. * Particle emitter represents a volume emitting particles.
  15875. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15876. */
  15877. export interface IParticleEmitterType {
  15878. /**
  15879. * Called by the particle System when the direction is computed for the created particle.
  15880. * @param worldMatrix is the world matrix of the particle system
  15881. * @param directionToUpdate is the direction vector to update with the result
  15882. * @param particle is the particle we are computed the direction for
  15883. */
  15884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15885. /**
  15886. * Called by the particle System when the position is computed for the created particle.
  15887. * @param worldMatrix is the world matrix of the particle system
  15888. * @param positionToUpdate is the position vector to update with the result
  15889. * @param particle is the particle we are computed the position for
  15890. */
  15891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15892. /**
  15893. * Clones the current emitter and returns a copy of it
  15894. * @returns the new emitter
  15895. */
  15896. clone(): IParticleEmitterType;
  15897. /**
  15898. * Called by the GPUParticleSystem to setup the update shader
  15899. * @param effect defines the update shader
  15900. */
  15901. applyToShader(effect: Effect): void;
  15902. /**
  15903. * Returns a string to use to update the GPU particles update shader
  15904. * @returns the effect defines string
  15905. */
  15906. getEffectDefines(): string;
  15907. /**
  15908. * Returns a string representing the class name
  15909. * @returns a string containing the class name
  15910. */
  15911. getClassName(): string;
  15912. /**
  15913. * Serializes the particle system to a JSON object.
  15914. * @returns the JSON object
  15915. */
  15916. serialize(): any;
  15917. /**
  15918. * Parse properties from a JSON object
  15919. * @param serializationObject defines the JSON object
  15920. */
  15921. parse(serializationObject: any): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15925. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15926. import { Effect } from "babylonjs/Materials/effect";
  15927. import { Particle } from "babylonjs/Particles/particle";
  15928. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15929. /**
  15930. * Particle emitter emitting particles from the inside of a box.
  15931. * It emits the particles randomly between 2 given directions.
  15932. */
  15933. export class BoxParticleEmitter implements IParticleEmitterType {
  15934. /**
  15935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15936. */
  15937. direction1: Vector3;
  15938. /**
  15939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15940. */
  15941. direction2: Vector3;
  15942. /**
  15943. * 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.
  15944. */
  15945. minEmitBox: Vector3;
  15946. /**
  15947. * 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.
  15948. */
  15949. maxEmitBox: Vector3;
  15950. /**
  15951. * Creates a new instance BoxParticleEmitter
  15952. */
  15953. constructor();
  15954. /**
  15955. * Called by the particle System when the direction is computed for the created particle.
  15956. * @param worldMatrix is the world matrix of the particle system
  15957. * @param directionToUpdate is the direction vector to update with the result
  15958. * @param particle is the particle we are computed the direction for
  15959. */
  15960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15961. /**
  15962. * Called by the particle System when the position is computed for the created particle.
  15963. * @param worldMatrix is the world matrix of the particle system
  15964. * @param positionToUpdate is the position vector to update with the result
  15965. * @param particle is the particle we are computed the position for
  15966. */
  15967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15968. /**
  15969. * Clones the current emitter and returns a copy of it
  15970. * @returns the new emitter
  15971. */
  15972. clone(): BoxParticleEmitter;
  15973. /**
  15974. * Called by the GPUParticleSystem to setup the update shader
  15975. * @param effect defines the update shader
  15976. */
  15977. applyToShader(effect: Effect): void;
  15978. /**
  15979. * Returns a string to use to update the GPU particles update shader
  15980. * @returns a string containng the defines string
  15981. */
  15982. getEffectDefines(): string;
  15983. /**
  15984. * Returns the string "BoxParticleEmitter"
  15985. * @returns a string containing the class name
  15986. */
  15987. getClassName(): string;
  15988. /**
  15989. * Serializes the particle system to a JSON object.
  15990. * @returns the JSON object
  15991. */
  15992. serialize(): any;
  15993. /**
  15994. * Parse properties from a JSON object
  15995. * @param serializationObject defines the JSON object
  15996. */
  15997. parse(serializationObject: any): void;
  15998. }
  15999. }
  16000. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16001. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16002. import { Effect } from "babylonjs/Materials/effect";
  16003. import { Particle } from "babylonjs/Particles/particle";
  16004. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16005. /**
  16006. * Particle emitter emitting particles from the inside of a cone.
  16007. * It emits the particles alongside the cone volume from the base to the particle.
  16008. * The emission direction might be randomized.
  16009. */
  16010. export class ConeParticleEmitter implements IParticleEmitterType {
  16011. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16012. directionRandomizer: number;
  16013. private _radius;
  16014. private _angle;
  16015. private _height;
  16016. /**
  16017. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16018. */
  16019. radiusRange: number;
  16020. /**
  16021. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16022. */
  16023. heightRange: number;
  16024. /**
  16025. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16026. */
  16027. emitFromSpawnPointOnly: boolean;
  16028. /**
  16029. * Gets or sets the radius of the emission cone
  16030. */
  16031. radius: number;
  16032. /**
  16033. * Gets or sets the angle of the emission cone
  16034. */
  16035. angle: number;
  16036. private _buildHeight;
  16037. /**
  16038. * Creates a new instance ConeParticleEmitter
  16039. * @param radius the radius of the emission cone (1 by default)
  16040. * @param angle the cone base angle (PI by default)
  16041. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16042. */
  16043. constructor(radius?: number, angle?: number,
  16044. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16045. directionRandomizer?: number);
  16046. /**
  16047. * Called by the particle System when the direction is computed for the created particle.
  16048. * @param worldMatrix is the world matrix of the particle system
  16049. * @param directionToUpdate is the direction vector to update with the result
  16050. * @param particle is the particle we are computed the direction for
  16051. */
  16052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16053. /**
  16054. * Called by the particle System when the position is computed for the created particle.
  16055. * @param worldMatrix is the world matrix of the particle system
  16056. * @param positionToUpdate is the position vector to update with the result
  16057. * @param particle is the particle we are computed the position for
  16058. */
  16059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16060. /**
  16061. * Clones the current emitter and returns a copy of it
  16062. * @returns the new emitter
  16063. */
  16064. clone(): ConeParticleEmitter;
  16065. /**
  16066. * Called by the GPUParticleSystem to setup the update shader
  16067. * @param effect defines the update shader
  16068. */
  16069. applyToShader(effect: Effect): void;
  16070. /**
  16071. * Returns a string to use to update the GPU particles update shader
  16072. * @returns a string containng the defines string
  16073. */
  16074. getEffectDefines(): string;
  16075. /**
  16076. * Returns the string "ConeParticleEmitter"
  16077. * @returns a string containing the class name
  16078. */
  16079. getClassName(): string;
  16080. /**
  16081. * Serializes the particle system to a JSON object.
  16082. * @returns the JSON object
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Parse properties from a JSON object
  16087. * @param serializationObject defines the JSON object
  16088. */
  16089. parse(serializationObject: any): void;
  16090. }
  16091. }
  16092. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16093. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16094. import { Effect } from "babylonjs/Materials/effect";
  16095. import { Particle } from "babylonjs/Particles/particle";
  16096. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16097. /**
  16098. * Particle emitter emitting particles from the inside of a cylinder.
  16099. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16100. */
  16101. export class CylinderParticleEmitter implements IParticleEmitterType {
  16102. /**
  16103. * The radius of the emission cylinder.
  16104. */
  16105. radius: number;
  16106. /**
  16107. * The height of the emission cylinder.
  16108. */
  16109. height: number;
  16110. /**
  16111. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16112. */
  16113. radiusRange: number;
  16114. /**
  16115. * How much to randomize the particle direction [0-1].
  16116. */
  16117. directionRandomizer: number;
  16118. /**
  16119. * Creates a new instance CylinderParticleEmitter
  16120. * @param radius the radius of the emission cylinder (1 by default)
  16121. * @param height the height of the emission cylinder (1 by default)
  16122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16123. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16124. */
  16125. constructor(
  16126. /**
  16127. * The radius of the emission cylinder.
  16128. */
  16129. radius?: number,
  16130. /**
  16131. * The height of the emission cylinder.
  16132. */
  16133. height?: number,
  16134. /**
  16135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16136. */
  16137. radiusRange?: number,
  16138. /**
  16139. * How much to randomize the particle direction [0-1].
  16140. */
  16141. directionRandomizer?: number);
  16142. /**
  16143. * Called by the particle System when the direction is computed for the created particle.
  16144. * @param worldMatrix is the world matrix of the particle system
  16145. * @param directionToUpdate is the direction vector to update with the result
  16146. * @param particle is the particle we are computed the direction for
  16147. */
  16148. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16149. /**
  16150. * Called by the particle System when the position is computed for the created particle.
  16151. * @param worldMatrix is the world matrix of the particle system
  16152. * @param positionToUpdate is the position vector to update with the result
  16153. * @param particle is the particle we are computed the position for
  16154. */
  16155. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16156. /**
  16157. * Clones the current emitter and returns a copy of it
  16158. * @returns the new emitter
  16159. */
  16160. clone(): CylinderParticleEmitter;
  16161. /**
  16162. * Called by the GPUParticleSystem to setup the update shader
  16163. * @param effect defines the update shader
  16164. */
  16165. applyToShader(effect: Effect): void;
  16166. /**
  16167. * Returns a string to use to update the GPU particles update shader
  16168. * @returns a string containng the defines string
  16169. */
  16170. getEffectDefines(): string;
  16171. /**
  16172. * Returns the string "CylinderParticleEmitter"
  16173. * @returns a string containing the class name
  16174. */
  16175. getClassName(): string;
  16176. /**
  16177. * Serializes the particle system to a JSON object.
  16178. * @returns the JSON object
  16179. */
  16180. serialize(): any;
  16181. /**
  16182. * Parse properties from a JSON object
  16183. * @param serializationObject defines the JSON object
  16184. */
  16185. parse(serializationObject: any): void;
  16186. }
  16187. /**
  16188. * Particle emitter emitting particles from the inside of a cylinder.
  16189. * It emits the particles randomly between two vectors.
  16190. */
  16191. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16192. /**
  16193. * The min limit of the emission direction.
  16194. */
  16195. direction1: Vector3;
  16196. /**
  16197. * The max limit of the emission direction.
  16198. */
  16199. direction2: Vector3;
  16200. /**
  16201. * Creates a new instance CylinderDirectedParticleEmitter
  16202. * @param radius the radius of the emission cylinder (1 by default)
  16203. * @param height the height of the emission cylinder (1 by default)
  16204. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16205. * @param direction1 the min limit of the emission direction (up vector by default)
  16206. * @param direction2 the max limit of the emission direction (up vector by default)
  16207. */
  16208. constructor(radius?: number, height?: number, radiusRange?: number,
  16209. /**
  16210. * The min limit of the emission direction.
  16211. */
  16212. direction1?: Vector3,
  16213. /**
  16214. * The max limit of the emission direction.
  16215. */
  16216. direction2?: Vector3);
  16217. /**
  16218. * Called by the particle System when the direction is computed for the created particle.
  16219. * @param worldMatrix is the world matrix of the particle system
  16220. * @param directionToUpdate is the direction vector to update with the result
  16221. * @param particle is the particle we are computed the direction for
  16222. */
  16223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16224. /**
  16225. * Clones the current emitter and returns a copy of it
  16226. * @returns the new emitter
  16227. */
  16228. clone(): CylinderDirectedParticleEmitter;
  16229. /**
  16230. * Called by the GPUParticleSystem to setup the update shader
  16231. * @param effect defines the update shader
  16232. */
  16233. applyToShader(effect: Effect): void;
  16234. /**
  16235. * Returns a string to use to update the GPU particles update shader
  16236. * @returns a string containng the defines string
  16237. */
  16238. getEffectDefines(): string;
  16239. /**
  16240. * Returns the string "CylinderDirectedParticleEmitter"
  16241. * @returns a string containing the class name
  16242. */
  16243. getClassName(): string;
  16244. /**
  16245. * Serializes the particle system to a JSON object.
  16246. * @returns the JSON object
  16247. */
  16248. serialize(): any;
  16249. /**
  16250. * Parse properties from a JSON object
  16251. * @param serializationObject defines the JSON object
  16252. */
  16253. parse(serializationObject: any): void;
  16254. }
  16255. }
  16256. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16257. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16258. import { Effect } from "babylonjs/Materials/effect";
  16259. import { Particle } from "babylonjs/Particles/particle";
  16260. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16261. /**
  16262. * Particle emitter emitting particles from the inside of a hemisphere.
  16263. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16264. */
  16265. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16266. /**
  16267. * The radius of the emission hemisphere.
  16268. */
  16269. radius: number;
  16270. /**
  16271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16272. */
  16273. radiusRange: number;
  16274. /**
  16275. * How much to randomize the particle direction [0-1].
  16276. */
  16277. directionRandomizer: number;
  16278. /**
  16279. * Creates a new instance HemisphericParticleEmitter
  16280. * @param radius the radius of the emission hemisphere (1 by default)
  16281. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16282. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16283. */
  16284. constructor(
  16285. /**
  16286. * The radius of the emission hemisphere.
  16287. */
  16288. radius?: number,
  16289. /**
  16290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16291. */
  16292. radiusRange?: number,
  16293. /**
  16294. * How much to randomize the particle direction [0-1].
  16295. */
  16296. directionRandomizer?: number);
  16297. /**
  16298. * Called by the particle System when the direction is computed for the created particle.
  16299. * @param worldMatrix is the world matrix of the particle system
  16300. * @param directionToUpdate is the direction vector to update with the result
  16301. * @param particle is the particle we are computed the direction for
  16302. */
  16303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16304. /**
  16305. * Called by the particle System when the position is computed for the created particle.
  16306. * @param worldMatrix is the world matrix of the particle system
  16307. * @param positionToUpdate is the position vector to update with the result
  16308. * @param particle is the particle we are computed the position for
  16309. */
  16310. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16311. /**
  16312. * Clones the current emitter and returns a copy of it
  16313. * @returns the new emitter
  16314. */
  16315. clone(): HemisphericParticleEmitter;
  16316. /**
  16317. * Called by the GPUParticleSystem to setup the update shader
  16318. * @param effect defines the update shader
  16319. */
  16320. applyToShader(effect: Effect): void;
  16321. /**
  16322. * Returns a string to use to update the GPU particles update shader
  16323. * @returns a string containng the defines string
  16324. */
  16325. getEffectDefines(): string;
  16326. /**
  16327. * Returns the string "HemisphericParticleEmitter"
  16328. * @returns a string containing the class name
  16329. */
  16330. getClassName(): string;
  16331. /**
  16332. * Serializes the particle system to a JSON object.
  16333. * @returns the JSON object
  16334. */
  16335. serialize(): any;
  16336. /**
  16337. * Parse properties from a JSON object
  16338. * @param serializationObject defines the JSON object
  16339. */
  16340. parse(serializationObject: any): void;
  16341. }
  16342. }
  16343. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16344. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16345. import { Effect } from "babylonjs/Materials/effect";
  16346. import { Particle } from "babylonjs/Particles/particle";
  16347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16348. /**
  16349. * Particle emitter emitting particles from a point.
  16350. * It emits the particles randomly between 2 given directions.
  16351. */
  16352. export class PointParticleEmitter implements IParticleEmitterType {
  16353. /**
  16354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16355. */
  16356. direction1: Vector3;
  16357. /**
  16358. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16359. */
  16360. direction2: Vector3;
  16361. /**
  16362. * Creates a new instance PointParticleEmitter
  16363. */
  16364. constructor();
  16365. /**
  16366. * Called by the particle System when the direction is computed for the created particle.
  16367. * @param worldMatrix is the world matrix of the particle system
  16368. * @param directionToUpdate is the direction vector to update with the result
  16369. * @param particle is the particle we are computed the direction for
  16370. */
  16371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16372. /**
  16373. * Called by the particle System when the position is computed for the created particle.
  16374. * @param worldMatrix is the world matrix of the particle system
  16375. * @param positionToUpdate is the position vector to update with the result
  16376. * @param particle is the particle we are computed the position for
  16377. */
  16378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16379. /**
  16380. * Clones the current emitter and returns a copy of it
  16381. * @returns the new emitter
  16382. */
  16383. clone(): PointParticleEmitter;
  16384. /**
  16385. * Called by the GPUParticleSystem to setup the update shader
  16386. * @param effect defines the update shader
  16387. */
  16388. applyToShader(effect: Effect): void;
  16389. /**
  16390. * Returns a string to use to update the GPU particles update shader
  16391. * @returns a string containng the defines string
  16392. */
  16393. getEffectDefines(): string;
  16394. /**
  16395. * Returns the string "PointParticleEmitter"
  16396. * @returns a string containing the class name
  16397. */
  16398. getClassName(): string;
  16399. /**
  16400. * Serializes the particle system to a JSON object.
  16401. * @returns the JSON object
  16402. */
  16403. serialize(): any;
  16404. /**
  16405. * Parse properties from a JSON object
  16406. * @param serializationObject defines the JSON object
  16407. */
  16408. parse(serializationObject: any): void;
  16409. }
  16410. }
  16411. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16412. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16413. import { Effect } from "babylonjs/Materials/effect";
  16414. import { Particle } from "babylonjs/Particles/particle";
  16415. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16416. /**
  16417. * Particle emitter emitting particles from the inside of a sphere.
  16418. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16419. */
  16420. export class SphereParticleEmitter implements IParticleEmitterType {
  16421. /**
  16422. * The radius of the emission sphere.
  16423. */
  16424. radius: number;
  16425. /**
  16426. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16427. */
  16428. radiusRange: number;
  16429. /**
  16430. * How much to randomize the particle direction [0-1].
  16431. */
  16432. directionRandomizer: number;
  16433. /**
  16434. * Creates a new instance SphereParticleEmitter
  16435. * @param radius the radius of the emission sphere (1 by default)
  16436. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16437. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16438. */
  16439. constructor(
  16440. /**
  16441. * The radius of the emission sphere.
  16442. */
  16443. radius?: number,
  16444. /**
  16445. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16446. */
  16447. radiusRange?: number,
  16448. /**
  16449. * How much to randomize the particle direction [0-1].
  16450. */
  16451. directionRandomizer?: number);
  16452. /**
  16453. * Called by the particle System when the direction is computed for the created particle.
  16454. * @param worldMatrix is the world matrix of the particle system
  16455. * @param directionToUpdate is the direction vector to update with the result
  16456. * @param particle is the particle we are computed the direction for
  16457. */
  16458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16459. /**
  16460. * Called by the particle System when the position is computed for the created particle.
  16461. * @param worldMatrix is the world matrix of the particle system
  16462. * @param positionToUpdate is the position vector to update with the result
  16463. * @param particle is the particle we are computed the position for
  16464. */
  16465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16466. /**
  16467. * Clones the current emitter and returns a copy of it
  16468. * @returns the new emitter
  16469. */
  16470. clone(): SphereParticleEmitter;
  16471. /**
  16472. * Called by the GPUParticleSystem to setup the update shader
  16473. * @param effect defines the update shader
  16474. */
  16475. applyToShader(effect: Effect): void;
  16476. /**
  16477. * Returns a string to use to update the GPU particles update shader
  16478. * @returns a string containng the defines string
  16479. */
  16480. getEffectDefines(): string;
  16481. /**
  16482. * Returns the string "SphereParticleEmitter"
  16483. * @returns a string containing the class name
  16484. */
  16485. getClassName(): string;
  16486. /**
  16487. * Serializes the particle system to a JSON object.
  16488. * @returns the JSON object
  16489. */
  16490. serialize(): any;
  16491. /**
  16492. * Parse properties from a JSON object
  16493. * @param serializationObject defines the JSON object
  16494. */
  16495. parse(serializationObject: any): void;
  16496. }
  16497. /**
  16498. * Particle emitter emitting particles from the inside of a sphere.
  16499. * It emits the particles randomly between two vectors.
  16500. */
  16501. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16502. /**
  16503. * The min limit of the emission direction.
  16504. */
  16505. direction1: Vector3;
  16506. /**
  16507. * The max limit of the emission direction.
  16508. */
  16509. direction2: Vector3;
  16510. /**
  16511. * Creates a new instance SphereDirectedParticleEmitter
  16512. * @param radius the radius of the emission sphere (1 by default)
  16513. * @param direction1 the min limit of the emission direction (up vector by default)
  16514. * @param direction2 the max limit of the emission direction (up vector by default)
  16515. */
  16516. constructor(radius?: number,
  16517. /**
  16518. * The min limit of the emission direction.
  16519. */
  16520. direction1?: Vector3,
  16521. /**
  16522. * The max limit of the emission direction.
  16523. */
  16524. direction2?: Vector3);
  16525. /**
  16526. * Called by the particle System when the direction is computed for the created particle.
  16527. * @param worldMatrix is the world matrix of the particle system
  16528. * @param directionToUpdate is the direction vector to update with the result
  16529. * @param particle is the particle we are computed the direction for
  16530. */
  16531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16532. /**
  16533. * Clones the current emitter and returns a copy of it
  16534. * @returns the new emitter
  16535. */
  16536. clone(): SphereDirectedParticleEmitter;
  16537. /**
  16538. * Called by the GPUParticleSystem to setup the update shader
  16539. * @param effect defines the update shader
  16540. */
  16541. applyToShader(effect: Effect): void;
  16542. /**
  16543. * Returns a string to use to update the GPU particles update shader
  16544. * @returns a string containng the defines string
  16545. */
  16546. getEffectDefines(): string;
  16547. /**
  16548. * Returns the string "SphereDirectedParticleEmitter"
  16549. * @returns a string containing the class name
  16550. */
  16551. getClassName(): string;
  16552. /**
  16553. * Serializes the particle system to a JSON object.
  16554. * @returns the JSON object
  16555. */
  16556. serialize(): any;
  16557. /**
  16558. * Parse properties from a JSON object
  16559. * @param serializationObject defines the JSON object
  16560. */
  16561. parse(serializationObject: any): void;
  16562. }
  16563. }
  16564. declare module "babylonjs/Particles/EmitterTypes/index" {
  16565. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16569. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16570. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16571. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16572. }
  16573. declare module "babylonjs/Particles/IParticleSystem" {
  16574. import { Nullable } from "babylonjs/types";
  16575. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16578. import { Texture } from "babylonjs/Materials/Textures/texture";
  16579. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16580. import { Scene } from "babylonjs/scene";
  16581. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16582. import { Animation } from "babylonjs/Animations/animation";
  16583. /**
  16584. * Interface representing a particle system in Babylon.js.
  16585. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16586. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16587. */
  16588. export interface IParticleSystem {
  16589. /**
  16590. * List of animations used by the particle system.
  16591. */
  16592. animations: Animation[];
  16593. /**
  16594. * The id of the Particle system.
  16595. */
  16596. id: string;
  16597. /**
  16598. * The name of the Particle system.
  16599. */
  16600. name: string;
  16601. /**
  16602. * The emitter represents the Mesh or position we are attaching the particle system to.
  16603. */
  16604. emitter: Nullable<AbstractMesh | Vector3>;
  16605. /**
  16606. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16607. */
  16608. isBillboardBased: boolean;
  16609. /**
  16610. * The rendering group used by the Particle system to chose when to render.
  16611. */
  16612. renderingGroupId: number;
  16613. /**
  16614. * The layer mask we are rendering the particles through.
  16615. */
  16616. layerMask: number;
  16617. /**
  16618. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16619. */
  16620. updateSpeed: number;
  16621. /**
  16622. * The amount of time the particle system is running (depends of the overall update speed).
  16623. */
  16624. targetStopDuration: number;
  16625. /**
  16626. * The texture used to render each particle. (this can be a spritesheet)
  16627. */
  16628. particleTexture: Nullable<Texture>;
  16629. /**
  16630. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16631. */
  16632. blendMode: number;
  16633. /**
  16634. * Minimum life time of emitting particles.
  16635. */
  16636. minLifeTime: number;
  16637. /**
  16638. * Maximum life time of emitting particles.
  16639. */
  16640. maxLifeTime: number;
  16641. /**
  16642. * Minimum Size of emitting particles.
  16643. */
  16644. minSize: number;
  16645. /**
  16646. * Maximum Size of emitting particles.
  16647. */
  16648. maxSize: number;
  16649. /**
  16650. * Minimum scale of emitting particles on X axis.
  16651. */
  16652. minScaleX: number;
  16653. /**
  16654. * Maximum scale of emitting particles on X axis.
  16655. */
  16656. maxScaleX: number;
  16657. /**
  16658. * Minimum scale of emitting particles on Y axis.
  16659. */
  16660. minScaleY: number;
  16661. /**
  16662. * Maximum scale of emitting particles on Y axis.
  16663. */
  16664. maxScaleY: number;
  16665. /**
  16666. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16667. */
  16668. color1: Color4;
  16669. /**
  16670. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16671. */
  16672. color2: Color4;
  16673. /**
  16674. * Color the particle will have at the end of its lifetime.
  16675. */
  16676. colorDead: Color4;
  16677. /**
  16678. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16679. */
  16680. emitRate: number;
  16681. /**
  16682. * You can use gravity if you want to give an orientation to your particles.
  16683. */
  16684. gravity: Vector3;
  16685. /**
  16686. * Minimum power of emitting particles.
  16687. */
  16688. minEmitPower: number;
  16689. /**
  16690. * Maximum power of emitting particles.
  16691. */
  16692. maxEmitPower: number;
  16693. /**
  16694. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16695. */
  16696. minAngularSpeed: number;
  16697. /**
  16698. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16699. */
  16700. maxAngularSpeed: number;
  16701. /**
  16702. * Gets or sets the minimal initial rotation in radians.
  16703. */
  16704. minInitialRotation: number;
  16705. /**
  16706. * Gets or sets the maximal initial rotation in radians.
  16707. */
  16708. maxInitialRotation: number;
  16709. /**
  16710. * The particle emitter type defines the emitter used by the particle system.
  16711. * It can be for example box, sphere, or cone...
  16712. */
  16713. particleEmitterType: Nullable<IParticleEmitterType>;
  16714. /**
  16715. * Defines the delay in milliseconds before starting the system (0 by default)
  16716. */
  16717. startDelay: number;
  16718. /**
  16719. * 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
  16720. */
  16721. preWarmCycles: number;
  16722. /**
  16723. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16724. */
  16725. preWarmStepOffset: number;
  16726. /**
  16727. * 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)
  16728. */
  16729. spriteCellChangeSpeed: number;
  16730. /**
  16731. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16732. */
  16733. startSpriteCellID: number;
  16734. /**
  16735. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16736. */
  16737. endSpriteCellID: number;
  16738. /**
  16739. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16740. */
  16741. spriteCellWidth: number;
  16742. /**
  16743. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16744. */
  16745. spriteCellHeight: number;
  16746. /**
  16747. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16748. */
  16749. spriteRandomStartCell: boolean;
  16750. /**
  16751. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16752. */
  16753. isAnimationSheetEnabled: boolean;
  16754. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16755. translationPivot: Vector2;
  16756. /**
  16757. * Gets or sets a texture used to add random noise to particle positions
  16758. */
  16759. noiseTexture: Nullable<BaseTexture>;
  16760. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16761. noiseStrength: Vector3;
  16762. /**
  16763. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16764. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16765. */
  16766. billboardMode: number;
  16767. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16768. limitVelocityDamping: number;
  16769. /**
  16770. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16771. */
  16772. beginAnimationOnStart: boolean;
  16773. /**
  16774. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16775. */
  16776. beginAnimationFrom: number;
  16777. /**
  16778. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16779. */
  16780. beginAnimationTo: number;
  16781. /**
  16782. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16783. */
  16784. beginAnimationLoop: boolean;
  16785. /**
  16786. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16787. */
  16788. disposeOnStop: boolean;
  16789. /**
  16790. * Gets the maximum number of particles active at the same time.
  16791. * @returns The max number of active particles.
  16792. */
  16793. getCapacity(): number;
  16794. /**
  16795. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16796. * @returns True if it has been started, otherwise false.
  16797. */
  16798. isStarted(): boolean;
  16799. /**
  16800. * Animates the particle system for this frame.
  16801. */
  16802. animate(): void;
  16803. /**
  16804. * Renders the particle system in its current state.
  16805. * @returns the current number of particles
  16806. */
  16807. render(): number;
  16808. /**
  16809. * Dispose the particle system and frees its associated resources.
  16810. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16811. */
  16812. dispose(disposeTexture?: boolean): void;
  16813. /**
  16814. * Clones the particle system.
  16815. * @param name The name of the cloned object
  16816. * @param newEmitter The new emitter to use
  16817. * @returns the cloned particle system
  16818. */
  16819. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16820. /**
  16821. * Serializes the particle system to a JSON object.
  16822. * @returns the JSON object
  16823. */
  16824. serialize(): any;
  16825. /**
  16826. * Rebuild the particle system
  16827. */
  16828. rebuild(): void;
  16829. /**
  16830. * Starts the particle system and begins to emit
  16831. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16832. */
  16833. start(delay?: number): void;
  16834. /**
  16835. * Stops the particle system.
  16836. */
  16837. stop(): void;
  16838. /**
  16839. * Remove all active particles
  16840. */
  16841. reset(): void;
  16842. /**
  16843. * Is this system ready to be used/rendered
  16844. * @return true if the system is ready
  16845. */
  16846. isReady(): boolean;
  16847. /**
  16848. * Adds a new color gradient
  16849. * @param gradient defines the gradient to use (between 0 and 1)
  16850. * @param color1 defines the color to affect to the specified gradient
  16851. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16852. * @returns the current particle system
  16853. */
  16854. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16855. /**
  16856. * Remove a specific color gradient
  16857. * @param gradient defines the gradient to remove
  16858. * @returns the current particle system
  16859. */
  16860. removeColorGradient(gradient: number): IParticleSystem;
  16861. /**
  16862. * Adds a new size gradient
  16863. * @param gradient defines the gradient to use (between 0 and 1)
  16864. * @param factor defines the size factor to affect to the specified gradient
  16865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16866. * @returns the current particle system
  16867. */
  16868. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16869. /**
  16870. * Remove a specific size gradient
  16871. * @param gradient defines the gradient to remove
  16872. * @returns the current particle system
  16873. */
  16874. removeSizeGradient(gradient: number): IParticleSystem;
  16875. /**
  16876. * Gets the current list of color gradients.
  16877. * You must use addColorGradient and removeColorGradient to udpate this list
  16878. * @returns the list of color gradients
  16879. */
  16880. getColorGradients(): Nullable<Array<ColorGradient>>;
  16881. /**
  16882. * Gets the current list of size gradients.
  16883. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16884. * @returns the list of size gradients
  16885. */
  16886. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Gets the current list of angular speed gradients.
  16889. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16890. * @returns the list of angular speed gradients
  16891. */
  16892. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16893. /**
  16894. * Adds a new angular speed gradient
  16895. * @param gradient defines the gradient to use (between 0 and 1)
  16896. * @param factor defines the angular speed to affect to the specified gradient
  16897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16898. * @returns the current particle system
  16899. */
  16900. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16901. /**
  16902. * Remove a specific angular speed gradient
  16903. * @param gradient defines the gradient to remove
  16904. * @returns the current particle system
  16905. */
  16906. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16907. /**
  16908. * Gets the current list of velocity gradients.
  16909. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16910. * @returns the list of velocity gradients
  16911. */
  16912. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Adds a new velocity gradient
  16915. * @param gradient defines the gradient to use (between 0 and 1)
  16916. * @param factor defines the velocity to affect to the specified gradient
  16917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16918. * @returns the current particle system
  16919. */
  16920. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16921. /**
  16922. * Remove a specific velocity gradient
  16923. * @param gradient defines the gradient to remove
  16924. * @returns the current particle system
  16925. */
  16926. removeVelocityGradient(gradient: number): IParticleSystem;
  16927. /**
  16928. * Gets the current list of limit velocity gradients.
  16929. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16930. * @returns the list of limit velocity gradients
  16931. */
  16932. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Adds a new limit velocity gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the limit velocity to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific limit velocity gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new drag gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the drag to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific drag gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeDragGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Gets the current list of drag gradients.
  16963. * You must use addDragGradient and removeDragGradient to udpate this list
  16964. * @returns the list of drag gradients
  16965. */
  16966. getDragGradients(): Nullable<Array<FactorGradient>>;
  16967. /**
  16968. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the emit rate to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific emit rate gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeEmitRateGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Gets the current list of emit rate gradients.
  16983. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16984. * @returns the list of emit rate gradients
  16985. */
  16986. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16987. /**
  16988. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16989. * @param gradient defines the gradient to use (between 0 and 1)
  16990. * @param factor defines the start size to affect to the specified gradient
  16991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16992. * @returns the current particle system
  16993. */
  16994. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16995. /**
  16996. * Remove a specific start size gradient
  16997. * @param gradient defines the gradient to remove
  16998. * @returns the current particle system
  16999. */
  17000. removeStartSizeGradient(gradient: number): IParticleSystem;
  17001. /**
  17002. * Gets the current list of start size gradients.
  17003. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17004. * @returns the list of start size gradients
  17005. */
  17006. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17007. /**
  17008. * Adds a new life time gradient
  17009. * @param gradient defines the gradient to use (between 0 and 1)
  17010. * @param factor defines the life time factor to affect to the specified gradient
  17011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17012. * @returns the current particle system
  17013. */
  17014. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17015. /**
  17016. * Remove a specific life time gradient
  17017. * @param gradient defines the gradient to remove
  17018. * @returns the current particle system
  17019. */
  17020. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17021. /**
  17022. * Gets the current list of life time gradients.
  17023. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17024. * @returns the list of life time gradients
  17025. */
  17026. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17027. /**
  17028. * Gets the current list of color gradients.
  17029. * You must use addColorGradient and removeColorGradient to udpate this list
  17030. * @returns the list of color gradients
  17031. */
  17032. getColorGradients(): Nullable<Array<ColorGradient>>;
  17033. /**
  17034. * Adds a new ramp gradient used to remap particle colors
  17035. * @param gradient defines the gradient to use (between 0 and 1)
  17036. * @param color defines the color to affect to the specified gradient
  17037. * @returns the current particle system
  17038. */
  17039. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17040. /**
  17041. * Gets the current list of ramp gradients.
  17042. * You must use addRampGradient and removeRampGradient to udpate this list
  17043. * @returns the list of ramp gradients
  17044. */
  17045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17046. /** Gets or sets a boolean indicating that ramp gradients must be used
  17047. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17048. */
  17049. useRampGradients: boolean;
  17050. /**
  17051. * Adds a new color remap gradient
  17052. * @param gradient defines the gradient to use (between 0 and 1)
  17053. * @param min defines the color remap minimal range
  17054. * @param max defines the color remap maximal range
  17055. * @returns the current particle system
  17056. */
  17057. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17058. /**
  17059. * Gets the current list of color remap gradients.
  17060. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17061. * @returns the list of color remap gradients
  17062. */
  17063. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Adds a new alpha remap gradient
  17066. * @param gradient defines the gradient to use (between 0 and 1)
  17067. * @param min defines the alpha remap minimal range
  17068. * @param max defines the alpha remap maximal range
  17069. * @returns the current particle system
  17070. */
  17071. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17072. /**
  17073. * Gets the current list of alpha remap gradients.
  17074. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17075. * @returns the list of alpha remap gradients
  17076. */
  17077. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17078. /**
  17079. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @returns the emitter
  17083. */
  17084. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17085. /**
  17086. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17087. * @param radius The radius of the hemisphere to emit from
  17088. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17089. * @returns the emitter
  17090. */
  17091. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17092. /**
  17093. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17094. * @param radius The radius of the sphere to emit from
  17095. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17096. * @returns the emitter
  17097. */
  17098. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17099. /**
  17100. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17101. * @param radius The radius of the sphere to emit from
  17102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17104. * @returns the emitter
  17105. */
  17106. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17107. /**
  17108. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17109. * @param radius The radius of the emission cylinder
  17110. * @param height The height of the emission cylinder
  17111. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17112. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17113. * @returns the emitter
  17114. */
  17115. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17116. /**
  17117. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17118. * @param radius The radius of the cylinder to emit from
  17119. * @param height The height of the emission cylinder
  17120. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17123. * @returns the emitter
  17124. */
  17125. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17126. /**
  17127. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17128. * @param radius The radius of the cone to emit from
  17129. * @param angle The base angle of the cone
  17130. * @returns the emitter
  17131. */
  17132. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17133. /**
  17134. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17135. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17137. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17139. * @returns the emitter
  17140. */
  17141. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17142. /**
  17143. * Get hosting scene
  17144. * @returns the scene
  17145. */
  17146. getScene(): Scene;
  17147. }
  17148. }
  17149. declare module "babylonjs/Meshes/instancedMesh" {
  17150. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17151. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17152. import { Camera } from "babylonjs/Cameras/camera";
  17153. import { Node } from "babylonjs/node";
  17154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17155. import { Mesh } from "babylonjs/Meshes/mesh";
  17156. import { Material } from "babylonjs/Materials/material";
  17157. import { Skeleton } from "babylonjs/Bones/skeleton";
  17158. import { Light } from "babylonjs/Lights/light";
  17159. /**
  17160. * Creates an instance based on a source mesh.
  17161. */
  17162. export class InstancedMesh extends AbstractMesh {
  17163. private _sourceMesh;
  17164. private _currentLOD;
  17165. /** @hidden */
  17166. _indexInSourceMeshInstanceArray: number;
  17167. constructor(name: string, source: Mesh);
  17168. /**
  17169. * Returns the string "InstancedMesh".
  17170. */
  17171. getClassName(): string;
  17172. /** Gets the list of lights affecting that mesh */
  17173. readonly lightSources: Light[];
  17174. _resyncLightSources(): void;
  17175. _resyncLighSource(light: Light): void;
  17176. _removeLightSource(light: Light): void;
  17177. /**
  17178. * If the source mesh receives shadows
  17179. */
  17180. readonly receiveShadows: boolean;
  17181. /**
  17182. * The material of the source mesh
  17183. */
  17184. readonly material: Nullable<Material>;
  17185. /**
  17186. * Visibility of the source mesh
  17187. */
  17188. readonly visibility: number;
  17189. /**
  17190. * Skeleton of the source mesh
  17191. */
  17192. readonly skeleton: Nullable<Skeleton>;
  17193. /**
  17194. * Rendering ground id of the source mesh
  17195. */
  17196. renderingGroupId: number;
  17197. /**
  17198. * Returns the total number of vertices (integer).
  17199. */
  17200. getTotalVertices(): number;
  17201. /**
  17202. * Returns a positive integer : the total number of indices in this mesh geometry.
  17203. * @returns the numner of indices or zero if the mesh has no geometry.
  17204. */
  17205. getTotalIndices(): number;
  17206. /**
  17207. * The source mesh of the instance
  17208. */
  17209. readonly sourceMesh: Mesh;
  17210. /**
  17211. * Is this node ready to be used/rendered
  17212. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17213. * @return {boolean} is it ready
  17214. */
  17215. isReady(completeCheck?: boolean): boolean;
  17216. /**
  17217. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17218. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17219. * @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.
  17220. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17221. */
  17222. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17223. /**
  17224. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17225. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17226. * The `data` are either a numeric array either a Float32Array.
  17227. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17228. * 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).
  17229. * Note that a new underlying VertexBuffer object is created each call.
  17230. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17231. *
  17232. * Possible `kind` values :
  17233. * - VertexBuffer.PositionKind
  17234. * - VertexBuffer.UVKind
  17235. * - VertexBuffer.UV2Kind
  17236. * - VertexBuffer.UV3Kind
  17237. * - VertexBuffer.UV4Kind
  17238. * - VertexBuffer.UV5Kind
  17239. * - VertexBuffer.UV6Kind
  17240. * - VertexBuffer.ColorKind
  17241. * - VertexBuffer.MatricesIndicesKind
  17242. * - VertexBuffer.MatricesIndicesExtraKind
  17243. * - VertexBuffer.MatricesWeightsKind
  17244. * - VertexBuffer.MatricesWeightsExtraKind
  17245. *
  17246. * Returns the Mesh.
  17247. */
  17248. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17249. /**
  17250. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17251. * If the mesh has no geometry, it is simply returned as it is.
  17252. * The `data` are either a numeric array either a Float32Array.
  17253. * No new underlying VertexBuffer object is created.
  17254. * 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.
  17255. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17256. *
  17257. * Possible `kind` values :
  17258. * - VertexBuffer.PositionKind
  17259. * - VertexBuffer.UVKind
  17260. * - VertexBuffer.UV2Kind
  17261. * - VertexBuffer.UV3Kind
  17262. * - VertexBuffer.UV4Kind
  17263. * - VertexBuffer.UV5Kind
  17264. * - VertexBuffer.UV6Kind
  17265. * - VertexBuffer.ColorKind
  17266. * - VertexBuffer.MatricesIndicesKind
  17267. * - VertexBuffer.MatricesIndicesExtraKind
  17268. * - VertexBuffer.MatricesWeightsKind
  17269. * - VertexBuffer.MatricesWeightsExtraKind
  17270. *
  17271. * Returns the Mesh.
  17272. */
  17273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17274. /**
  17275. * Sets the mesh indices.
  17276. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17277. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17278. * This method creates a new index buffer each call.
  17279. * Returns the Mesh.
  17280. */
  17281. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17282. /**
  17283. * Boolean : True if the mesh owns the requested kind of data.
  17284. */
  17285. isVerticesDataPresent(kind: string): boolean;
  17286. /**
  17287. * Returns an array of indices (IndicesArray).
  17288. */
  17289. getIndices(): Nullable<IndicesArray>;
  17290. readonly _positions: Nullable<Vector3[]>;
  17291. /**
  17292. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17293. * This means the mesh underlying bounding box and sphere are recomputed.
  17294. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17295. * @returns the current mesh
  17296. */
  17297. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17298. /** @hidden */
  17299. _preActivate(): InstancedMesh;
  17300. /** @hidden */
  17301. _activate(renderId: number): boolean;
  17302. /** @hidden */
  17303. _postActivate(): void;
  17304. getWorldMatrix(): Matrix;
  17305. readonly isAnInstance: boolean;
  17306. /**
  17307. * Returns the current associated LOD AbstractMesh.
  17308. */
  17309. getLOD(camera: Camera): AbstractMesh;
  17310. /** @hidden */
  17311. _syncSubMeshes(): InstancedMesh;
  17312. /** @hidden */
  17313. _generatePointsArray(): boolean;
  17314. /**
  17315. * Creates a new InstancedMesh from the current mesh.
  17316. * - name (string) : the cloned mesh name
  17317. * - newParent (optional Node) : the optional Node to parent the clone to.
  17318. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17319. *
  17320. * Returns the clone.
  17321. */
  17322. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17323. /**
  17324. * Disposes the InstancedMesh.
  17325. * Returns nothing.
  17326. */
  17327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17328. }
  17329. }
  17330. declare module "babylonjs/Materials/shaderMaterial" {
  17331. import { Scene } from "babylonjs/scene";
  17332. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17334. import { Mesh } from "babylonjs/Meshes/mesh";
  17335. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17337. import { Texture } from "babylonjs/Materials/Textures/texture";
  17338. import { Material } from "babylonjs/Materials/material";
  17339. /**
  17340. * Defines the options associated with the creation of a shader material.
  17341. */
  17342. export interface IShaderMaterialOptions {
  17343. /**
  17344. * Does the material work in alpha blend mode
  17345. */
  17346. needAlphaBlending: boolean;
  17347. /**
  17348. * Does the material work in alpha test mode
  17349. */
  17350. needAlphaTesting: boolean;
  17351. /**
  17352. * The list of attribute names used in the shader
  17353. */
  17354. attributes: string[];
  17355. /**
  17356. * The list of unifrom names used in the shader
  17357. */
  17358. uniforms: string[];
  17359. /**
  17360. * The list of UBO names used in the shader
  17361. */
  17362. uniformBuffers: string[];
  17363. /**
  17364. * The list of sampler names used in the shader
  17365. */
  17366. samplers: string[];
  17367. /**
  17368. * The list of defines used in the shader
  17369. */
  17370. defines: string[];
  17371. }
  17372. /**
  17373. * 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.
  17374. *
  17375. * This returned material effects how the mesh will look based on the code in the shaders.
  17376. *
  17377. * @see http://doc.babylonjs.com/how_to/shader_material
  17378. */
  17379. export class ShaderMaterial extends Material {
  17380. private _shaderPath;
  17381. private _options;
  17382. private _textures;
  17383. private _textureArrays;
  17384. private _floats;
  17385. private _ints;
  17386. private _floatsArrays;
  17387. private _colors3;
  17388. private _colors3Arrays;
  17389. private _colors4;
  17390. private _vectors2;
  17391. private _vectors3;
  17392. private _vectors4;
  17393. private _matrices;
  17394. private _matrices3x3;
  17395. private _matrices2x2;
  17396. private _vectors2Arrays;
  17397. private _vectors3Arrays;
  17398. private _cachedWorldViewMatrix;
  17399. private _renderId;
  17400. /**
  17401. * Instantiate a new shader material.
  17402. * 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.
  17403. * This returned material effects how the mesh will look based on the code in the shaders.
  17404. * @see http://doc.babylonjs.com/how_to/shader_material
  17405. * @param name Define the name of the material in the scene
  17406. * @param scene Define the scene the material belongs to
  17407. * @param shaderPath Defines the route to the shader code in one of three ways:
  17408. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17409. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17410. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17411. * @param options Define the options used to create the shader
  17412. */
  17413. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17414. /**
  17415. * Gets the options used to compile the shader.
  17416. * They can be modified to trigger a new compilation
  17417. */
  17418. readonly options: IShaderMaterialOptions;
  17419. /**
  17420. * Gets the current class name of the material e.g. "ShaderMaterial"
  17421. * Mainly use in serialization.
  17422. * @returns the class name
  17423. */
  17424. getClassName(): string;
  17425. /**
  17426. * Specifies if the material will require alpha blending
  17427. * @returns a boolean specifying if alpha blending is needed
  17428. */
  17429. needAlphaBlending(): boolean;
  17430. /**
  17431. * Specifies if this material should be rendered in alpha test mode
  17432. * @returns a boolean specifying if an alpha test is needed.
  17433. */
  17434. needAlphaTesting(): boolean;
  17435. private _checkUniform;
  17436. /**
  17437. * Set a texture in the shader.
  17438. * @param name Define the name of the uniform samplers as defined in the shader
  17439. * @param texture Define the texture to bind to this sampler
  17440. * @return the material itself allowing "fluent" like uniform updates
  17441. */
  17442. setTexture(name: string, texture: Texture): ShaderMaterial;
  17443. /**
  17444. * Set a texture array in the shader.
  17445. * @param name Define the name of the uniform sampler array as defined in the shader
  17446. * @param textures Define the list of textures to bind to this sampler
  17447. * @return the material itself allowing "fluent" like uniform updates
  17448. */
  17449. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17450. /**
  17451. * Set a float in the shader.
  17452. * @param name Define the name of the uniform as defined in the shader
  17453. * @param value Define the value to give to the uniform
  17454. * @return the material itself allowing "fluent" like uniform updates
  17455. */
  17456. setFloat(name: string, value: number): ShaderMaterial;
  17457. /**
  17458. * Set a int in the shader.
  17459. * @param name Define the name of the uniform as defined in the shader
  17460. * @param value Define the value to give to the uniform
  17461. * @return the material itself allowing "fluent" like uniform updates
  17462. */
  17463. setInt(name: string, value: number): ShaderMaterial;
  17464. /**
  17465. * Set an array of floats in the shader.
  17466. * @param name Define the name of the uniform as defined in the shader
  17467. * @param value Define the value to give to the uniform
  17468. * @return the material itself allowing "fluent" like uniform updates
  17469. */
  17470. setFloats(name: string, value: number[]): ShaderMaterial;
  17471. /**
  17472. * Set a vec3 in the shader from a Color3.
  17473. * @param name Define the name of the uniform as defined in the shader
  17474. * @param value Define the value to give to the uniform
  17475. * @return the material itself allowing "fluent" like uniform updates
  17476. */
  17477. setColor3(name: string, value: Color3): ShaderMaterial;
  17478. /**
  17479. * Set a vec3 array in the shader from a Color3 array.
  17480. * @param name Define the name of the uniform as defined in the shader
  17481. * @param value Define the value to give to the uniform
  17482. * @return the material itself allowing "fluent" like uniform updates
  17483. */
  17484. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17485. /**
  17486. * Set a vec4 in the shader from a Color4.
  17487. * @param name Define the name of the uniform as defined in the shader
  17488. * @param value Define the value to give to the uniform
  17489. * @return the material itself allowing "fluent" like uniform updates
  17490. */
  17491. setColor4(name: string, value: Color4): ShaderMaterial;
  17492. /**
  17493. * Set a vec2 in the shader from a Vector2.
  17494. * @param name Define the name of the uniform as defined in the shader
  17495. * @param value Define the value to give to the uniform
  17496. * @return the material itself allowing "fluent" like uniform updates
  17497. */
  17498. setVector2(name: string, value: Vector2): ShaderMaterial;
  17499. /**
  17500. * Set a vec3 in the shader from a Vector3.
  17501. * @param name Define the name of the uniform as defined in the shader
  17502. * @param value Define the value to give to the uniform
  17503. * @return the material itself allowing "fluent" like uniform updates
  17504. */
  17505. setVector3(name: string, value: Vector3): ShaderMaterial;
  17506. /**
  17507. * Set a vec4 in the shader from a Vector4.
  17508. * @param name Define the name of the uniform as defined in the shader
  17509. * @param value Define the value to give to the uniform
  17510. * @return the material itself allowing "fluent" like uniform updates
  17511. */
  17512. setVector4(name: string, value: Vector4): ShaderMaterial;
  17513. /**
  17514. * Set a mat4 in the shader from a Matrix.
  17515. * @param name Define the name of the uniform as defined in the shader
  17516. * @param value Define the value to give to the uniform
  17517. * @return the material itself allowing "fluent" like uniform updates
  17518. */
  17519. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17520. /**
  17521. * Set a mat3 in the shader from a Float32Array.
  17522. * @param name Define the name of the uniform as defined in the shader
  17523. * @param value Define the value to give to the uniform
  17524. * @return the material itself allowing "fluent" like uniform updates
  17525. */
  17526. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17527. /**
  17528. * Set a mat2 in the shader from a Float32Array.
  17529. * @param name Define the name of the uniform as defined in the shader
  17530. * @param value Define the value to give to the uniform
  17531. * @return the material itself allowing "fluent" like uniform updates
  17532. */
  17533. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17534. /**
  17535. * Set a vec2 array in the shader from a number array.
  17536. * @param name Define the name of the uniform as defined in the shader
  17537. * @param value Define the value to give to the uniform
  17538. * @return the material itself allowing "fluent" like uniform updates
  17539. */
  17540. setArray2(name: string, value: number[]): ShaderMaterial;
  17541. /**
  17542. * Set a vec3 array in the shader from a number array.
  17543. * @param name Define the name of the uniform as defined in the shader
  17544. * @param value Define the value to give to the uniform
  17545. * @return the material itself allowing "fluent" like uniform updates
  17546. */
  17547. setArray3(name: string, value: number[]): ShaderMaterial;
  17548. private _checkCache;
  17549. /**
  17550. * Specifies that the submesh is ready to be used
  17551. * @param mesh defines the mesh to check
  17552. * @param subMesh defines which submesh to check
  17553. * @param useInstances specifies that instances should be used
  17554. * @returns a boolean indicating that the submesh is ready or not
  17555. */
  17556. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17557. /**
  17558. * Checks if the material is ready to render the requested mesh
  17559. * @param mesh Define the mesh to render
  17560. * @param useInstances Define whether or not the material is used with instances
  17561. * @returns true if ready, otherwise false
  17562. */
  17563. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17564. /**
  17565. * Binds the world matrix to the material
  17566. * @param world defines the world transformation matrix
  17567. */
  17568. bindOnlyWorldMatrix(world: Matrix): void;
  17569. /**
  17570. * Binds the material to the mesh
  17571. * @param world defines the world transformation matrix
  17572. * @param mesh defines the mesh to bind the material to
  17573. */
  17574. bind(world: Matrix, mesh?: Mesh): void;
  17575. /**
  17576. * Gets the active textures from the material
  17577. * @returns an array of textures
  17578. */
  17579. getActiveTextures(): BaseTexture[];
  17580. /**
  17581. * Specifies if the material uses a texture
  17582. * @param texture defines the texture to check against the material
  17583. * @returns a boolean specifying if the material uses the texture
  17584. */
  17585. hasTexture(texture: BaseTexture): boolean;
  17586. /**
  17587. * Makes a duplicate of the material, and gives it a new name
  17588. * @param name defines the new name for the duplicated material
  17589. * @returns the cloned material
  17590. */
  17591. clone(name: string): ShaderMaterial;
  17592. /**
  17593. * Disposes the material
  17594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17595. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17596. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17597. */
  17598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17599. /**
  17600. * Serializes this material in a JSON representation
  17601. * @returns the serialized material object
  17602. */
  17603. serialize(): any;
  17604. /**
  17605. * Creates a shader material from parsed shader material data
  17606. * @param source defines the JSON represnetation of the material
  17607. * @param scene defines the hosting scene
  17608. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17609. * @returns a new material
  17610. */
  17611. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17612. }
  17613. }
  17614. declare module "babylonjs/Shaders/color.fragment" {
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17617. /** @hidden */
  17618. export var colorPixelShader: {
  17619. name: string;
  17620. shader: string;
  17621. };
  17622. }
  17623. declare module "babylonjs/Shaders/color.vertex" {
  17624. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17625. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17626. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17627. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17628. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17630. /** @hidden */
  17631. export var colorVertexShader: {
  17632. name: string;
  17633. shader: string;
  17634. };
  17635. }
  17636. declare module "babylonjs/Meshes/linesMesh" {
  17637. import { Nullable } from "babylonjs/types";
  17638. import { Scene } from "babylonjs/scene";
  17639. import { Color3 } from "babylonjs/Maths/math";
  17640. import { Node } from "babylonjs/node";
  17641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17642. import { Mesh } from "babylonjs/Meshes/mesh";
  17643. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17644. import { Effect } from "babylonjs/Materials/effect";
  17645. import { Material } from "babylonjs/Materials/material";
  17646. import "babylonjs/Shaders/color.fragment";
  17647. import "babylonjs/Shaders/color.vertex";
  17648. /**
  17649. * Line mesh
  17650. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17651. */
  17652. export class LinesMesh extends Mesh {
  17653. /**
  17654. * If vertex color should be applied to the mesh
  17655. */
  17656. useVertexColor?: boolean | undefined;
  17657. /**
  17658. * If vertex alpha should be applied to the mesh
  17659. */
  17660. useVertexAlpha?: boolean | undefined;
  17661. /**
  17662. * Color of the line (Default: White)
  17663. */
  17664. color: Color3;
  17665. /**
  17666. * Alpha of the line (Default: 1)
  17667. */
  17668. alpha: number;
  17669. /**
  17670. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17671. * This margin is expressed in world space coordinates, so its value may vary.
  17672. * Default value is 0.1
  17673. */
  17674. intersectionThreshold: number;
  17675. private _colorShader;
  17676. /**
  17677. * Creates a new LinesMesh
  17678. * @param name defines the name
  17679. * @param scene defines the hosting scene
  17680. * @param parent defines the parent mesh if any
  17681. * @param source defines the optional source LinesMesh used to clone data from
  17682. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17683. * When false, achieved by calling a clone(), also passing False.
  17684. * This will make creation of children, recursive.
  17685. * @param useVertexColor defines if this LinesMesh supports vertex color
  17686. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17687. */
  17688. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17689. /**
  17690. * If vertex color should be applied to the mesh
  17691. */
  17692. useVertexColor?: boolean | undefined,
  17693. /**
  17694. * If vertex alpha should be applied to the mesh
  17695. */
  17696. useVertexAlpha?: boolean | undefined);
  17697. private _addClipPlaneDefine;
  17698. private _removeClipPlaneDefine;
  17699. isReady(): boolean;
  17700. /**
  17701. * Returns the string "LineMesh"
  17702. */
  17703. getClassName(): string;
  17704. /**
  17705. * @hidden
  17706. */
  17707. /**
  17708. * @hidden
  17709. */
  17710. material: Material;
  17711. /**
  17712. * @hidden
  17713. */
  17714. readonly checkCollisions: boolean;
  17715. /** @hidden */
  17716. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17717. /** @hidden */
  17718. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17719. /**
  17720. * Disposes of the line mesh
  17721. * @param doNotRecurse If children should be disposed
  17722. */
  17723. dispose(doNotRecurse?: boolean): void;
  17724. /**
  17725. * Returns a new LineMesh object cloned from the current one.
  17726. */
  17727. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17728. /**
  17729. * Creates a new InstancedLinesMesh object from the mesh model.
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17731. * @param name defines the name of the new instance
  17732. * @returns a new InstancedLinesMesh
  17733. */
  17734. createInstance(name: string): InstancedLinesMesh;
  17735. }
  17736. /**
  17737. * Creates an instance based on a source LinesMesh
  17738. */
  17739. export class InstancedLinesMesh extends InstancedMesh {
  17740. /**
  17741. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17742. * This margin is expressed in world space coordinates, so its value may vary.
  17743. * Initilized with the intersectionThreshold value of the source LinesMesh
  17744. */
  17745. intersectionThreshold: number;
  17746. constructor(name: string, source: LinesMesh);
  17747. /**
  17748. * Returns the string "InstancedLinesMesh".
  17749. */
  17750. getClassName(): string;
  17751. }
  17752. }
  17753. declare module "babylonjs/Shaders/line.fragment" {
  17754. /** @hidden */
  17755. export var linePixelShader: {
  17756. name: string;
  17757. shader: string;
  17758. };
  17759. }
  17760. declare module "babylonjs/Shaders/line.vertex" {
  17761. /** @hidden */
  17762. export var lineVertexShader: {
  17763. name: string;
  17764. shader: string;
  17765. };
  17766. }
  17767. declare module "babylonjs/Rendering/edgesRenderer" {
  17768. import { Nullable } from "babylonjs/types";
  17769. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17771. import { Vector3 } from "babylonjs/Maths/math";
  17772. import { IDisposable } from "babylonjs/scene";
  17773. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17774. import "babylonjs/Shaders/line.fragment";
  17775. import "babylonjs/Shaders/line.vertex";
  17776. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17777. module "babylonjs/Meshes/abstractMesh" {
  17778. interface AbstractMesh {
  17779. /**
  17780. * Disables the mesh edge rendering mode
  17781. * @returns the currentAbstractMesh
  17782. */
  17783. disableEdgesRendering(): AbstractMesh;
  17784. /**
  17785. * Enables the edge rendering mode on the mesh.
  17786. * This mode makes the mesh edges visible
  17787. * @param epsilon defines the maximal distance between two angles to detect a face
  17788. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17789. * @returns the currentAbstractMesh
  17790. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17791. */
  17792. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17793. /**
  17794. * Gets the edgesRenderer associated with the mesh
  17795. */
  17796. edgesRenderer: Nullable<EdgesRenderer>;
  17797. }
  17798. }
  17799. module "babylonjs/Meshes/linesMesh" {
  17800. interface LinesMesh {
  17801. /**
  17802. * Enables the edge rendering mode on the mesh.
  17803. * This mode makes the mesh edges visible
  17804. * @param epsilon defines the maximal distance between two angles to detect a face
  17805. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17806. * @returns the currentAbstractMesh
  17807. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17808. */
  17809. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17810. }
  17811. }
  17812. module "babylonjs/Meshes/linesMesh" {
  17813. interface InstancedLinesMesh {
  17814. /**
  17815. * Enables the edge rendering mode on the mesh.
  17816. * This mode makes the mesh edges visible
  17817. * @param epsilon defines the maximal distance between two angles to detect a face
  17818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17819. * @returns the current InstancedLinesMesh
  17820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17821. */
  17822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17823. }
  17824. }
  17825. /**
  17826. * Defines the minimum contract an Edges renderer should follow.
  17827. */
  17828. export interface IEdgesRenderer extends IDisposable {
  17829. /**
  17830. * Gets or sets a boolean indicating if the edgesRenderer is active
  17831. */
  17832. isEnabled: boolean;
  17833. /**
  17834. * Renders the edges of the attached mesh,
  17835. */
  17836. render(): void;
  17837. /**
  17838. * Checks wether or not the edges renderer is ready to render.
  17839. * @return true if ready, otherwise false.
  17840. */
  17841. isReady(): boolean;
  17842. }
  17843. /**
  17844. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17845. */
  17846. export class EdgesRenderer implements IEdgesRenderer {
  17847. /**
  17848. * Define the size of the edges with an orthographic camera
  17849. */
  17850. edgesWidthScalerForOrthographic: number;
  17851. /**
  17852. * Define the size of the edges with a perspective camera
  17853. */
  17854. edgesWidthScalerForPerspective: number;
  17855. protected _source: AbstractMesh;
  17856. protected _linesPositions: number[];
  17857. protected _linesNormals: number[];
  17858. protected _linesIndices: number[];
  17859. protected _epsilon: number;
  17860. protected _indicesCount: number;
  17861. protected _lineShader: ShaderMaterial;
  17862. protected _ib: DataBuffer;
  17863. protected _buffers: {
  17864. [key: string]: Nullable<VertexBuffer>;
  17865. };
  17866. protected _checkVerticesInsteadOfIndices: boolean;
  17867. private _meshRebuildObserver;
  17868. private _meshDisposeObserver;
  17869. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17870. isEnabled: boolean;
  17871. /**
  17872. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17873. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17874. * @param source Mesh used to create edges
  17875. * @param epsilon sum of angles in adjacency to check for edge
  17876. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17877. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17878. */
  17879. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17880. protected _prepareRessources(): void;
  17881. /** @hidden */
  17882. _rebuild(): void;
  17883. /**
  17884. * Releases the required resources for the edges renderer
  17885. */
  17886. dispose(): void;
  17887. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17888. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17889. /**
  17890. * Checks if the pair of p0 and p1 is en edge
  17891. * @param faceIndex
  17892. * @param edge
  17893. * @param faceNormals
  17894. * @param p0
  17895. * @param p1
  17896. * @private
  17897. */
  17898. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17899. /**
  17900. * push line into the position, normal and index buffer
  17901. * @protected
  17902. */
  17903. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17904. /**
  17905. * Generates lines edges from adjacencjes
  17906. * @private
  17907. */
  17908. _generateEdgesLines(): void;
  17909. /**
  17910. * Checks wether or not the edges renderer is ready to render.
  17911. * @return true if ready, otherwise false.
  17912. */
  17913. isReady(): boolean;
  17914. /**
  17915. * Renders the edges of the attached mesh,
  17916. */
  17917. render(): void;
  17918. }
  17919. /**
  17920. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17921. */
  17922. export class LineEdgesRenderer extends EdgesRenderer {
  17923. /**
  17924. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17925. * @param source LineMesh used to generate edges
  17926. * @param epsilon not important (specified angle for edge detection)
  17927. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17928. */
  17929. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17930. /**
  17931. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17932. */
  17933. _generateEdgesLines(): void;
  17934. }
  17935. }
  17936. declare module "babylonjs/Rendering/renderingGroup" {
  17937. import { SmartArray } from "babylonjs/Misc/smartArray";
  17938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17940. import { Nullable } from "babylonjs/types";
  17941. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17942. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17943. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17944. import { Material } from "babylonjs/Materials/material";
  17945. import { Scene } from "babylonjs/scene";
  17946. /**
  17947. * This represents the object necessary to create a rendering group.
  17948. * This is exclusively used and created by the rendering manager.
  17949. * To modify the behavior, you use the available helpers in your scene or meshes.
  17950. * @hidden
  17951. */
  17952. export class RenderingGroup {
  17953. index: number;
  17954. private _scene;
  17955. private _opaqueSubMeshes;
  17956. private _transparentSubMeshes;
  17957. private _alphaTestSubMeshes;
  17958. private _depthOnlySubMeshes;
  17959. private _particleSystems;
  17960. private _spriteManagers;
  17961. private _opaqueSortCompareFn;
  17962. private _alphaTestSortCompareFn;
  17963. private _transparentSortCompareFn;
  17964. private _renderOpaque;
  17965. private _renderAlphaTest;
  17966. private _renderTransparent;
  17967. /** @hidden */
  17968. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17969. onBeforeTransparentRendering: () => void;
  17970. /**
  17971. * Set the opaque sort comparison function.
  17972. * If null the sub meshes will be render in the order they were created
  17973. */
  17974. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17975. /**
  17976. * Set the alpha test sort comparison function.
  17977. * If null the sub meshes will be render in the order they were created
  17978. */
  17979. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17980. /**
  17981. * Set the transparent sort comparison function.
  17982. * If null the sub meshes will be render in the order they were created
  17983. */
  17984. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17985. /**
  17986. * Creates a new rendering group.
  17987. * @param index The rendering group index
  17988. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17989. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17990. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17991. */
  17992. 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>);
  17993. /**
  17994. * Render all the sub meshes contained in the group.
  17995. * @param customRenderFunction Used to override the default render behaviour of the group.
  17996. * @returns true if rendered some submeshes.
  17997. */
  17998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17999. /**
  18000. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18001. * @param subMeshes The submeshes to render
  18002. */
  18003. private renderOpaqueSorted;
  18004. /**
  18005. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18006. * @param subMeshes The submeshes to render
  18007. */
  18008. private renderAlphaTestSorted;
  18009. /**
  18010. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18011. * @param subMeshes The submeshes to render
  18012. */
  18013. private renderTransparentSorted;
  18014. /**
  18015. * Renders the submeshes in a specified order.
  18016. * @param subMeshes The submeshes to sort before render
  18017. * @param sortCompareFn The comparison function use to sort
  18018. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18019. * @param transparent Specifies to activate blending if true
  18020. */
  18021. private static renderSorted;
  18022. /**
  18023. * Renders the submeshes in the order they were dispatched (no sort applied).
  18024. * @param subMeshes The submeshes to render
  18025. */
  18026. private static renderUnsorted;
  18027. /**
  18028. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18029. * are rendered back to front if in the same alpha index.
  18030. *
  18031. * @param a The first submesh
  18032. * @param b The second submesh
  18033. * @returns The result of the comparison
  18034. */
  18035. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18036. /**
  18037. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18038. * are rendered back to front.
  18039. *
  18040. * @param a The first submesh
  18041. * @param b The second submesh
  18042. * @returns The result of the comparison
  18043. */
  18044. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18045. /**
  18046. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18047. * are rendered front to back (prevent overdraw).
  18048. *
  18049. * @param a The first submesh
  18050. * @param b The second submesh
  18051. * @returns The result of the comparison
  18052. */
  18053. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18054. /**
  18055. * Resets the different lists of submeshes to prepare a new frame.
  18056. */
  18057. prepare(): void;
  18058. dispose(): void;
  18059. /**
  18060. * Inserts the submesh in its correct queue depending on its material.
  18061. * @param subMesh The submesh to dispatch
  18062. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18063. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18064. */
  18065. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18066. dispatchSprites(spriteManager: ISpriteManager): void;
  18067. dispatchParticles(particleSystem: IParticleSystem): void;
  18068. private _renderParticles;
  18069. private _renderSprites;
  18070. }
  18071. }
  18072. declare module "babylonjs/Rendering/renderingManager" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18075. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18076. import { SmartArray } from "babylonjs/Misc/smartArray";
  18077. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18079. import { Material } from "babylonjs/Materials/material";
  18080. import { Scene } from "babylonjs/scene";
  18081. import { Camera } from "babylonjs/Cameras/camera";
  18082. /**
  18083. * Interface describing the different options available in the rendering manager
  18084. * regarding Auto Clear between groups.
  18085. */
  18086. export interface IRenderingManagerAutoClearSetup {
  18087. /**
  18088. * Defines whether or not autoclear is enable.
  18089. */
  18090. autoClear: boolean;
  18091. /**
  18092. * Defines whether or not to autoclear the depth buffer.
  18093. */
  18094. depth: boolean;
  18095. /**
  18096. * Defines whether or not to autoclear the stencil buffer.
  18097. */
  18098. stencil: boolean;
  18099. }
  18100. /**
  18101. * This class is used by the onRenderingGroupObservable
  18102. */
  18103. export class RenderingGroupInfo {
  18104. /**
  18105. * The Scene that being rendered
  18106. */
  18107. scene: Scene;
  18108. /**
  18109. * The camera currently used for the rendering pass
  18110. */
  18111. camera: Nullable<Camera>;
  18112. /**
  18113. * The ID of the renderingGroup being processed
  18114. */
  18115. renderingGroupId: number;
  18116. }
  18117. /**
  18118. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18119. * It is enable to manage the different groups as well as the different necessary sort functions.
  18120. * This should not be used directly aside of the few static configurations
  18121. */
  18122. export class RenderingManager {
  18123. /**
  18124. * The max id used for rendering groups (not included)
  18125. */
  18126. static MAX_RENDERINGGROUPS: number;
  18127. /**
  18128. * The min id used for rendering groups (included)
  18129. */
  18130. static MIN_RENDERINGGROUPS: number;
  18131. /**
  18132. * Used to globally prevent autoclearing scenes.
  18133. */
  18134. static AUTOCLEAR: boolean;
  18135. /**
  18136. * @hidden
  18137. */
  18138. _useSceneAutoClearSetup: boolean;
  18139. private _scene;
  18140. private _renderingGroups;
  18141. private _depthStencilBufferAlreadyCleaned;
  18142. private _autoClearDepthStencil;
  18143. private _customOpaqueSortCompareFn;
  18144. private _customAlphaTestSortCompareFn;
  18145. private _customTransparentSortCompareFn;
  18146. private _renderingGroupInfo;
  18147. /**
  18148. * Instantiates a new rendering group for a particular scene
  18149. * @param scene Defines the scene the groups belongs to
  18150. */
  18151. constructor(scene: Scene);
  18152. private _clearDepthStencilBuffer;
  18153. /**
  18154. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18155. * @hidden
  18156. */
  18157. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18158. /**
  18159. * Resets the different information of the group to prepare a new frame
  18160. * @hidden
  18161. */
  18162. reset(): void;
  18163. /**
  18164. * Dispose and release the group and its associated resources.
  18165. * @hidden
  18166. */
  18167. dispose(): void;
  18168. /**
  18169. * Clear the info related to rendering groups preventing retention points during dispose.
  18170. */
  18171. freeRenderingGroups(): void;
  18172. private _prepareRenderingGroup;
  18173. /**
  18174. * Add a sprite manager to the rendering manager in order to render it this frame.
  18175. * @param spriteManager Define the sprite manager to render
  18176. */
  18177. dispatchSprites(spriteManager: ISpriteManager): void;
  18178. /**
  18179. * Add a particle system to the rendering manager in order to render it this frame.
  18180. * @param particleSystem Define the particle system to render
  18181. */
  18182. dispatchParticles(particleSystem: IParticleSystem): void;
  18183. /**
  18184. * Add a submesh to the manager in order to render it this frame
  18185. * @param subMesh The submesh to dispatch
  18186. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18187. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18188. */
  18189. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18190. /**
  18191. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18192. * This allowed control for front to back rendering or reversly depending of the special needs.
  18193. *
  18194. * @param renderingGroupId The rendering group id corresponding to its index
  18195. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18196. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18197. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18198. */
  18199. 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;
  18200. /**
  18201. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18202. *
  18203. * @param renderingGroupId The rendering group id corresponding to its index
  18204. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18205. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18206. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18207. */
  18208. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18209. /**
  18210. * Gets the current auto clear configuration for one rendering group of the rendering
  18211. * manager.
  18212. * @param index the rendering group index to get the information for
  18213. * @returns The auto clear setup for the requested rendering group
  18214. */
  18215. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18216. }
  18217. }
  18218. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18219. import { Observable } from "babylonjs/Misc/observable";
  18220. import { SmartArray } from "babylonjs/Misc/smartArray";
  18221. import { Nullable } from "babylonjs/types";
  18222. import { Camera } from "babylonjs/Cameras/camera";
  18223. import { Scene } from "babylonjs/scene";
  18224. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18225. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18229. import { Texture } from "babylonjs/Materials/Textures/texture";
  18230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18231. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18232. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18233. import { Engine } from "babylonjs/Engines/engine";
  18234. /**
  18235. * This Helps creating a texture that will be created from a camera in your scene.
  18236. * It is basically a dynamic texture that could be used to create special effects for instance.
  18237. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18238. */
  18239. export class RenderTargetTexture extends Texture {
  18240. isCube: boolean;
  18241. /**
  18242. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18243. */
  18244. static readonly REFRESHRATE_RENDER_ONCE: number;
  18245. /**
  18246. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18247. */
  18248. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18249. /**
  18250. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18251. * the central point of your effect and can save a lot of performances.
  18252. */
  18253. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18254. /**
  18255. * Use this predicate to dynamically define the list of mesh you want to render.
  18256. * If set, the renderList property will be overwritten.
  18257. */
  18258. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18259. private _renderList;
  18260. /**
  18261. * Use this list to define the list of mesh you want to render.
  18262. */
  18263. renderList: Nullable<Array<AbstractMesh>>;
  18264. private _hookArray;
  18265. /**
  18266. * Define if particles should be rendered in your texture.
  18267. */
  18268. renderParticles: boolean;
  18269. /**
  18270. * Define if sprites should be rendered in your texture.
  18271. */
  18272. renderSprites: boolean;
  18273. /**
  18274. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18275. */
  18276. coordinatesMode: number;
  18277. /**
  18278. * Define the camera used to render the texture.
  18279. */
  18280. activeCamera: Nullable<Camera>;
  18281. /**
  18282. * Override the render function of the texture with your own one.
  18283. */
  18284. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18285. /**
  18286. * Define if camera post processes should be use while rendering the texture.
  18287. */
  18288. useCameraPostProcesses: boolean;
  18289. /**
  18290. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18291. */
  18292. ignoreCameraViewport: boolean;
  18293. private _postProcessManager;
  18294. private _postProcesses;
  18295. private _resizeObserver;
  18296. /**
  18297. * An event triggered when the texture is unbind.
  18298. */
  18299. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18300. /**
  18301. * An event triggered when the texture is unbind.
  18302. */
  18303. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18304. private _onAfterUnbindObserver;
  18305. /**
  18306. * Set a after unbind callback in the texture.
  18307. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18308. */
  18309. onAfterUnbind: () => void;
  18310. /**
  18311. * An event triggered before rendering the texture
  18312. */
  18313. onBeforeRenderObservable: Observable<number>;
  18314. private _onBeforeRenderObserver;
  18315. /**
  18316. * Set a before render callback in the texture.
  18317. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18318. */
  18319. onBeforeRender: (faceIndex: number) => void;
  18320. /**
  18321. * An event triggered after rendering the texture
  18322. */
  18323. onAfterRenderObservable: Observable<number>;
  18324. private _onAfterRenderObserver;
  18325. /**
  18326. * Set a after render callback in the texture.
  18327. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18328. */
  18329. onAfterRender: (faceIndex: number) => void;
  18330. /**
  18331. * An event triggered after the texture clear
  18332. */
  18333. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18334. private _onClearObserver;
  18335. /**
  18336. * Set a clear callback in the texture.
  18337. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18338. */
  18339. onClear: (Engine: Engine) => void;
  18340. /**
  18341. * Define the clear color of the Render Target if it should be different from the scene.
  18342. */
  18343. clearColor: Color4;
  18344. protected _size: number | {
  18345. width: number;
  18346. height: number;
  18347. };
  18348. protected _initialSizeParameter: number | {
  18349. width: number;
  18350. height: number;
  18351. } | {
  18352. ratio: number;
  18353. };
  18354. protected _sizeRatio: Nullable<number>;
  18355. /** @hidden */
  18356. _generateMipMaps: boolean;
  18357. protected _renderingManager: RenderingManager;
  18358. /** @hidden */
  18359. _waitingRenderList: string[];
  18360. protected _doNotChangeAspectRatio: boolean;
  18361. protected _currentRefreshId: number;
  18362. protected _refreshRate: number;
  18363. protected _textureMatrix: Matrix;
  18364. protected _samples: number;
  18365. protected _renderTargetOptions: RenderTargetCreationOptions;
  18366. /**
  18367. * Gets render target creation options that were used.
  18368. */
  18369. readonly renderTargetOptions: RenderTargetCreationOptions;
  18370. protected _engine: Engine;
  18371. protected _onRatioRescale(): void;
  18372. /**
  18373. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18374. * It must define where the camera used to render the texture is set
  18375. */
  18376. boundingBoxPosition: Vector3;
  18377. private _boundingBoxSize;
  18378. /**
  18379. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18380. * When defined, the cubemap will switch to local mode
  18381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18382. * @example https://www.babylonjs-playground.com/#RNASML
  18383. */
  18384. boundingBoxSize: Vector3;
  18385. /**
  18386. * In case the RTT has been created with a depth texture, get the associated
  18387. * depth texture.
  18388. * Otherwise, return null.
  18389. */
  18390. depthStencilTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18393. * or used a shadow, depth texture...
  18394. * @param name The friendly name of the texture
  18395. * @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)
  18396. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18397. * @param generateMipMaps True if mip maps need to be generated after render.
  18398. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18399. * @param type The type of the buffer in the RTT (int, half float, float...)
  18400. * @param isCube True if a cube texture needs to be created
  18401. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18402. * @param generateDepthBuffer True to generate a depth buffer
  18403. * @param generateStencilBuffer True to generate a stencil buffer
  18404. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18405. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18406. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18407. */
  18408. constructor(name: string, size: number | {
  18409. width: number;
  18410. height: number;
  18411. } | {
  18412. ratio: number;
  18413. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18414. /**
  18415. * Creates a depth stencil texture.
  18416. * This is only available in WebGL 2 or with the depth texture extension available.
  18417. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18418. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18419. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18420. */
  18421. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18422. private _processSizeParameter;
  18423. /**
  18424. * Define the number of samples to use in case of MSAA.
  18425. * It defaults to one meaning no MSAA has been enabled.
  18426. */
  18427. samples: number;
  18428. /**
  18429. * Resets the refresh counter of the texture and start bak from scratch.
  18430. * Could be useful to regenerate the texture if it is setup to render only once.
  18431. */
  18432. resetRefreshCounter(): void;
  18433. /**
  18434. * Define the refresh rate of the texture or the rendering frequency.
  18435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18436. */
  18437. refreshRate: number;
  18438. /**
  18439. * Adds a post process to the render target rendering passes.
  18440. * @param postProcess define the post process to add
  18441. */
  18442. addPostProcess(postProcess: PostProcess): void;
  18443. /**
  18444. * Clear all the post processes attached to the render target
  18445. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18446. */
  18447. clearPostProcesses(dispose?: boolean): void;
  18448. /**
  18449. * Remove one of the post process from the list of attached post processes to the texture
  18450. * @param postProcess define the post process to remove from the list
  18451. */
  18452. removePostProcess(postProcess: PostProcess): void;
  18453. /** @hidden */
  18454. _shouldRender(): boolean;
  18455. /**
  18456. * Gets the actual render size of the texture.
  18457. * @returns the width of the render size
  18458. */
  18459. getRenderSize(): number;
  18460. /**
  18461. * Gets the actual render width of the texture.
  18462. * @returns the width of the render size
  18463. */
  18464. getRenderWidth(): number;
  18465. /**
  18466. * Gets the actual render height of the texture.
  18467. * @returns the height of the render size
  18468. */
  18469. getRenderHeight(): number;
  18470. /**
  18471. * Get if the texture can be rescaled or not.
  18472. */
  18473. readonly canRescale: boolean;
  18474. /**
  18475. * Resize the texture using a ratio.
  18476. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18477. */
  18478. scale(ratio: number): void;
  18479. /**
  18480. * Get the texture reflection matrix used to rotate/transform the reflection.
  18481. * @returns the reflection matrix
  18482. */
  18483. getReflectionTextureMatrix(): Matrix;
  18484. /**
  18485. * Resize the texture to a new desired size.
  18486. * Be carrefull as it will recreate all the data in the new texture.
  18487. * @param size Define the new size. It can be:
  18488. * - a number for squared texture,
  18489. * - an object containing { width: number, height: number }
  18490. * - or an object containing a ratio { ratio: number }
  18491. */
  18492. resize(size: number | {
  18493. width: number;
  18494. height: number;
  18495. } | {
  18496. ratio: number;
  18497. }): void;
  18498. /**
  18499. * Renders all the objects from the render list into the texture.
  18500. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18501. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18502. */
  18503. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18504. private _bestReflectionRenderTargetDimension;
  18505. /**
  18506. * @hidden
  18507. * @param faceIndex face index to bind to if this is a cubetexture
  18508. */
  18509. _bindFrameBuffer(faceIndex?: number): void;
  18510. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18511. private renderToTarget;
  18512. /**
  18513. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18514. * This allowed control for front to back rendering or reversly depending of the special needs.
  18515. *
  18516. * @param renderingGroupId The rendering group id corresponding to its index
  18517. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18518. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18519. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18520. */
  18521. 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;
  18522. /**
  18523. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18524. *
  18525. * @param renderingGroupId The rendering group id corresponding to its index
  18526. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18527. */
  18528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18529. /**
  18530. * Clones the texture.
  18531. * @returns the cloned texture
  18532. */
  18533. clone(): RenderTargetTexture;
  18534. /**
  18535. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18536. * @returns The JSON representation of the texture
  18537. */
  18538. serialize(): any;
  18539. /**
  18540. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18541. */
  18542. disposeFramebufferObjects(): void;
  18543. /**
  18544. * Dispose the texture and release its associated resources.
  18545. */
  18546. dispose(): void;
  18547. /** @hidden */
  18548. _rebuild(): void;
  18549. /**
  18550. * Clear the info related to rendering groups preventing retention point in material dispose.
  18551. */
  18552. freeRenderingGroups(): void;
  18553. /**
  18554. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18555. * @returns the view count
  18556. */
  18557. getViewCount(): number;
  18558. }
  18559. }
  18560. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18561. import { Scene } from "babylonjs/scene";
  18562. import { Plane } from "babylonjs/Maths/math";
  18563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18564. /**
  18565. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18566. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18567. * You can then easily use it as a reflectionTexture on a flat surface.
  18568. * In case the surface is not a plane, please consider relying on reflection probes.
  18569. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18570. */
  18571. export class MirrorTexture extends RenderTargetTexture {
  18572. private scene;
  18573. /**
  18574. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18575. * 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.
  18576. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18577. */
  18578. mirrorPlane: Plane;
  18579. /**
  18580. * Define the blur ratio used to blur the reflection if needed.
  18581. */
  18582. blurRatio: number;
  18583. /**
  18584. * Define the adaptive blur kernel used to blur the reflection if needed.
  18585. * This will autocompute the closest best match for the `blurKernel`
  18586. */
  18587. adaptiveBlurKernel: number;
  18588. /**
  18589. * Define the blur kernel used to blur the reflection if needed.
  18590. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18591. */
  18592. blurKernel: number;
  18593. /**
  18594. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18595. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18596. */
  18597. blurKernelX: number;
  18598. /**
  18599. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18600. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18601. */
  18602. blurKernelY: number;
  18603. private _autoComputeBlurKernel;
  18604. protected _onRatioRescale(): void;
  18605. private _updateGammaSpace;
  18606. private _imageProcessingConfigChangeObserver;
  18607. private _transformMatrix;
  18608. private _mirrorMatrix;
  18609. private _savedViewMatrix;
  18610. private _blurX;
  18611. private _blurY;
  18612. private _adaptiveBlurKernel;
  18613. private _blurKernelX;
  18614. private _blurKernelY;
  18615. private _blurRatio;
  18616. /**
  18617. * Instantiates a Mirror Texture.
  18618. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18619. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18620. * You can then easily use it as a reflectionTexture on a flat surface.
  18621. * In case the surface is not a plane, please consider relying on reflection probes.
  18622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18623. * @param name
  18624. * @param size
  18625. * @param scene
  18626. * @param generateMipMaps
  18627. * @param type
  18628. * @param samplingMode
  18629. * @param generateDepthBuffer
  18630. */
  18631. constructor(name: string, size: number | {
  18632. width: number;
  18633. height: number;
  18634. } | {
  18635. ratio: number;
  18636. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18637. private _preparePostProcesses;
  18638. /**
  18639. * Clone the mirror texture.
  18640. * @returns the cloned texture
  18641. */
  18642. clone(): MirrorTexture;
  18643. /**
  18644. * Serialize the texture to a JSON representation you could use in Parse later on
  18645. * @returns the serialized JSON representation
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Dispose the texture and release its associated resources.
  18650. */
  18651. dispose(): void;
  18652. }
  18653. }
  18654. declare module "babylonjs/Materials/Textures/texture" {
  18655. import { Observable } from "babylonjs/Misc/observable";
  18656. import { Nullable } from "babylonjs/types";
  18657. import { Scene } from "babylonjs/scene";
  18658. import { Matrix } from "babylonjs/Maths/math";
  18659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18660. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18661. /**
  18662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18664. */
  18665. export class Texture extends BaseTexture {
  18666. /** @hidden */
  18667. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18668. /** @hidden */
  18669. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18670. /** @hidden */
  18671. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18672. /** nearest is mag = nearest and min = nearest and mip = linear */
  18673. static readonly NEAREST_SAMPLINGMODE: number;
  18674. /** nearest is mag = nearest and min = nearest and mip = linear */
  18675. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18676. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18677. static readonly BILINEAR_SAMPLINGMODE: number;
  18678. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18679. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18680. /** Trilinear is mag = linear and min = linear and mip = linear */
  18681. static readonly TRILINEAR_SAMPLINGMODE: number;
  18682. /** Trilinear is mag = linear and min = linear and mip = linear */
  18683. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18684. /** mag = nearest and min = nearest and mip = nearest */
  18685. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18686. /** mag = nearest and min = linear and mip = nearest */
  18687. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18688. /** mag = nearest and min = linear and mip = linear */
  18689. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18690. /** mag = nearest and min = linear and mip = none */
  18691. static readonly NEAREST_LINEAR: number;
  18692. /** mag = nearest and min = nearest and mip = none */
  18693. static readonly NEAREST_NEAREST: number;
  18694. /** mag = linear and min = nearest and mip = nearest */
  18695. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18696. /** mag = linear and min = nearest and mip = linear */
  18697. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18698. /** mag = linear and min = linear and mip = none */
  18699. static readonly LINEAR_LINEAR: number;
  18700. /** mag = linear and min = nearest and mip = none */
  18701. static readonly LINEAR_NEAREST: number;
  18702. /** Explicit coordinates mode */
  18703. static readonly EXPLICIT_MODE: number;
  18704. /** Spherical coordinates mode */
  18705. static readonly SPHERICAL_MODE: number;
  18706. /** Planar coordinates mode */
  18707. static readonly PLANAR_MODE: number;
  18708. /** Cubic coordinates mode */
  18709. static readonly CUBIC_MODE: number;
  18710. /** Projection coordinates mode */
  18711. static readonly PROJECTION_MODE: number;
  18712. /** Inverse Cubic coordinates mode */
  18713. static readonly SKYBOX_MODE: number;
  18714. /** Inverse Cubic coordinates mode */
  18715. static readonly INVCUBIC_MODE: number;
  18716. /** Equirectangular coordinates mode */
  18717. static readonly EQUIRECTANGULAR_MODE: number;
  18718. /** Equirectangular Fixed coordinates mode */
  18719. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18720. /** Equirectangular Fixed Mirrored coordinates mode */
  18721. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18722. /** Texture is not repeating outside of 0..1 UVs */
  18723. static readonly CLAMP_ADDRESSMODE: number;
  18724. /** Texture is repeating outside of 0..1 UVs */
  18725. static readonly WRAP_ADDRESSMODE: number;
  18726. /** Texture is repeating and mirrored */
  18727. static readonly MIRROR_ADDRESSMODE: number;
  18728. /**
  18729. * 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
  18730. */
  18731. static UseSerializedUrlIfAny: boolean;
  18732. /**
  18733. * Define the url of the texture.
  18734. */
  18735. url: Nullable<string>;
  18736. /**
  18737. * Define an offset on the texture to offset the u coordinates of the UVs
  18738. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18739. */
  18740. uOffset: number;
  18741. /**
  18742. * Define an offset on the texture to offset the v coordinates of the UVs
  18743. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18744. */
  18745. vOffset: number;
  18746. /**
  18747. * Define an offset on the texture to scale the u coordinates of the UVs
  18748. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18749. */
  18750. uScale: number;
  18751. /**
  18752. * Define an offset on the texture to scale the v coordinates of the UVs
  18753. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18754. */
  18755. vScale: number;
  18756. /**
  18757. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18758. * @see http://doc.babylonjs.com/how_to/more_materials
  18759. */
  18760. uAng: number;
  18761. /**
  18762. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18763. * @see http://doc.babylonjs.com/how_to/more_materials
  18764. */
  18765. vAng: number;
  18766. /**
  18767. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18768. * @see http://doc.babylonjs.com/how_to/more_materials
  18769. */
  18770. wAng: number;
  18771. /**
  18772. * Defines the center of rotation (U)
  18773. */
  18774. uRotationCenter: number;
  18775. /**
  18776. * Defines the center of rotation (V)
  18777. */
  18778. vRotationCenter: number;
  18779. /**
  18780. * Defines the center of rotation (W)
  18781. */
  18782. wRotationCenter: number;
  18783. /**
  18784. * Are mip maps generated for this texture or not.
  18785. */
  18786. readonly noMipmap: boolean;
  18787. /**
  18788. * List of inspectable custom properties (used by the Inspector)
  18789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18790. */
  18791. inspectableCustomProperties: Nullable<IInspectable[]>;
  18792. private _noMipmap;
  18793. /** @hidden */
  18794. _invertY: boolean;
  18795. private _rowGenerationMatrix;
  18796. private _cachedTextureMatrix;
  18797. private _projectionModeMatrix;
  18798. private _t0;
  18799. private _t1;
  18800. private _t2;
  18801. private _cachedUOffset;
  18802. private _cachedVOffset;
  18803. private _cachedUScale;
  18804. private _cachedVScale;
  18805. private _cachedUAng;
  18806. private _cachedVAng;
  18807. private _cachedWAng;
  18808. private _cachedProjectionMatrixId;
  18809. private _cachedCoordinatesMode;
  18810. /** @hidden */
  18811. protected _initialSamplingMode: number;
  18812. /** @hidden */
  18813. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18814. private _deleteBuffer;
  18815. protected _format: Nullable<number>;
  18816. private _delayedOnLoad;
  18817. private _delayedOnError;
  18818. /**
  18819. * Observable triggered once the texture has been loaded.
  18820. */
  18821. onLoadObservable: Observable<Texture>;
  18822. protected _isBlocking: boolean;
  18823. /**
  18824. * Is the texture preventing material to render while loading.
  18825. * If false, a default texture will be used instead of the loading one during the preparation step.
  18826. */
  18827. isBlocking: boolean;
  18828. /**
  18829. * Get the current sampling mode associated with the texture.
  18830. */
  18831. readonly samplingMode: number;
  18832. /**
  18833. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18834. */
  18835. readonly invertY: boolean;
  18836. /**
  18837. * Instantiates a new texture.
  18838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18840. * @param url define the url of the picture to load as a texture
  18841. * @param scene define the scene the texture will belong to
  18842. * @param noMipmap define if the texture will require mip maps or not
  18843. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18844. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18845. * @param onLoad define a callback triggered when the texture has been loaded
  18846. * @param onError define a callback triggered when an error occurred during the loading session
  18847. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18848. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18849. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18850. */
  18851. 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);
  18852. /**
  18853. * Update the url (and optional buffer) of this texture if url was null during construction.
  18854. * @param url the url of the texture
  18855. * @param buffer the buffer of the texture (defaults to null)
  18856. * @param onLoad callback called when the texture is loaded (defaults to null)
  18857. */
  18858. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18859. /**
  18860. * Finish the loading sequence of a texture flagged as delayed load.
  18861. * @hidden
  18862. */
  18863. delayLoad(): void;
  18864. private _prepareRowForTextureGeneration;
  18865. /**
  18866. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18867. * @returns the transform matrix of the texture.
  18868. */
  18869. getTextureMatrix(): Matrix;
  18870. /**
  18871. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18872. * @returns The reflection texture transform
  18873. */
  18874. getReflectionTextureMatrix(): Matrix;
  18875. /**
  18876. * Clones the texture.
  18877. * @returns the cloned texture
  18878. */
  18879. clone(): Texture;
  18880. /**
  18881. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18882. * @returns The JSON representation of the texture
  18883. */
  18884. serialize(): any;
  18885. /**
  18886. * Get the current class name of the texture useful for serialization or dynamic coding.
  18887. * @returns "Texture"
  18888. */
  18889. getClassName(): string;
  18890. /**
  18891. * Dispose the texture and release its associated resources.
  18892. */
  18893. dispose(): void;
  18894. /**
  18895. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18896. * @param parsedTexture Define the JSON representation of the texture
  18897. * @param scene Define the scene the parsed texture should be instantiated in
  18898. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18899. * @returns The parsed texture if successful
  18900. */
  18901. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18902. /**
  18903. * Creates a texture from its base 64 representation.
  18904. * @param data Define the base64 payload without the data: prefix
  18905. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18906. * @param scene Define the scene the texture should belong to
  18907. * @param noMipmap Forces the texture to not create mip map information if true
  18908. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18909. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18910. * @param onLoad define a callback triggered when the texture has been loaded
  18911. * @param onError define a callback triggered when an error occurred during the loading session
  18912. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18913. * @returns the created texture
  18914. */
  18915. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18916. /**
  18917. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18918. * @param data Define the base64 payload without the data: prefix
  18919. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18920. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18921. * @param scene Define the scene the texture should belong to
  18922. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18923. * @param noMipmap Forces the texture to not create mip map information if true
  18924. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18925. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18926. * @param onLoad define a callback triggered when the texture has been loaded
  18927. * @param onError define a callback triggered when an error occurred during the loading session
  18928. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18929. * @returns the created texture
  18930. */
  18931. 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;
  18932. }
  18933. }
  18934. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18935. import { Nullable } from "babylonjs/types";
  18936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18937. import { Scene } from "babylonjs/scene";
  18938. module "babylonjs/Engines/engine" {
  18939. interface Engine {
  18940. /**
  18941. * Creates a raw texture
  18942. * @param data defines the data to store in the texture
  18943. * @param width defines the width of the texture
  18944. * @param height defines the height of the texture
  18945. * @param format defines the format of the data
  18946. * @param generateMipMaps defines if the engine should generate the mip levels
  18947. * @param invertY defines if data must be stored with Y axis inverted
  18948. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18949. * @param compression defines the compression used (null by default)
  18950. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18951. * @returns the raw texture inside an InternalTexture
  18952. */
  18953. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18954. /**
  18955. * Update a raw texture
  18956. * @param texture defines the texture to update
  18957. * @param data defines the data to store in the texture
  18958. * @param format defines the format of the data
  18959. * @param invertY defines if data must be stored with Y axis inverted
  18960. */
  18961. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18962. /**
  18963. * Update a raw texture
  18964. * @param texture defines the texture to update
  18965. * @param data defines the data to store in the texture
  18966. * @param format defines the format of the data
  18967. * @param invertY defines if data must be stored with Y axis inverted
  18968. * @param compression defines the compression used (null by default)
  18969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18970. */
  18971. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18972. /**
  18973. * Creates a new raw cube texture
  18974. * @param data defines the array of data to use to create each face
  18975. * @param size defines the size of the textures
  18976. * @param format defines the format of the data
  18977. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18978. * @param generateMipMaps defines if the engine should generate the mip levels
  18979. * @param invertY defines if data must be stored with Y axis inverted
  18980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18981. * @param compression defines the compression used (null by default)
  18982. * @returns the cube texture as an InternalTexture
  18983. */
  18984. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18985. /**
  18986. * Update a raw cube texture
  18987. * @param texture defines the texture to udpdate
  18988. * @param data defines the data to store
  18989. * @param format defines the data format
  18990. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18991. * @param invertY defines if data must be stored with Y axis inverted
  18992. */
  18993. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18994. /**
  18995. * Update a raw cube texture
  18996. * @param texture defines the texture to udpdate
  18997. * @param data defines the data to store
  18998. * @param format defines the data format
  18999. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19000. * @param invertY defines if data must be stored with Y axis inverted
  19001. * @param compression defines the compression used (null by default)
  19002. */
  19003. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19004. /**
  19005. * Update a raw cube texture
  19006. * @param texture defines the texture to udpdate
  19007. * @param data defines the data to store
  19008. * @param format defines the data format
  19009. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19010. * @param invertY defines if data must be stored with Y axis inverted
  19011. * @param compression defines the compression used (null by default)
  19012. * @param level defines which level of the texture to update
  19013. */
  19014. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19015. /**
  19016. * Creates a new raw cube texture from a specified url
  19017. * @param url defines the url where the data is located
  19018. * @param scene defines the current scene
  19019. * @param size defines the size of the textures
  19020. * @param format defines the format of the data
  19021. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19022. * @param noMipmap defines if the engine should avoid generating the mip levels
  19023. * @param callback defines a callback used to extract texture data from loaded data
  19024. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19025. * @param onLoad defines a callback called when texture is loaded
  19026. * @param onError defines a callback called if there is an error
  19027. * @returns the cube texture as an InternalTexture
  19028. */
  19029. 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;
  19030. /**
  19031. * Creates a new raw cube texture from a specified url
  19032. * @param url defines the url where the data is located
  19033. * @param scene defines the current scene
  19034. * @param size defines the size of the textures
  19035. * @param format defines the format of the data
  19036. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19037. * @param noMipmap defines if the engine should avoid generating the mip levels
  19038. * @param callback defines a callback used to extract texture data from loaded data
  19039. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19040. * @param onLoad defines a callback called when texture is loaded
  19041. * @param onError defines a callback called if there is an error
  19042. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19043. * @param invertY defines if data must be stored with Y axis inverted
  19044. * @returns the cube texture as an InternalTexture
  19045. */
  19046. 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;
  19047. /**
  19048. * Creates a new raw 3D texture
  19049. * @param data defines the data used to create the texture
  19050. * @param width defines the width of the texture
  19051. * @param height defines the height of the texture
  19052. * @param depth defines the depth of the texture
  19053. * @param format defines the format of the texture
  19054. * @param generateMipMaps defines if the engine must generate mip levels
  19055. * @param invertY defines if data must be stored with Y axis inverted
  19056. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19057. * @param compression defines the compressed used (can be null)
  19058. * @param textureType defines the compressed used (can be null)
  19059. * @returns a new raw 3D texture (stored in an InternalTexture)
  19060. */
  19061. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19062. /**
  19063. * Update a raw 3D texture
  19064. * @param texture defines the texture to update
  19065. * @param data defines the data to store
  19066. * @param format defines the data format
  19067. * @param invertY defines if data must be stored with Y axis inverted
  19068. */
  19069. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19070. /**
  19071. * Update a raw 3D texture
  19072. * @param texture defines the texture to update
  19073. * @param data defines the data to store
  19074. * @param format defines the data format
  19075. * @param invertY defines if data must be stored with Y axis inverted
  19076. * @param compression defines the used compression (can be null)
  19077. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19078. */
  19079. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19080. }
  19081. }
  19082. }
  19083. declare module "babylonjs/Materials/Textures/rawTexture" {
  19084. import { Scene } from "babylonjs/scene";
  19085. import { Texture } from "babylonjs/Materials/Textures/texture";
  19086. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19087. /**
  19088. * Raw texture can help creating a texture directly from an array of data.
  19089. * This can be super useful if you either get the data from an uncompressed source or
  19090. * if you wish to create your texture pixel by pixel.
  19091. */
  19092. export class RawTexture extends Texture {
  19093. /**
  19094. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19095. */
  19096. format: number;
  19097. private _engine;
  19098. /**
  19099. * Instantiates a new RawTexture.
  19100. * Raw texture can help creating a texture directly from an array of data.
  19101. * This can be super useful if you either get the data from an uncompressed source or
  19102. * if you wish to create your texture pixel by pixel.
  19103. * @param data define the array of data to use to create the texture
  19104. * @param width define the width of the texture
  19105. * @param height define the height of the texture
  19106. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19107. * @param scene define the scene the texture belongs to
  19108. * @param generateMipMaps define whether mip maps should be generated or not
  19109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19111. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19112. */
  19113. constructor(data: ArrayBufferView, width: number, height: number,
  19114. /**
  19115. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19116. */
  19117. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19118. /**
  19119. * Updates the texture underlying data.
  19120. * @param data Define the new data of the texture
  19121. */
  19122. update(data: ArrayBufferView): void;
  19123. /**
  19124. * Creates a luminance texture from some data.
  19125. * @param data Define the texture data
  19126. * @param width Define the width of the texture
  19127. * @param height Define the height of the texture
  19128. * @param scene Define the scene the texture belongs to
  19129. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19130. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19131. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19132. * @returns the luminance texture
  19133. */
  19134. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19135. /**
  19136. * Creates a luminance alpha texture from some data.
  19137. * @param data Define the texture data
  19138. * @param width Define the width of the texture
  19139. * @param height Define the height of the texture
  19140. * @param scene Define the scene the texture belongs to
  19141. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19142. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19143. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19144. * @returns the luminance alpha texture
  19145. */
  19146. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19147. /**
  19148. * Creates an alpha texture from some data.
  19149. * @param data Define the texture data
  19150. * @param width Define the width of the texture
  19151. * @param height Define the height of the texture
  19152. * @param scene Define the scene the texture belongs to
  19153. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19154. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19155. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19156. * @returns the alpha texture
  19157. */
  19158. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19159. /**
  19160. * Creates a RGB texture from some data.
  19161. * @param data Define the texture data
  19162. * @param width Define the width of the texture
  19163. * @param height Define the height of the texture
  19164. * @param scene Define the scene the texture belongs to
  19165. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19166. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19167. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19168. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19169. * @returns the RGB alpha texture
  19170. */
  19171. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19172. /**
  19173. * Creates a RGBA texture from some data.
  19174. * @param data Define the texture data
  19175. * @param width Define the width of the texture
  19176. * @param height Define the height of the texture
  19177. * @param scene Define the scene the texture belongs to
  19178. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19179. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19180. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19181. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19182. * @returns the RGBA texture
  19183. */
  19184. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19185. /**
  19186. * Creates a R texture from some data.
  19187. * @param data Define the texture data
  19188. * @param width Define the width of the texture
  19189. * @param height Define the height of the texture
  19190. * @param scene Define the scene the texture belongs to
  19191. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19192. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19193. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19194. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19195. * @returns the R texture
  19196. */
  19197. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19198. }
  19199. }
  19200. declare module "babylonjs/Animations/runtimeAnimation" {
  19201. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19202. import { Animatable } from "babylonjs/Animations/animatable";
  19203. import { Scene } from "babylonjs/scene";
  19204. /**
  19205. * Defines a runtime animation
  19206. */
  19207. export class RuntimeAnimation {
  19208. private _events;
  19209. /**
  19210. * The current frame of the runtime animation
  19211. */
  19212. private _currentFrame;
  19213. /**
  19214. * The animation used by the runtime animation
  19215. */
  19216. private _animation;
  19217. /**
  19218. * The target of the runtime animation
  19219. */
  19220. private _target;
  19221. /**
  19222. * The initiating animatable
  19223. */
  19224. private _host;
  19225. /**
  19226. * The original value of the runtime animation
  19227. */
  19228. private _originalValue;
  19229. /**
  19230. * The original blend value of the runtime animation
  19231. */
  19232. private _originalBlendValue;
  19233. /**
  19234. * The offsets cache of the runtime animation
  19235. */
  19236. private _offsetsCache;
  19237. /**
  19238. * The high limits cache of the runtime animation
  19239. */
  19240. private _highLimitsCache;
  19241. /**
  19242. * Specifies if the runtime animation has been stopped
  19243. */
  19244. private _stopped;
  19245. /**
  19246. * The blending factor of the runtime animation
  19247. */
  19248. private _blendingFactor;
  19249. /**
  19250. * The BabylonJS scene
  19251. */
  19252. private _scene;
  19253. /**
  19254. * The current value of the runtime animation
  19255. */
  19256. private _currentValue;
  19257. /** @hidden */
  19258. _animationState: _IAnimationState;
  19259. /**
  19260. * The active target of the runtime animation
  19261. */
  19262. private _activeTargets;
  19263. private _currentActiveTarget;
  19264. private _directTarget;
  19265. /**
  19266. * The target path of the runtime animation
  19267. */
  19268. private _targetPath;
  19269. /**
  19270. * The weight of the runtime animation
  19271. */
  19272. private _weight;
  19273. /**
  19274. * The ratio offset of the runtime animation
  19275. */
  19276. private _ratioOffset;
  19277. /**
  19278. * The previous delay of the runtime animation
  19279. */
  19280. private _previousDelay;
  19281. /**
  19282. * The previous ratio of the runtime animation
  19283. */
  19284. private _previousRatio;
  19285. private _enableBlending;
  19286. private _keys;
  19287. private _minFrame;
  19288. private _maxFrame;
  19289. private _minValue;
  19290. private _maxValue;
  19291. private _targetIsArray;
  19292. /**
  19293. * Gets the current frame of the runtime animation
  19294. */
  19295. readonly currentFrame: number;
  19296. /**
  19297. * Gets the weight of the runtime animation
  19298. */
  19299. readonly weight: number;
  19300. /**
  19301. * Gets the current value of the runtime animation
  19302. */
  19303. readonly currentValue: any;
  19304. /**
  19305. * Gets the target path of the runtime animation
  19306. */
  19307. readonly targetPath: string;
  19308. /**
  19309. * Gets the actual target of the runtime animation
  19310. */
  19311. readonly target: any;
  19312. /** @hidden */
  19313. _onLoop: () => void;
  19314. /**
  19315. * Create a new RuntimeAnimation object
  19316. * @param target defines the target of the animation
  19317. * @param animation defines the source animation object
  19318. * @param scene defines the hosting scene
  19319. * @param host defines the initiating Animatable
  19320. */
  19321. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19322. private _preparePath;
  19323. /**
  19324. * Gets the animation from the runtime animation
  19325. */
  19326. readonly animation: Animation;
  19327. /**
  19328. * Resets the runtime animation to the beginning
  19329. * @param restoreOriginal defines whether to restore the target property to the original value
  19330. */
  19331. reset(restoreOriginal?: boolean): void;
  19332. /**
  19333. * Specifies if the runtime animation is stopped
  19334. * @returns Boolean specifying if the runtime animation is stopped
  19335. */
  19336. isStopped(): boolean;
  19337. /**
  19338. * Disposes of the runtime animation
  19339. */
  19340. dispose(): void;
  19341. /**
  19342. * Apply the interpolated value to the target
  19343. * @param currentValue defines the value computed by the animation
  19344. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19345. */
  19346. setValue(currentValue: any, weight: number): void;
  19347. private _getOriginalValues;
  19348. private _setValue;
  19349. /**
  19350. * Gets the loop pmode of the runtime animation
  19351. * @returns Loop Mode
  19352. */
  19353. private _getCorrectLoopMode;
  19354. /**
  19355. * Move the current animation to a given frame
  19356. * @param frame defines the frame to move to
  19357. */
  19358. goToFrame(frame: number): void;
  19359. /**
  19360. * @hidden Internal use only
  19361. */
  19362. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19363. /**
  19364. * Execute the current animation
  19365. * @param delay defines the delay to add to the current frame
  19366. * @param from defines the lower bound of the animation range
  19367. * @param to defines the upper bound of the animation range
  19368. * @param loop defines if the current animation must loop
  19369. * @param speedRatio defines the current speed ratio
  19370. * @param weight defines the weight of the animation (default is -1 so no weight)
  19371. * @param onLoop optional callback called when animation loops
  19372. * @returns a boolean indicating if the animation is running
  19373. */
  19374. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19375. }
  19376. }
  19377. declare module "babylonjs/Animations/animatable" {
  19378. import { Animation } from "babylonjs/Animations/animation";
  19379. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19380. import { Nullable } from "babylonjs/types";
  19381. import { Observable } from "babylonjs/Misc/observable";
  19382. import { Scene } from "babylonjs/scene";
  19383. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19384. import { Node } from "babylonjs/node";
  19385. /**
  19386. * Class used to store an actual running animation
  19387. */
  19388. export class Animatable {
  19389. /** defines the target object */
  19390. target: any;
  19391. /** defines the starting frame number (default is 0) */
  19392. fromFrame: number;
  19393. /** defines the ending frame number (default is 100) */
  19394. toFrame: number;
  19395. /** defines if the animation must loop (default is false) */
  19396. loopAnimation: boolean;
  19397. /** defines a callback to call when animation ends if it is not looping */
  19398. onAnimationEnd?: (() => void) | null | undefined;
  19399. /** defines a callback to call when animation loops */
  19400. onAnimationLoop?: (() => void) | null | undefined;
  19401. private _localDelayOffset;
  19402. private _pausedDelay;
  19403. private _runtimeAnimations;
  19404. private _paused;
  19405. private _scene;
  19406. private _speedRatio;
  19407. private _weight;
  19408. private _syncRoot;
  19409. /**
  19410. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19411. * This will only apply for non looping animation (default is true)
  19412. */
  19413. disposeOnEnd: boolean;
  19414. /**
  19415. * Gets a boolean indicating if the animation has started
  19416. */
  19417. animationStarted: boolean;
  19418. /**
  19419. * Observer raised when the animation ends
  19420. */
  19421. onAnimationEndObservable: Observable<Animatable>;
  19422. /**
  19423. * Observer raised when the animation loops
  19424. */
  19425. onAnimationLoopObservable: Observable<Animatable>;
  19426. /**
  19427. * Gets the root Animatable used to synchronize and normalize animations
  19428. */
  19429. readonly syncRoot: Nullable<Animatable>;
  19430. /**
  19431. * Gets the current frame of the first RuntimeAnimation
  19432. * Used to synchronize Animatables
  19433. */
  19434. readonly masterFrame: number;
  19435. /**
  19436. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19437. */
  19438. weight: number;
  19439. /**
  19440. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19441. */
  19442. speedRatio: number;
  19443. /**
  19444. * Creates a new Animatable
  19445. * @param scene defines the hosting scene
  19446. * @param target defines the target object
  19447. * @param fromFrame defines the starting frame number (default is 0)
  19448. * @param toFrame defines the ending frame number (default is 100)
  19449. * @param loopAnimation defines if the animation must loop (default is false)
  19450. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19451. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19452. * @param animations defines a group of animation to add to the new Animatable
  19453. * @param onAnimationLoop defines a callback to call when animation loops
  19454. */
  19455. constructor(scene: Scene,
  19456. /** defines the target object */
  19457. target: any,
  19458. /** defines the starting frame number (default is 0) */
  19459. fromFrame?: number,
  19460. /** defines the ending frame number (default is 100) */
  19461. toFrame?: number,
  19462. /** defines if the animation must loop (default is false) */
  19463. loopAnimation?: boolean, speedRatio?: number,
  19464. /** defines a callback to call when animation ends if it is not looping */
  19465. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19466. /** defines a callback to call when animation loops */
  19467. onAnimationLoop?: (() => void) | null | undefined);
  19468. /**
  19469. * Synchronize and normalize current Animatable with a source Animatable
  19470. * This is useful when using animation weights and when animations are not of the same length
  19471. * @param root defines the root Animatable to synchronize with
  19472. * @returns the current Animatable
  19473. */
  19474. syncWith(root: Animatable): Animatable;
  19475. /**
  19476. * Gets the list of runtime animations
  19477. * @returns an array of RuntimeAnimation
  19478. */
  19479. getAnimations(): RuntimeAnimation[];
  19480. /**
  19481. * Adds more animations to the current animatable
  19482. * @param target defines the target of the animations
  19483. * @param animations defines the new animations to add
  19484. */
  19485. appendAnimations(target: any, animations: Animation[]): void;
  19486. /**
  19487. * Gets the source animation for a specific property
  19488. * @param property defines the propertyu to look for
  19489. * @returns null or the source animation for the given property
  19490. */
  19491. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19492. /**
  19493. * Gets the runtime animation for a specific property
  19494. * @param property defines the propertyu to look for
  19495. * @returns null or the runtime animation for the given property
  19496. */
  19497. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19498. /**
  19499. * Resets the animatable to its original state
  19500. */
  19501. reset(): void;
  19502. /**
  19503. * Allows the animatable to blend with current running animations
  19504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19505. * @param blendingSpeed defines the blending speed to use
  19506. */
  19507. enableBlending(blendingSpeed: number): void;
  19508. /**
  19509. * Disable animation blending
  19510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19511. */
  19512. disableBlending(): void;
  19513. /**
  19514. * Jump directly to a given frame
  19515. * @param frame defines the frame to jump to
  19516. */
  19517. goToFrame(frame: number): void;
  19518. /**
  19519. * Pause the animation
  19520. */
  19521. pause(): void;
  19522. /**
  19523. * Restart the animation
  19524. */
  19525. restart(): void;
  19526. private _raiseOnAnimationEnd;
  19527. /**
  19528. * Stop and delete the current animation
  19529. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19530. * @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)
  19531. */
  19532. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19533. /**
  19534. * Wait asynchronously for the animation to end
  19535. * @returns a promise which will be fullfilled when the animation ends
  19536. */
  19537. waitAsync(): Promise<Animatable>;
  19538. /** @hidden */
  19539. _animate(delay: number): boolean;
  19540. }
  19541. module "babylonjs/scene" {
  19542. interface Scene {
  19543. /** @hidden */
  19544. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19545. /** @hidden */
  19546. _processLateAnimationBindingsForMatrices(holder: {
  19547. totalWeight: number;
  19548. animations: RuntimeAnimation[];
  19549. originalValue: Matrix;
  19550. }): any;
  19551. /** @hidden */
  19552. _processLateAnimationBindingsForQuaternions(holder: {
  19553. totalWeight: number;
  19554. animations: RuntimeAnimation[];
  19555. originalValue: Quaternion;
  19556. }, refQuaternion: Quaternion): Quaternion;
  19557. /** @hidden */
  19558. _processLateAnimationBindings(): void;
  19559. /**
  19560. * Will start the animation sequence of a given target
  19561. * @param target defines the target
  19562. * @param from defines from which frame should animation start
  19563. * @param to defines until which frame should animation run.
  19564. * @param weight defines the weight to apply to the animation (1.0 by default)
  19565. * @param loop defines if the animation loops
  19566. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19567. * @param onAnimationEnd defines the function to be executed when the animation ends
  19568. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19569. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19570. * @param onAnimationLoop defines the callback to call when an animation loops
  19571. * @returns the animatable object created for this animation
  19572. */
  19573. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19574. /**
  19575. * Will start the animation sequence of a given target
  19576. * @param target defines the target
  19577. * @param from defines from which frame should animation start
  19578. * @param to defines until which frame should animation run.
  19579. * @param loop defines if the animation loops
  19580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19581. * @param onAnimationEnd defines the function to be executed when the animation ends
  19582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19583. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19584. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19585. * @param onAnimationLoop defines the callback to call when an animation loops
  19586. * @returns the animatable object created for this animation
  19587. */
  19588. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19589. /**
  19590. * Will start the animation sequence of a given target and its hierarchy
  19591. * @param target defines the target
  19592. * @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.
  19593. * @param from defines from which frame should animation start
  19594. * @param to defines until which frame should animation run.
  19595. * @param loop defines if the animation loops
  19596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19597. * @param onAnimationEnd defines the function to be executed when the animation ends
  19598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19599. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19600. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19601. * @param onAnimationLoop defines the callback to call when an animation loops
  19602. * @returns the list of created animatables
  19603. */
  19604. 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[];
  19605. /**
  19606. * Begin a new animation on a given node
  19607. * @param target defines the target where the animation will take place
  19608. * @param animations defines the list of animations to start
  19609. * @param from defines the initial value
  19610. * @param to defines the final value
  19611. * @param loop defines if you want animation to loop (off by default)
  19612. * @param speedRatio defines the speed ratio to apply to all animations
  19613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19614. * @param onAnimationLoop defines the callback to call when an animation loops
  19615. * @returns the list of created animatables
  19616. */
  19617. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19618. /**
  19619. * Begin a new animation on a given node and its hierarchy
  19620. * @param target defines the root node where the animation will take place
  19621. * @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.
  19622. * @param animations defines the list of animations to start
  19623. * @param from defines the initial value
  19624. * @param to defines the final value
  19625. * @param loop defines if you want animation to loop (off by default)
  19626. * @param speedRatio defines the speed ratio to apply to all animations
  19627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19628. * @param onAnimationLoop defines the callback to call when an animation loops
  19629. * @returns the list of animatables created for all nodes
  19630. */
  19631. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19632. /**
  19633. * Gets the animatable associated with a specific target
  19634. * @param target defines the target of the animatable
  19635. * @returns the required animatable if found
  19636. */
  19637. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19638. /**
  19639. * Gets all animatables associated with a given target
  19640. * @param target defines the target to look animatables for
  19641. * @returns an array of Animatables
  19642. */
  19643. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19644. /**
  19645. * Stops and removes all animations that have been applied to the scene
  19646. */
  19647. stopAllAnimations(): void;
  19648. }
  19649. }
  19650. module "babylonjs/Bones/bone" {
  19651. interface Bone {
  19652. /**
  19653. * Copy an animation range from another bone
  19654. * @param source defines the source bone
  19655. * @param rangeName defines the range name to copy
  19656. * @param frameOffset defines the frame offset
  19657. * @param rescaleAsRequired defines if rescaling must be applied if required
  19658. * @param skelDimensionsRatio defines the scaling ratio
  19659. * @returns true if operation was successful
  19660. */
  19661. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19662. }
  19663. }
  19664. }
  19665. declare module "babylonjs/Bones/skeleton" {
  19666. import { Bone } from "babylonjs/Bones/bone";
  19667. import { IAnimatable } from "babylonjs/Misc/tools";
  19668. import { Observable } from "babylonjs/Misc/observable";
  19669. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19670. import { Scene } from "babylonjs/scene";
  19671. import { Nullable } from "babylonjs/types";
  19672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19673. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19674. import { Animatable } from "babylonjs/Animations/animatable";
  19675. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19676. import { Animation } from "babylonjs/Animations/animation";
  19677. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19678. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19679. /**
  19680. * Class used to handle skinning animations
  19681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19682. */
  19683. export class Skeleton implements IAnimatable {
  19684. /** defines the skeleton name */
  19685. name: string;
  19686. /** defines the skeleton Id */
  19687. id: string;
  19688. /**
  19689. * Defines the list of child bones
  19690. */
  19691. bones: Bone[];
  19692. /**
  19693. * Defines an estimate of the dimension of the skeleton at rest
  19694. */
  19695. dimensionsAtRest: Vector3;
  19696. /**
  19697. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19698. */
  19699. needInitialSkinMatrix: boolean;
  19700. /**
  19701. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19702. */
  19703. overrideMesh: Nullable<AbstractMesh>;
  19704. /**
  19705. * Gets the list of animations attached to this skeleton
  19706. */
  19707. animations: Array<Animation>;
  19708. private _scene;
  19709. private _isDirty;
  19710. private _transformMatrices;
  19711. private _transformMatrixTexture;
  19712. private _meshesWithPoseMatrix;
  19713. private _animatables;
  19714. private _identity;
  19715. private _synchronizedWithMesh;
  19716. private _ranges;
  19717. private _lastAbsoluteTransformsUpdateId;
  19718. private _canUseTextureForBones;
  19719. private _uniqueId;
  19720. /** @hidden */
  19721. _numBonesWithLinkedTransformNode: number;
  19722. /** @hidden */
  19723. _hasWaitingData: Nullable<boolean>;
  19724. /**
  19725. * Specifies if the skeleton should be serialized
  19726. */
  19727. doNotSerialize: boolean;
  19728. private _useTextureToStoreBoneMatrices;
  19729. /**
  19730. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19731. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19732. */
  19733. useTextureToStoreBoneMatrices: boolean;
  19734. private _animationPropertiesOverride;
  19735. /**
  19736. * Gets or sets the animation properties override
  19737. */
  19738. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19739. /**
  19740. * List of inspectable custom properties (used by the Inspector)
  19741. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19742. */
  19743. inspectableCustomProperties: IInspectable[];
  19744. /**
  19745. * An observable triggered before computing the skeleton's matrices
  19746. */
  19747. onBeforeComputeObservable: Observable<Skeleton>;
  19748. /**
  19749. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19750. */
  19751. readonly isUsingTextureForMatrices: boolean;
  19752. /**
  19753. * Gets the unique ID of this skeleton
  19754. */
  19755. readonly uniqueId: number;
  19756. /**
  19757. * Creates a new skeleton
  19758. * @param name defines the skeleton name
  19759. * @param id defines the skeleton Id
  19760. * @param scene defines the hosting scene
  19761. */
  19762. constructor(
  19763. /** defines the skeleton name */
  19764. name: string,
  19765. /** defines the skeleton Id */
  19766. id: string, scene: Scene);
  19767. /**
  19768. * Gets the current object class name.
  19769. * @return the class name
  19770. */
  19771. getClassName(): string;
  19772. /**
  19773. * Returns an array containing the root bones
  19774. * @returns an array containing the root bones
  19775. */
  19776. getChildren(): Array<Bone>;
  19777. /**
  19778. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19779. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19780. * @returns a Float32Array containing matrices data
  19781. */
  19782. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19783. /**
  19784. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19785. * @returns a raw texture containing the data
  19786. */
  19787. getTransformMatrixTexture(): Nullable<RawTexture>;
  19788. /**
  19789. * Gets the current hosting scene
  19790. * @returns a scene object
  19791. */
  19792. getScene(): Scene;
  19793. /**
  19794. * Gets a string representing the current skeleton data
  19795. * @param fullDetails defines a boolean indicating if we want a verbose version
  19796. * @returns a string representing the current skeleton data
  19797. */
  19798. toString(fullDetails?: boolean): string;
  19799. /**
  19800. * Get bone's index searching by name
  19801. * @param name defines bone's name to search for
  19802. * @return the indice of the bone. Returns -1 if not found
  19803. */
  19804. getBoneIndexByName(name: string): number;
  19805. /**
  19806. * Creater a new animation range
  19807. * @param name defines the name of the range
  19808. * @param from defines the start key
  19809. * @param to defines the end key
  19810. */
  19811. createAnimationRange(name: string, from: number, to: number): void;
  19812. /**
  19813. * Delete a specific animation range
  19814. * @param name defines the name of the range
  19815. * @param deleteFrames defines if frames must be removed as well
  19816. */
  19817. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19818. /**
  19819. * Gets a specific animation range
  19820. * @param name defines the name of the range to look for
  19821. * @returns the requested animation range or null if not found
  19822. */
  19823. getAnimationRange(name: string): Nullable<AnimationRange>;
  19824. /**
  19825. * Gets the list of all animation ranges defined on this skeleton
  19826. * @returns an array
  19827. */
  19828. getAnimationRanges(): Nullable<AnimationRange>[];
  19829. /**
  19830. * Copy animation range from a source skeleton.
  19831. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19832. * @param source defines the source skeleton
  19833. * @param name defines the name of the range to copy
  19834. * @param rescaleAsRequired defines if rescaling must be applied if required
  19835. * @returns true if operation was successful
  19836. */
  19837. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19838. /**
  19839. * Forces the skeleton to go to rest pose
  19840. */
  19841. returnToRest(): void;
  19842. private _getHighestAnimationFrame;
  19843. /**
  19844. * Begin a specific animation range
  19845. * @param name defines the name of the range to start
  19846. * @param loop defines if looping must be turned on (false by default)
  19847. * @param speedRatio defines the speed ratio to apply (1 by default)
  19848. * @param onAnimationEnd defines a callback which will be called when animation will end
  19849. * @returns a new animatable
  19850. */
  19851. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19852. /** @hidden */
  19853. _markAsDirty(): void;
  19854. /** @hidden */
  19855. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19856. /** @hidden */
  19857. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19858. private _computeTransformMatrices;
  19859. /**
  19860. * Build all resources required to render a skeleton
  19861. */
  19862. prepare(): void;
  19863. /**
  19864. * Gets the list of animatables currently running for this skeleton
  19865. * @returns an array of animatables
  19866. */
  19867. getAnimatables(): IAnimatable[];
  19868. /**
  19869. * Clone the current skeleton
  19870. * @param name defines the name of the new skeleton
  19871. * @param id defines the id of the new skeleton
  19872. * @returns the new skeleton
  19873. */
  19874. clone(name: string, id: string): Skeleton;
  19875. /**
  19876. * Enable animation blending for this skeleton
  19877. * @param blendingSpeed defines the blending speed to apply
  19878. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19879. */
  19880. enableBlending(blendingSpeed?: number): void;
  19881. /**
  19882. * Releases all resources associated with the current skeleton
  19883. */
  19884. dispose(): void;
  19885. /**
  19886. * Serialize the skeleton in a JSON object
  19887. * @returns a JSON object
  19888. */
  19889. serialize(): any;
  19890. /**
  19891. * Creates a new skeleton from serialized data
  19892. * @param parsedSkeleton defines the serialized data
  19893. * @param scene defines the hosting scene
  19894. * @returns a new skeleton
  19895. */
  19896. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19897. /**
  19898. * Compute all node absolute transforms
  19899. * @param forceUpdate defines if computation must be done even if cache is up to date
  19900. */
  19901. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19902. /**
  19903. * Gets the root pose matrix
  19904. * @returns a matrix
  19905. */
  19906. getPoseMatrix(): Nullable<Matrix>;
  19907. /**
  19908. * Sorts bones per internal index
  19909. */
  19910. sortBones(): void;
  19911. private _sortBones;
  19912. }
  19913. }
  19914. declare module "babylonjs/Morph/morphTarget" {
  19915. import { IAnimatable } from "babylonjs/Misc/tools";
  19916. import { Observable } from "babylonjs/Misc/observable";
  19917. import { Nullable, FloatArray } from "babylonjs/types";
  19918. import { Scene } from "babylonjs/scene";
  19919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19920. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19921. /**
  19922. * Defines a target to use with MorphTargetManager
  19923. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19924. */
  19925. export class MorphTarget implements IAnimatable {
  19926. /** defines the name of the target */
  19927. name: string;
  19928. /**
  19929. * Gets or sets the list of animations
  19930. */
  19931. animations: import("babylonjs/Animations/animation").Animation[];
  19932. private _scene;
  19933. private _positions;
  19934. private _normals;
  19935. private _tangents;
  19936. private _influence;
  19937. /**
  19938. * Observable raised when the influence changes
  19939. */
  19940. onInfluenceChanged: Observable<boolean>;
  19941. /** @hidden */
  19942. _onDataLayoutChanged: Observable<void>;
  19943. /**
  19944. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19945. */
  19946. influence: number;
  19947. /**
  19948. * Gets or sets the id of the morph Target
  19949. */
  19950. id: string;
  19951. private _animationPropertiesOverride;
  19952. /**
  19953. * Gets or sets the animation properties override
  19954. */
  19955. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19956. /**
  19957. * Creates a new MorphTarget
  19958. * @param name defines the name of the target
  19959. * @param influence defines the influence to use
  19960. * @param scene defines the scene the morphtarget belongs to
  19961. */
  19962. constructor(
  19963. /** defines the name of the target */
  19964. name: string, influence?: number, scene?: Nullable<Scene>);
  19965. /**
  19966. * Gets a boolean defining if the target contains position data
  19967. */
  19968. readonly hasPositions: boolean;
  19969. /**
  19970. * Gets a boolean defining if the target contains normal data
  19971. */
  19972. readonly hasNormals: boolean;
  19973. /**
  19974. * Gets a boolean defining if the target contains tangent data
  19975. */
  19976. readonly hasTangents: boolean;
  19977. /**
  19978. * Affects position data to this target
  19979. * @param data defines the position data to use
  19980. */
  19981. setPositions(data: Nullable<FloatArray>): void;
  19982. /**
  19983. * Gets the position data stored in this target
  19984. * @returns a FloatArray containing the position data (or null if not present)
  19985. */
  19986. getPositions(): Nullable<FloatArray>;
  19987. /**
  19988. * Affects normal data to this target
  19989. * @param data defines the normal data to use
  19990. */
  19991. setNormals(data: Nullable<FloatArray>): void;
  19992. /**
  19993. * Gets the normal data stored in this target
  19994. * @returns a FloatArray containing the normal data (or null if not present)
  19995. */
  19996. getNormals(): Nullable<FloatArray>;
  19997. /**
  19998. * Affects tangent data to this target
  19999. * @param data defines the tangent data to use
  20000. */
  20001. setTangents(data: Nullable<FloatArray>): void;
  20002. /**
  20003. * Gets the tangent data stored in this target
  20004. * @returns a FloatArray containing the tangent data (or null if not present)
  20005. */
  20006. getTangents(): Nullable<FloatArray>;
  20007. /**
  20008. * Serializes the current target into a Serialization object
  20009. * @returns the serialized object
  20010. */
  20011. serialize(): any;
  20012. /**
  20013. * Returns the string "MorphTarget"
  20014. * @returns "MorphTarget"
  20015. */
  20016. getClassName(): string;
  20017. /**
  20018. * Creates a new target from serialized data
  20019. * @param serializationObject defines the serialized data to use
  20020. * @returns a new MorphTarget
  20021. */
  20022. static Parse(serializationObject: any): MorphTarget;
  20023. /**
  20024. * Creates a MorphTarget from mesh data
  20025. * @param mesh defines the source mesh
  20026. * @param name defines the name to use for the new target
  20027. * @param influence defines the influence to attach to the target
  20028. * @returns a new MorphTarget
  20029. */
  20030. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20031. }
  20032. }
  20033. declare module "babylonjs/Morph/morphTargetManager" {
  20034. import { Nullable } from "babylonjs/types";
  20035. import { Scene } from "babylonjs/scene";
  20036. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20037. /**
  20038. * This class is used to deform meshes using morphing between different targets
  20039. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20040. */
  20041. export class MorphTargetManager {
  20042. private _targets;
  20043. private _targetInfluenceChangedObservers;
  20044. private _targetDataLayoutChangedObservers;
  20045. private _activeTargets;
  20046. private _scene;
  20047. private _influences;
  20048. private _supportsNormals;
  20049. private _supportsTangents;
  20050. private _vertexCount;
  20051. private _uniqueId;
  20052. private _tempInfluences;
  20053. /**
  20054. * Creates a new MorphTargetManager
  20055. * @param scene defines the current scene
  20056. */
  20057. constructor(scene?: Nullable<Scene>);
  20058. /**
  20059. * Gets the unique ID of this manager
  20060. */
  20061. readonly uniqueId: number;
  20062. /**
  20063. * Gets the number of vertices handled by this manager
  20064. */
  20065. readonly vertexCount: number;
  20066. /**
  20067. * Gets a boolean indicating if this manager supports morphing of normals
  20068. */
  20069. readonly supportsNormals: boolean;
  20070. /**
  20071. * Gets a boolean indicating if this manager supports morphing of tangents
  20072. */
  20073. readonly supportsTangents: boolean;
  20074. /**
  20075. * Gets the number of targets stored in this manager
  20076. */
  20077. readonly numTargets: number;
  20078. /**
  20079. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20080. */
  20081. readonly numInfluencers: number;
  20082. /**
  20083. * Gets the list of influences (one per target)
  20084. */
  20085. readonly influences: Float32Array;
  20086. /**
  20087. * Gets the active target at specified index. An active target is a target with an influence > 0
  20088. * @param index defines the index to check
  20089. * @returns the requested target
  20090. */
  20091. getActiveTarget(index: number): MorphTarget;
  20092. /**
  20093. * Gets the target at specified index
  20094. * @param index defines the index to check
  20095. * @returns the requested target
  20096. */
  20097. getTarget(index: number): MorphTarget;
  20098. /**
  20099. * Add a new target to this manager
  20100. * @param target defines the target to add
  20101. */
  20102. addTarget(target: MorphTarget): void;
  20103. /**
  20104. * Removes a target from the manager
  20105. * @param target defines the target to remove
  20106. */
  20107. removeTarget(target: MorphTarget): void;
  20108. /**
  20109. * Serializes the current manager into a Serialization object
  20110. * @returns the serialized object
  20111. */
  20112. serialize(): any;
  20113. private _syncActiveTargets;
  20114. /**
  20115. * Syncrhonize the targets with all the meshes using this morph target manager
  20116. */
  20117. synchronize(): void;
  20118. /**
  20119. * Creates a new MorphTargetManager from serialized data
  20120. * @param serializationObject defines the serialized data
  20121. * @param scene defines the hosting scene
  20122. * @returns the new MorphTargetManager
  20123. */
  20124. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20125. }
  20126. }
  20127. declare module "babylonjs/Meshes/meshLODLevel" {
  20128. import { Mesh } from "babylonjs/Meshes/mesh";
  20129. import { Nullable } from "babylonjs/types";
  20130. /**
  20131. * Class used to represent a specific level of detail of a mesh
  20132. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20133. */
  20134. export class MeshLODLevel {
  20135. /** Defines the distance where this level should star being displayed */
  20136. distance: number;
  20137. /** Defines the mesh to use to render this level */
  20138. mesh: Nullable<Mesh>;
  20139. /**
  20140. * Creates a new LOD level
  20141. * @param distance defines the distance where this level should star being displayed
  20142. * @param mesh defines the mesh to use to render this level
  20143. */
  20144. constructor(
  20145. /** Defines the distance where this level should star being displayed */
  20146. distance: number,
  20147. /** Defines the mesh to use to render this level */
  20148. mesh: Nullable<Mesh>);
  20149. }
  20150. }
  20151. declare module "babylonjs/Meshes/groundMesh" {
  20152. import { Scene } from "babylonjs/scene";
  20153. import { Vector3 } from "babylonjs/Maths/math";
  20154. import { Mesh } from "babylonjs/Meshes/mesh";
  20155. /**
  20156. * Mesh representing the gorund
  20157. */
  20158. export class GroundMesh extends Mesh {
  20159. /** If octree should be generated */
  20160. generateOctree: boolean;
  20161. private _heightQuads;
  20162. /** @hidden */
  20163. _subdivisionsX: number;
  20164. /** @hidden */
  20165. _subdivisionsY: number;
  20166. /** @hidden */
  20167. _width: number;
  20168. /** @hidden */
  20169. _height: number;
  20170. /** @hidden */
  20171. _minX: number;
  20172. /** @hidden */
  20173. _maxX: number;
  20174. /** @hidden */
  20175. _minZ: number;
  20176. /** @hidden */
  20177. _maxZ: number;
  20178. constructor(name: string, scene: Scene);
  20179. /**
  20180. * "GroundMesh"
  20181. * @returns "GroundMesh"
  20182. */
  20183. getClassName(): string;
  20184. /**
  20185. * The minimum of x and y subdivisions
  20186. */
  20187. readonly subdivisions: number;
  20188. /**
  20189. * X subdivisions
  20190. */
  20191. readonly subdivisionsX: number;
  20192. /**
  20193. * Y subdivisions
  20194. */
  20195. readonly subdivisionsY: number;
  20196. /**
  20197. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20198. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20199. * @param chunksCount the number of subdivisions for x and y
  20200. * @param octreeBlocksSize (Default: 32)
  20201. */
  20202. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20203. /**
  20204. * Returns a height (y) value in the Worl system :
  20205. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20206. * @param x x coordinate
  20207. * @param z z coordinate
  20208. * @returns the ground y position if (x, z) are outside the ground surface.
  20209. */
  20210. getHeightAtCoordinates(x: number, z: number): number;
  20211. /**
  20212. * Returns a normalized vector (Vector3) orthogonal to the ground
  20213. * at the ground coordinates (x, z) expressed in the World system.
  20214. * @param x x coordinate
  20215. * @param z z coordinate
  20216. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20217. */
  20218. getNormalAtCoordinates(x: number, z: number): Vector3;
  20219. /**
  20220. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20221. * at the ground coordinates (x, z) expressed in the World system.
  20222. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20223. * @param x x coordinate
  20224. * @param z z coordinate
  20225. * @param ref vector to store the result
  20226. * @returns the GroundMesh.
  20227. */
  20228. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20229. /**
  20230. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20231. * if the ground has been updated.
  20232. * This can be used in the render loop.
  20233. * @returns the GroundMesh.
  20234. */
  20235. updateCoordinateHeights(): GroundMesh;
  20236. private _getFacetAt;
  20237. private _initHeightQuads;
  20238. private _computeHeightQuads;
  20239. /**
  20240. * Serializes this ground mesh
  20241. * @param serializationObject object to write serialization to
  20242. */
  20243. serialize(serializationObject: any): void;
  20244. /**
  20245. * Parses a serialized ground mesh
  20246. * @param parsedMesh the serialized mesh
  20247. * @param scene the scene to create the ground mesh in
  20248. * @returns the created ground mesh
  20249. */
  20250. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20251. }
  20252. }
  20253. declare module "babylonjs/Physics/physicsJoint" {
  20254. import { Vector3 } from "babylonjs/Maths/math";
  20255. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20256. /**
  20257. * Interface for Physics-Joint data
  20258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20259. */
  20260. export interface PhysicsJointData {
  20261. /**
  20262. * The main pivot of the joint
  20263. */
  20264. mainPivot?: Vector3;
  20265. /**
  20266. * The connected pivot of the joint
  20267. */
  20268. connectedPivot?: Vector3;
  20269. /**
  20270. * The main axis of the joint
  20271. */
  20272. mainAxis?: Vector3;
  20273. /**
  20274. * The connected axis of the joint
  20275. */
  20276. connectedAxis?: Vector3;
  20277. /**
  20278. * The collision of the joint
  20279. */
  20280. collision?: boolean;
  20281. /**
  20282. * Native Oimo/Cannon/Energy data
  20283. */
  20284. nativeParams?: any;
  20285. }
  20286. /**
  20287. * This is a holder class for the physics joint created by the physics plugin
  20288. * It holds a set of functions to control the underlying joint
  20289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20290. */
  20291. export class PhysicsJoint {
  20292. /**
  20293. * The type of the physics joint
  20294. */
  20295. type: number;
  20296. /**
  20297. * The data for the physics joint
  20298. */
  20299. jointData: PhysicsJointData;
  20300. private _physicsJoint;
  20301. protected _physicsPlugin: IPhysicsEnginePlugin;
  20302. /**
  20303. * Initializes the physics joint
  20304. * @param type The type of the physics joint
  20305. * @param jointData The data for the physics joint
  20306. */
  20307. constructor(
  20308. /**
  20309. * The type of the physics joint
  20310. */
  20311. type: number,
  20312. /**
  20313. * The data for the physics joint
  20314. */
  20315. jointData: PhysicsJointData);
  20316. /**
  20317. * Gets the physics joint
  20318. */
  20319. /**
  20320. * Sets the physics joint
  20321. */
  20322. physicsJoint: any;
  20323. /**
  20324. * Sets the physics plugin
  20325. */
  20326. physicsPlugin: IPhysicsEnginePlugin;
  20327. /**
  20328. * Execute a function that is physics-plugin specific.
  20329. * @param {Function} func the function that will be executed.
  20330. * It accepts two parameters: the physics world and the physics joint
  20331. */
  20332. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20333. /**
  20334. * Distance-Joint type
  20335. */
  20336. static DistanceJoint: number;
  20337. /**
  20338. * Hinge-Joint type
  20339. */
  20340. static HingeJoint: number;
  20341. /**
  20342. * Ball-and-Socket joint type
  20343. */
  20344. static BallAndSocketJoint: number;
  20345. /**
  20346. * Wheel-Joint type
  20347. */
  20348. static WheelJoint: number;
  20349. /**
  20350. * Slider-Joint type
  20351. */
  20352. static SliderJoint: number;
  20353. /**
  20354. * Prismatic-Joint type
  20355. */
  20356. static PrismaticJoint: number;
  20357. /**
  20358. * Universal-Joint type
  20359. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20360. */
  20361. static UniversalJoint: number;
  20362. /**
  20363. * Hinge-Joint 2 type
  20364. */
  20365. static Hinge2Joint: number;
  20366. /**
  20367. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20368. */
  20369. static PointToPointJoint: number;
  20370. /**
  20371. * Spring-Joint type
  20372. */
  20373. static SpringJoint: number;
  20374. /**
  20375. * Lock-Joint type
  20376. */
  20377. static LockJoint: number;
  20378. }
  20379. /**
  20380. * A class representing a physics distance joint
  20381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20382. */
  20383. export class DistanceJoint extends PhysicsJoint {
  20384. /**
  20385. *
  20386. * @param jointData The data for the Distance-Joint
  20387. */
  20388. constructor(jointData: DistanceJointData);
  20389. /**
  20390. * Update the predefined distance.
  20391. * @param maxDistance The maximum preferred distance
  20392. * @param minDistance The minimum preferred distance
  20393. */
  20394. updateDistance(maxDistance: number, minDistance?: number): void;
  20395. }
  20396. /**
  20397. * Represents a Motor-Enabled Joint
  20398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20399. */
  20400. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20401. /**
  20402. * Initializes the Motor-Enabled Joint
  20403. * @param type The type of the joint
  20404. * @param jointData The physica joint data for the joint
  20405. */
  20406. constructor(type: number, jointData: PhysicsJointData);
  20407. /**
  20408. * Set the motor values.
  20409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20410. * @param force the force to apply
  20411. * @param maxForce max force for this motor.
  20412. */
  20413. setMotor(force?: number, maxForce?: number): void;
  20414. /**
  20415. * Set the motor's limits.
  20416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20417. * @param upperLimit The upper limit of the motor
  20418. * @param lowerLimit The lower limit of the motor
  20419. */
  20420. setLimit(upperLimit: number, lowerLimit?: number): void;
  20421. }
  20422. /**
  20423. * This class represents a single physics Hinge-Joint
  20424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20425. */
  20426. export class HingeJoint extends MotorEnabledJoint {
  20427. /**
  20428. * Initializes the Hinge-Joint
  20429. * @param jointData The joint data for the Hinge-Joint
  20430. */
  20431. constructor(jointData: PhysicsJointData);
  20432. /**
  20433. * Set the motor values.
  20434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20435. * @param {number} force the force to apply
  20436. * @param {number} maxForce max force for this motor.
  20437. */
  20438. setMotor(force?: number, maxForce?: number): void;
  20439. /**
  20440. * Set the motor's limits.
  20441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20442. * @param upperLimit The upper limit of the motor
  20443. * @param lowerLimit The lower limit of the motor
  20444. */
  20445. setLimit(upperLimit: number, lowerLimit?: number): void;
  20446. }
  20447. /**
  20448. * This class represents a dual hinge physics joint (same as wheel joint)
  20449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20450. */
  20451. export class Hinge2Joint extends MotorEnabledJoint {
  20452. /**
  20453. * Initializes the Hinge2-Joint
  20454. * @param jointData The joint data for the Hinge2-Joint
  20455. */
  20456. constructor(jointData: PhysicsJointData);
  20457. /**
  20458. * Set the motor values.
  20459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20460. * @param {number} targetSpeed the speed the motor is to reach
  20461. * @param {number} maxForce max force for this motor.
  20462. * @param {motorIndex} the motor's index, 0 or 1.
  20463. */
  20464. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20465. /**
  20466. * Set the motor limits.
  20467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20468. * @param {number} upperLimit the upper limit
  20469. * @param {number} lowerLimit lower limit
  20470. * @param {motorIndex} the motor's index, 0 or 1.
  20471. */
  20472. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20473. }
  20474. /**
  20475. * Interface for a motor enabled joint
  20476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20477. */
  20478. export interface IMotorEnabledJoint {
  20479. /**
  20480. * Physics joint
  20481. */
  20482. physicsJoint: any;
  20483. /**
  20484. * Sets the motor of the motor-enabled joint
  20485. * @param force The force of the motor
  20486. * @param maxForce The maximum force of the motor
  20487. * @param motorIndex The index of the motor
  20488. */
  20489. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20490. /**
  20491. * Sets the limit of the motor
  20492. * @param upperLimit The upper limit of the motor
  20493. * @param lowerLimit The lower limit of the motor
  20494. * @param motorIndex The index of the motor
  20495. */
  20496. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20497. }
  20498. /**
  20499. * Joint data for a Distance-Joint
  20500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20501. */
  20502. export interface DistanceJointData extends PhysicsJointData {
  20503. /**
  20504. * Max distance the 2 joint objects can be apart
  20505. */
  20506. maxDistance: number;
  20507. }
  20508. /**
  20509. * Joint data from a spring joint
  20510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20511. */
  20512. export interface SpringJointData extends PhysicsJointData {
  20513. /**
  20514. * Length of the spring
  20515. */
  20516. length: number;
  20517. /**
  20518. * Stiffness of the spring
  20519. */
  20520. stiffness: number;
  20521. /**
  20522. * Damping of the spring
  20523. */
  20524. damping: number;
  20525. /** this callback will be called when applying the force to the impostors. */
  20526. forceApplicationCallback: () => void;
  20527. }
  20528. }
  20529. declare module "babylonjs/Physics/physicsRaycastResult" {
  20530. import { Vector3 } from "babylonjs/Maths/math";
  20531. /**
  20532. * Holds the data for the raycast result
  20533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20534. */
  20535. export class PhysicsRaycastResult {
  20536. private _hasHit;
  20537. private _hitDistance;
  20538. private _hitNormalWorld;
  20539. private _hitPointWorld;
  20540. private _rayFromWorld;
  20541. private _rayToWorld;
  20542. /**
  20543. * Gets if there was a hit
  20544. */
  20545. readonly hasHit: boolean;
  20546. /**
  20547. * Gets the distance from the hit
  20548. */
  20549. readonly hitDistance: number;
  20550. /**
  20551. * Gets the hit normal/direction in the world
  20552. */
  20553. readonly hitNormalWorld: Vector3;
  20554. /**
  20555. * Gets the hit point in the world
  20556. */
  20557. readonly hitPointWorld: Vector3;
  20558. /**
  20559. * Gets the ray "start point" of the ray in the world
  20560. */
  20561. readonly rayFromWorld: Vector3;
  20562. /**
  20563. * Gets the ray "end point" of the ray in the world
  20564. */
  20565. readonly rayToWorld: Vector3;
  20566. /**
  20567. * Sets the hit data (normal & point in world space)
  20568. * @param hitNormalWorld defines the normal in world space
  20569. * @param hitPointWorld defines the point in world space
  20570. */
  20571. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20572. /**
  20573. * Sets the distance from the start point to the hit point
  20574. * @param distance
  20575. */
  20576. setHitDistance(distance: number): void;
  20577. /**
  20578. * Calculates the distance manually
  20579. */
  20580. calculateHitDistance(): void;
  20581. /**
  20582. * Resets all the values to default
  20583. * @param from The from point on world space
  20584. * @param to The to point on world space
  20585. */
  20586. reset(from?: Vector3, to?: Vector3): void;
  20587. }
  20588. /**
  20589. * Interface for the size containing width and height
  20590. */
  20591. interface IXYZ {
  20592. /**
  20593. * X
  20594. */
  20595. x: number;
  20596. /**
  20597. * Y
  20598. */
  20599. y: number;
  20600. /**
  20601. * Z
  20602. */
  20603. z: number;
  20604. }
  20605. }
  20606. declare module "babylonjs/Physics/IPhysicsEngine" {
  20607. import { Nullable } from "babylonjs/types";
  20608. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20610. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20611. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20612. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20613. /**
  20614. * Interface used to describe a physics joint
  20615. */
  20616. export interface PhysicsImpostorJoint {
  20617. /** Defines the main impostor to which the joint is linked */
  20618. mainImpostor: PhysicsImpostor;
  20619. /** Defines the impostor that is connected to the main impostor using this joint */
  20620. connectedImpostor: PhysicsImpostor;
  20621. /** Defines the joint itself */
  20622. joint: PhysicsJoint;
  20623. }
  20624. /** @hidden */
  20625. export interface IPhysicsEnginePlugin {
  20626. world: any;
  20627. name: string;
  20628. setGravity(gravity: Vector3): void;
  20629. setTimeStep(timeStep: number): void;
  20630. getTimeStep(): number;
  20631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20635. removePhysicsBody(impostor: PhysicsImpostor): void;
  20636. generateJoint(joint: PhysicsImpostorJoint): void;
  20637. removeJoint(joint: PhysicsImpostorJoint): void;
  20638. isSupported(): boolean;
  20639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20646. getBodyMass(impostor: PhysicsImpostor): number;
  20647. getBodyFriction(impostor: PhysicsImpostor): number;
  20648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20649. getBodyRestitution(impostor: PhysicsImpostor): number;
  20650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20651. getBodyPressure?(impostor: PhysicsImpostor): number;
  20652. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20653. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20654. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20655. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20656. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20657. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20658. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20659. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20660. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20661. sleepBody(impostor: PhysicsImpostor): void;
  20662. wakeUpBody(impostor: PhysicsImpostor): void;
  20663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20665. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20667. getRadius(impostor: PhysicsImpostor): number;
  20668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20669. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20670. dispose(): void;
  20671. }
  20672. /**
  20673. * Interface used to define a physics engine
  20674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20675. */
  20676. export interface IPhysicsEngine {
  20677. /**
  20678. * Gets the gravity vector used by the simulation
  20679. */
  20680. gravity: Vector3;
  20681. /**
  20682. * Sets the gravity vector used by the simulation
  20683. * @param gravity defines the gravity vector to use
  20684. */
  20685. setGravity(gravity: Vector3): void;
  20686. /**
  20687. * Set the time step of the physics engine.
  20688. * Default is 1/60.
  20689. * To slow it down, enter 1/600 for example.
  20690. * To speed it up, 1/30
  20691. * @param newTimeStep the new timestep to apply to this world.
  20692. */
  20693. setTimeStep(newTimeStep: number): void;
  20694. /**
  20695. * Get the time step of the physics engine.
  20696. * @returns the current time step
  20697. */
  20698. getTimeStep(): number;
  20699. /**
  20700. * Release all resources
  20701. */
  20702. dispose(): void;
  20703. /**
  20704. * Gets the name of the current physics plugin
  20705. * @returns the name of the plugin
  20706. */
  20707. getPhysicsPluginName(): string;
  20708. /**
  20709. * Adding a new impostor for the impostor tracking.
  20710. * This will be done by the impostor itself.
  20711. * @param impostor the impostor to add
  20712. */
  20713. addImpostor(impostor: PhysicsImpostor): void;
  20714. /**
  20715. * Remove an impostor from the engine.
  20716. * This impostor and its mesh will not longer be updated by the physics engine.
  20717. * @param impostor the impostor to remove
  20718. */
  20719. removeImpostor(impostor: PhysicsImpostor): void;
  20720. /**
  20721. * Add a joint to the physics engine
  20722. * @param mainImpostor defines the main impostor to which the joint is added.
  20723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20724. * @param joint defines the joint that will connect both impostors.
  20725. */
  20726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20727. /**
  20728. * Removes a joint from the simulation
  20729. * @param mainImpostor defines the impostor used with the joint
  20730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20731. * @param joint defines the joint to remove
  20732. */
  20733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20734. /**
  20735. * Gets the current plugin used to run the simulation
  20736. * @returns current plugin
  20737. */
  20738. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20739. /**
  20740. * Gets the list of physic impostors
  20741. * @returns an array of PhysicsImpostor
  20742. */
  20743. getImpostors(): Array<PhysicsImpostor>;
  20744. /**
  20745. * Gets the impostor for a physics enabled object
  20746. * @param object defines the object impersonated by the impostor
  20747. * @returns the PhysicsImpostor or null if not found
  20748. */
  20749. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20750. /**
  20751. * Gets the impostor for a physics body object
  20752. * @param body defines physics body used by the impostor
  20753. * @returns the PhysicsImpostor or null if not found
  20754. */
  20755. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20756. /**
  20757. * Does a raycast in the physics world
  20758. * @param from when should the ray start?
  20759. * @param to when should the ray end?
  20760. * @returns PhysicsRaycastResult
  20761. */
  20762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20763. /**
  20764. * Called by the scene. No need to call it.
  20765. * @param delta defines the timespam between frames
  20766. */
  20767. _step(delta: number): void;
  20768. }
  20769. }
  20770. declare module "babylonjs/Physics/physicsImpostor" {
  20771. import { Nullable, IndicesArray } from "babylonjs/types";
  20772. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20773. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20775. import { Scene } from "babylonjs/scene";
  20776. import { Bone } from "babylonjs/Bones/bone";
  20777. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20778. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20779. /**
  20780. * The interface for the physics imposter parameters
  20781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20782. */
  20783. export interface PhysicsImpostorParameters {
  20784. /**
  20785. * The mass of the physics imposter
  20786. */
  20787. mass: number;
  20788. /**
  20789. * The friction of the physics imposter
  20790. */
  20791. friction?: number;
  20792. /**
  20793. * The coefficient of restitution of the physics imposter
  20794. */
  20795. restitution?: number;
  20796. /**
  20797. * The native options of the physics imposter
  20798. */
  20799. nativeOptions?: any;
  20800. /**
  20801. * Specifies if the parent should be ignored
  20802. */
  20803. ignoreParent?: boolean;
  20804. /**
  20805. * Specifies if bi-directional transformations should be disabled
  20806. */
  20807. disableBidirectionalTransformation?: boolean;
  20808. /**
  20809. * The pressure inside the physics imposter, soft object only
  20810. */
  20811. pressure?: number;
  20812. /**
  20813. * The stiffness the physics imposter, soft object only
  20814. */
  20815. stiffness?: number;
  20816. /**
  20817. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20818. */
  20819. velocityIterations?: number;
  20820. /**
  20821. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20822. */
  20823. positionIterations?: number;
  20824. /**
  20825. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20826. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20827. * Add to fix multiple points
  20828. */
  20829. fixedPoints?: number;
  20830. /**
  20831. * The collision margin around a soft object
  20832. */
  20833. margin?: number;
  20834. /**
  20835. * The collision margin around a soft object
  20836. */
  20837. damping?: number;
  20838. /**
  20839. * The path for a rope based on an extrusion
  20840. */
  20841. path?: any;
  20842. /**
  20843. * The shape of an extrusion used for a rope based on an extrusion
  20844. */
  20845. shape?: any;
  20846. }
  20847. /**
  20848. * Interface for a physics-enabled object
  20849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20850. */
  20851. export interface IPhysicsEnabledObject {
  20852. /**
  20853. * The position of the physics-enabled object
  20854. */
  20855. position: Vector3;
  20856. /**
  20857. * The rotation of the physics-enabled object
  20858. */
  20859. rotationQuaternion: Nullable<Quaternion>;
  20860. /**
  20861. * The scale of the physics-enabled object
  20862. */
  20863. scaling: Vector3;
  20864. /**
  20865. * The rotation of the physics-enabled object
  20866. */
  20867. rotation?: Vector3;
  20868. /**
  20869. * The parent of the physics-enabled object
  20870. */
  20871. parent?: any;
  20872. /**
  20873. * The bounding info of the physics-enabled object
  20874. * @returns The bounding info of the physics-enabled object
  20875. */
  20876. getBoundingInfo(): BoundingInfo;
  20877. /**
  20878. * Computes the world matrix
  20879. * @param force Specifies if the world matrix should be computed by force
  20880. * @returns A world matrix
  20881. */
  20882. computeWorldMatrix(force: boolean): Matrix;
  20883. /**
  20884. * Gets the world matrix
  20885. * @returns A world matrix
  20886. */
  20887. getWorldMatrix?(): Matrix;
  20888. /**
  20889. * Gets the child meshes
  20890. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20891. * @returns An array of abstract meshes
  20892. */
  20893. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20894. /**
  20895. * Gets the vertex data
  20896. * @param kind The type of vertex data
  20897. * @returns A nullable array of numbers, or a float32 array
  20898. */
  20899. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20900. /**
  20901. * Gets the indices from the mesh
  20902. * @returns A nullable array of index arrays
  20903. */
  20904. getIndices?(): Nullable<IndicesArray>;
  20905. /**
  20906. * Gets the scene from the mesh
  20907. * @returns the indices array or null
  20908. */
  20909. getScene?(): Scene;
  20910. /**
  20911. * Gets the absolute position from the mesh
  20912. * @returns the absolute position
  20913. */
  20914. getAbsolutePosition(): Vector3;
  20915. /**
  20916. * Gets the absolute pivot point from the mesh
  20917. * @returns the absolute pivot point
  20918. */
  20919. getAbsolutePivotPoint(): Vector3;
  20920. /**
  20921. * Rotates the mesh
  20922. * @param axis The axis of rotation
  20923. * @param amount The amount of rotation
  20924. * @param space The space of the rotation
  20925. * @returns The rotation transform node
  20926. */
  20927. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20928. /**
  20929. * Translates the mesh
  20930. * @param axis The axis of translation
  20931. * @param distance The distance of translation
  20932. * @param space The space of the translation
  20933. * @returns The transform node
  20934. */
  20935. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20936. /**
  20937. * Sets the absolute position of the mesh
  20938. * @param absolutePosition The absolute position of the mesh
  20939. * @returns The transform node
  20940. */
  20941. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20942. /**
  20943. * Gets the class name of the mesh
  20944. * @returns The class name
  20945. */
  20946. getClassName(): string;
  20947. }
  20948. /**
  20949. * Represents a physics imposter
  20950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20951. */
  20952. export class PhysicsImpostor {
  20953. /**
  20954. * The physics-enabled object used as the physics imposter
  20955. */
  20956. object: IPhysicsEnabledObject;
  20957. /**
  20958. * The type of the physics imposter
  20959. */
  20960. type: number;
  20961. private _options;
  20962. private _scene?;
  20963. /**
  20964. * The default object size of the imposter
  20965. */
  20966. static DEFAULT_OBJECT_SIZE: Vector3;
  20967. /**
  20968. * The identity quaternion of the imposter
  20969. */
  20970. static IDENTITY_QUATERNION: Quaternion;
  20971. /** @hidden */
  20972. _pluginData: any;
  20973. private _physicsEngine;
  20974. private _physicsBody;
  20975. private _bodyUpdateRequired;
  20976. private _onBeforePhysicsStepCallbacks;
  20977. private _onAfterPhysicsStepCallbacks;
  20978. /** @hidden */
  20979. _onPhysicsCollideCallbacks: Array<{
  20980. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20981. otherImpostors: Array<PhysicsImpostor>;
  20982. }>;
  20983. private _deltaPosition;
  20984. private _deltaRotation;
  20985. private _deltaRotationConjugated;
  20986. /** hidden */
  20987. _isFromLine: boolean;
  20988. private _parent;
  20989. private _isDisposed;
  20990. private static _tmpVecs;
  20991. private static _tmpQuat;
  20992. /**
  20993. * Specifies if the physics imposter is disposed
  20994. */
  20995. readonly isDisposed: boolean;
  20996. /**
  20997. * Gets the mass of the physics imposter
  20998. */
  20999. mass: number;
  21000. /**
  21001. * Gets the coefficient of friction
  21002. */
  21003. /**
  21004. * Sets the coefficient of friction
  21005. */
  21006. friction: number;
  21007. /**
  21008. * Gets the coefficient of restitution
  21009. */
  21010. /**
  21011. * Sets the coefficient of restitution
  21012. */
  21013. restitution: number;
  21014. /**
  21015. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21016. */
  21017. /**
  21018. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21019. */
  21020. pressure: number;
  21021. /**
  21022. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21023. */
  21024. /**
  21025. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21026. */
  21027. stiffness: number;
  21028. /**
  21029. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21030. */
  21031. /**
  21032. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21033. */
  21034. velocityIterations: number;
  21035. /**
  21036. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21037. */
  21038. /**
  21039. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21040. */
  21041. positionIterations: number;
  21042. /**
  21043. * The unique id of the physics imposter
  21044. * set by the physics engine when adding this impostor to the array
  21045. */
  21046. uniqueId: number;
  21047. /**
  21048. * @hidden
  21049. */
  21050. soft: boolean;
  21051. /**
  21052. * @hidden
  21053. */
  21054. segments: number;
  21055. private _joints;
  21056. /**
  21057. * Initializes the physics imposter
  21058. * @param object The physics-enabled object used as the physics imposter
  21059. * @param type The type of the physics imposter
  21060. * @param _options The options for the physics imposter
  21061. * @param _scene The Babylon scene
  21062. */
  21063. constructor(
  21064. /**
  21065. * The physics-enabled object used as the physics imposter
  21066. */
  21067. object: IPhysicsEnabledObject,
  21068. /**
  21069. * The type of the physics imposter
  21070. */
  21071. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21072. /**
  21073. * This function will completly initialize this impostor.
  21074. * It will create a new body - but only if this mesh has no parent.
  21075. * If it has, this impostor will not be used other than to define the impostor
  21076. * of the child mesh.
  21077. * @hidden
  21078. */
  21079. _init(): void;
  21080. private _getPhysicsParent;
  21081. /**
  21082. * Should a new body be generated.
  21083. * @returns boolean specifying if body initialization is required
  21084. */
  21085. isBodyInitRequired(): boolean;
  21086. /**
  21087. * Sets the updated scaling
  21088. * @param updated Specifies if the scaling is updated
  21089. */
  21090. setScalingUpdated(): void;
  21091. /**
  21092. * Force a regeneration of this or the parent's impostor's body.
  21093. * Use under cautious - This will remove all joints already implemented.
  21094. */
  21095. forceUpdate(): void;
  21096. /**
  21097. * Gets the body that holds this impostor. Either its own, or its parent.
  21098. */
  21099. /**
  21100. * Set the physics body. Used mainly by the physics engine/plugin
  21101. */
  21102. physicsBody: any;
  21103. /**
  21104. * Get the parent of the physics imposter
  21105. * @returns Physics imposter or null
  21106. */
  21107. /**
  21108. * Sets the parent of the physics imposter
  21109. */
  21110. parent: Nullable<PhysicsImpostor>;
  21111. /**
  21112. * Resets the update flags
  21113. */
  21114. resetUpdateFlags(): void;
  21115. /**
  21116. * Gets the object extend size
  21117. * @returns the object extend size
  21118. */
  21119. getObjectExtendSize(): Vector3;
  21120. /**
  21121. * Gets the object center
  21122. * @returns The object center
  21123. */
  21124. getObjectCenter(): Vector3;
  21125. /**
  21126. * Get a specific parametes from the options parameter
  21127. * @param paramName The object parameter name
  21128. * @returns The object parameter
  21129. */
  21130. getParam(paramName: string): any;
  21131. /**
  21132. * Sets a specific parameter in the options given to the physics plugin
  21133. * @param paramName The parameter name
  21134. * @param value The value of the parameter
  21135. */
  21136. setParam(paramName: string, value: number): void;
  21137. /**
  21138. * Specifically change the body's mass option. Won't recreate the physics body object
  21139. * @param mass The mass of the physics imposter
  21140. */
  21141. setMass(mass: number): void;
  21142. /**
  21143. * Gets the linear velocity
  21144. * @returns linear velocity or null
  21145. */
  21146. getLinearVelocity(): Nullable<Vector3>;
  21147. /**
  21148. * Sets the linear velocity
  21149. * @param velocity linear velocity or null
  21150. */
  21151. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21152. /**
  21153. * Gets the angular velocity
  21154. * @returns angular velocity or null
  21155. */
  21156. getAngularVelocity(): Nullable<Vector3>;
  21157. /**
  21158. * Sets the angular velocity
  21159. * @param velocity The velocity or null
  21160. */
  21161. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21162. /**
  21163. * Execute a function with the physics plugin native code
  21164. * Provide a function the will have two variables - the world object and the physics body object
  21165. * @param func The function to execute with the physics plugin native code
  21166. */
  21167. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21168. /**
  21169. * Register a function that will be executed before the physics world is stepping forward
  21170. * @param func The function to execute before the physics world is stepped forward
  21171. */
  21172. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21173. /**
  21174. * Unregister a function that will be executed before the physics world is stepping forward
  21175. * @param func The function to execute before the physics world is stepped forward
  21176. */
  21177. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21178. /**
  21179. * Register a function that will be executed after the physics step
  21180. * @param func The function to execute after physics step
  21181. */
  21182. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21183. /**
  21184. * Unregisters a function that will be executed after the physics step
  21185. * @param func The function to execute after physics step
  21186. */
  21187. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21188. /**
  21189. * register a function that will be executed when this impostor collides against a different body
  21190. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21191. * @param func Callback that is executed on collision
  21192. */
  21193. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21194. /**
  21195. * Unregisters the physics imposter on contact
  21196. * @param collideAgainst The physics object to collide against
  21197. * @param func Callback to execute on collision
  21198. */
  21199. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21200. private _tmpQuat;
  21201. private _tmpQuat2;
  21202. /**
  21203. * Get the parent rotation
  21204. * @returns The parent rotation
  21205. */
  21206. getParentsRotation(): Quaternion;
  21207. /**
  21208. * this function is executed by the physics engine.
  21209. */
  21210. beforeStep: () => void;
  21211. /**
  21212. * this function is executed by the physics engine
  21213. */
  21214. afterStep: () => void;
  21215. /**
  21216. * Legacy collision detection event support
  21217. */
  21218. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21219. /**
  21220. * event and body object due to cannon's event-based architecture.
  21221. */
  21222. onCollide: (e: {
  21223. body: any;
  21224. }) => void;
  21225. /**
  21226. * Apply a force
  21227. * @param force The force to apply
  21228. * @param contactPoint The contact point for the force
  21229. * @returns The physics imposter
  21230. */
  21231. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21232. /**
  21233. * Apply an impulse
  21234. * @param force The impulse force
  21235. * @param contactPoint The contact point for the impulse force
  21236. * @returns The physics imposter
  21237. */
  21238. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21239. /**
  21240. * A help function to create a joint
  21241. * @param otherImpostor A physics imposter used to create a joint
  21242. * @param jointType The type of joint
  21243. * @param jointData The data for the joint
  21244. * @returns The physics imposter
  21245. */
  21246. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21247. /**
  21248. * Add a joint to this impostor with a different impostor
  21249. * @param otherImpostor A physics imposter used to add a joint
  21250. * @param joint The joint to add
  21251. * @returns The physics imposter
  21252. */
  21253. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21254. /**
  21255. * Add an anchor to a cloth impostor
  21256. * @param otherImpostor rigid impostor to anchor to
  21257. * @param width ratio across width from 0 to 1
  21258. * @param height ratio up height from 0 to 1
  21259. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21260. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21261. * @returns impostor the soft imposter
  21262. */
  21263. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21264. /**
  21265. * Add a hook to a rope impostor
  21266. * @param otherImpostor rigid impostor to anchor to
  21267. * @param length ratio across rope from 0 to 1
  21268. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21269. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21270. * @returns impostor the rope imposter
  21271. */
  21272. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21273. /**
  21274. * Will keep this body still, in a sleep mode.
  21275. * @returns the physics imposter
  21276. */
  21277. sleep(): PhysicsImpostor;
  21278. /**
  21279. * Wake the body up.
  21280. * @returns The physics imposter
  21281. */
  21282. wakeUp(): PhysicsImpostor;
  21283. /**
  21284. * Clones the physics imposter
  21285. * @param newObject The physics imposter clones to this physics-enabled object
  21286. * @returns A nullable physics imposter
  21287. */
  21288. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21289. /**
  21290. * Disposes the physics imposter
  21291. */
  21292. dispose(): void;
  21293. /**
  21294. * Sets the delta position
  21295. * @param position The delta position amount
  21296. */
  21297. setDeltaPosition(position: Vector3): void;
  21298. /**
  21299. * Sets the delta rotation
  21300. * @param rotation The delta rotation amount
  21301. */
  21302. setDeltaRotation(rotation: Quaternion): void;
  21303. /**
  21304. * Gets the box size of the physics imposter and stores the result in the input parameter
  21305. * @param result Stores the box size
  21306. * @returns The physics imposter
  21307. */
  21308. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21309. /**
  21310. * Gets the radius of the physics imposter
  21311. * @returns Radius of the physics imposter
  21312. */
  21313. getRadius(): number;
  21314. /**
  21315. * Sync a bone with this impostor
  21316. * @param bone The bone to sync to the impostor.
  21317. * @param boneMesh The mesh that the bone is influencing.
  21318. * @param jointPivot The pivot of the joint / bone in local space.
  21319. * @param distToJoint Optional distance from the impostor to the joint.
  21320. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21321. */
  21322. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21323. /**
  21324. * Sync impostor to a bone
  21325. * @param bone The bone that the impostor will be synced to.
  21326. * @param boneMesh The mesh that the bone is influencing.
  21327. * @param jointPivot The pivot of the joint / bone in local space.
  21328. * @param distToJoint Optional distance from the impostor to the joint.
  21329. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21330. * @param boneAxis Optional vector3 axis the bone is aligned with
  21331. */
  21332. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21333. /**
  21334. * No-Imposter type
  21335. */
  21336. static NoImpostor: number;
  21337. /**
  21338. * Sphere-Imposter type
  21339. */
  21340. static SphereImpostor: number;
  21341. /**
  21342. * Box-Imposter type
  21343. */
  21344. static BoxImpostor: number;
  21345. /**
  21346. * Plane-Imposter type
  21347. */
  21348. static PlaneImpostor: number;
  21349. /**
  21350. * Mesh-imposter type
  21351. */
  21352. static MeshImpostor: number;
  21353. /**
  21354. * Cylinder-Imposter type
  21355. */
  21356. static CylinderImpostor: number;
  21357. /**
  21358. * Particle-Imposter type
  21359. */
  21360. static ParticleImpostor: number;
  21361. /**
  21362. * Heightmap-Imposter type
  21363. */
  21364. static HeightmapImpostor: number;
  21365. /**
  21366. * ConvexHull-Impostor type (Ammo.js plugin only)
  21367. */
  21368. static ConvexHullImpostor: number;
  21369. /**
  21370. * Rope-Imposter type
  21371. */
  21372. static RopeImpostor: number;
  21373. /**
  21374. * Cloth-Imposter type
  21375. */
  21376. static ClothImpostor: number;
  21377. /**
  21378. * Softbody-Imposter type
  21379. */
  21380. static SoftbodyImpostor: number;
  21381. }
  21382. }
  21383. declare module "babylonjs/Meshes/mesh" {
  21384. import { Observable } from "babylonjs/Misc/observable";
  21385. import { IAnimatable } from "babylonjs/Misc/tools";
  21386. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21387. import { Camera } from "babylonjs/Cameras/camera";
  21388. import { Scene } from "babylonjs/scene";
  21389. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21390. import { Engine } from "babylonjs/Engines/engine";
  21391. import { Node } from "babylonjs/node";
  21392. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21393. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21394. import { Buffer } from "babylonjs/Meshes/buffer";
  21395. import { Geometry } from "babylonjs/Meshes/geometry";
  21396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21397. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21398. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21399. import { Effect } from "babylonjs/Materials/effect";
  21400. import { Material } from "babylonjs/Materials/material";
  21401. import { Skeleton } from "babylonjs/Bones/skeleton";
  21402. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21403. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21404. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21405. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21406. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21407. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21408. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21409. /**
  21410. * @hidden
  21411. **/
  21412. export class _CreationDataStorage {
  21413. closePath?: boolean;
  21414. closeArray?: boolean;
  21415. idx: number[];
  21416. dashSize: number;
  21417. gapSize: number;
  21418. path3D: Path3D;
  21419. pathArray: Vector3[][];
  21420. arc: number;
  21421. radius: number;
  21422. cap: number;
  21423. tessellation: number;
  21424. }
  21425. /**
  21426. * @hidden
  21427. **/
  21428. class _InstanceDataStorage {
  21429. visibleInstances: any;
  21430. batchCache: _InstancesBatch;
  21431. instancesBufferSize: number;
  21432. instancesBuffer: Nullable<Buffer>;
  21433. instancesData: Float32Array;
  21434. overridenInstanceCount: number;
  21435. isFrozen: boolean;
  21436. previousBatch: _InstancesBatch;
  21437. hardwareInstancedRendering: boolean;
  21438. sideOrientation: number;
  21439. }
  21440. /**
  21441. * @hidden
  21442. **/
  21443. export class _InstancesBatch {
  21444. mustReturn: boolean;
  21445. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21446. renderSelf: boolean[];
  21447. hardwareInstancedRendering: boolean[];
  21448. }
  21449. /**
  21450. * Class used to represent renderable models
  21451. */
  21452. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21453. /**
  21454. * Mesh side orientation : usually the external or front surface
  21455. */
  21456. static readonly FRONTSIDE: number;
  21457. /**
  21458. * Mesh side orientation : usually the internal or back surface
  21459. */
  21460. static readonly BACKSIDE: number;
  21461. /**
  21462. * Mesh side orientation : both internal and external or front and back surfaces
  21463. */
  21464. static readonly DOUBLESIDE: number;
  21465. /**
  21466. * Mesh side orientation : by default, `FRONTSIDE`
  21467. */
  21468. static readonly DEFAULTSIDE: number;
  21469. /**
  21470. * Mesh cap setting : no cap
  21471. */
  21472. static readonly NO_CAP: number;
  21473. /**
  21474. * Mesh cap setting : one cap at the beginning of the mesh
  21475. */
  21476. static readonly CAP_START: number;
  21477. /**
  21478. * Mesh cap setting : one cap at the end of the mesh
  21479. */
  21480. static readonly CAP_END: number;
  21481. /**
  21482. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21483. */
  21484. static readonly CAP_ALL: number;
  21485. /**
  21486. * Gets the default side orientation.
  21487. * @param orientation the orientation to value to attempt to get
  21488. * @returns the default orientation
  21489. * @hidden
  21490. */
  21491. static _GetDefaultSideOrientation(orientation?: number): number;
  21492. private _internalMeshDataInfo;
  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. /**
  21533. * User defined function used to change how LOD level selection is done
  21534. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21535. */
  21536. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21537. /**
  21538. * Gets or sets the morph target manager
  21539. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21540. */
  21541. morphTargetManager: Nullable<MorphTargetManager>;
  21542. /** @hidden */
  21543. _creationDataStorage: Nullable<_CreationDataStorage>;
  21544. /** @hidden */
  21545. _geometry: Nullable<Geometry>;
  21546. /** @hidden */
  21547. _delayInfo: Array<string>;
  21548. /** @hidden */
  21549. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21550. /** @hidden */
  21551. _instanceDataStorage: _InstanceDataStorage;
  21552. private _effectiveMaterial;
  21553. /** @hidden */
  21554. _shouldGenerateFlatShading: boolean;
  21555. /** @hidden */
  21556. _originalBuilderSideOrientation: number;
  21557. /**
  21558. * Use this property to change the original side orientation defined at construction time
  21559. */
  21560. overrideMaterialSideOrientation: Nullable<number>;
  21561. /**
  21562. * Gets the source mesh (the one used to clone this one from)
  21563. */
  21564. readonly source: Nullable<Mesh>;
  21565. /**
  21566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21567. */
  21568. isUnIndexed: boolean;
  21569. /**
  21570. * @constructor
  21571. * @param name The value used by scene.getMeshByName() to do a lookup.
  21572. * @param scene The scene to add this mesh to.
  21573. * @param parent The parent of this mesh, if it has one
  21574. * @param source An optional Mesh from which geometry is shared, cloned.
  21575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21576. * When false, achieved by calling a clone(), also passing False.
  21577. * This will make creation of children, recursive.
  21578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21579. */
  21580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21581. /**
  21582. * Gets the class name
  21583. * @returns the string "Mesh".
  21584. */
  21585. getClassName(): string;
  21586. /** @hidden */
  21587. readonly _isMesh: boolean;
  21588. /**
  21589. * Returns a description of this mesh
  21590. * @param fullDetails define if full details about this mesh must be used
  21591. * @returns a descriptive string representing this mesh
  21592. */
  21593. toString(fullDetails?: boolean): string;
  21594. /** @hidden */
  21595. _unBindEffect(): void;
  21596. /**
  21597. * Gets a boolean indicating if this mesh has LOD
  21598. */
  21599. readonly hasLODLevels: boolean;
  21600. /**
  21601. * Gets the list of MeshLODLevel associated with the current mesh
  21602. * @returns an array of MeshLODLevel
  21603. */
  21604. getLODLevels(): MeshLODLevel[];
  21605. private _sortLODLevels;
  21606. /**
  21607. * Add a mesh as LOD level triggered at the given distance.
  21608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21609. * @param distance The distance from the center of the object to show this level
  21610. * @param mesh The mesh to be added as LOD level (can be null)
  21611. * @return This mesh (for chaining)
  21612. */
  21613. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21614. /**
  21615. * Returns the LOD level mesh at the passed distance or null if not found.
  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. * @returns a Mesh or `null`
  21619. */
  21620. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21621. /**
  21622. * Remove a mesh from the LOD array
  21623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21624. * @param mesh defines the mesh to be removed
  21625. * @return This mesh (for chaining)
  21626. */
  21627. removeLODLevel(mesh: Mesh): Mesh;
  21628. /**
  21629. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21630. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21631. * @param camera defines the camera to use to compute distance
  21632. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21633. * @return This mesh (for chaining)
  21634. */
  21635. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21636. /**
  21637. * Gets the mesh internal Geometry object
  21638. */
  21639. readonly geometry: Nullable<Geometry>;
  21640. /**
  21641. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21642. * @returns the total number of vertices
  21643. */
  21644. getTotalVertices(): number;
  21645. /**
  21646. * Returns the content of an associated vertex buffer
  21647. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21648. * - VertexBuffer.PositionKind
  21649. * - VertexBuffer.UVKind
  21650. * - VertexBuffer.UV2Kind
  21651. * - VertexBuffer.UV3Kind
  21652. * - VertexBuffer.UV4Kind
  21653. * - VertexBuffer.UV5Kind
  21654. * - VertexBuffer.UV6Kind
  21655. * - VertexBuffer.ColorKind
  21656. * - VertexBuffer.MatricesIndicesKind
  21657. * - VertexBuffer.MatricesIndicesExtraKind
  21658. * - VertexBuffer.MatricesWeightsKind
  21659. * - VertexBuffer.MatricesWeightsExtraKind
  21660. * @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
  21661. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21662. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21663. */
  21664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21665. /**
  21666. * Returns the mesh VertexBuffer object from the requested `kind`
  21667. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21668. * - VertexBuffer.PositionKind
  21669. * - VertexBuffer.UVKind
  21670. * - VertexBuffer.UV2Kind
  21671. * - VertexBuffer.UV3Kind
  21672. * - VertexBuffer.UV4Kind
  21673. * - VertexBuffer.UV5Kind
  21674. * - VertexBuffer.UV6Kind
  21675. * - VertexBuffer.ColorKind
  21676. * - VertexBuffer.MatricesIndicesKind
  21677. * - VertexBuffer.MatricesIndicesExtraKind
  21678. * - VertexBuffer.MatricesWeightsKind
  21679. * - VertexBuffer.MatricesWeightsExtraKind
  21680. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21681. */
  21682. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21683. /**
  21684. * Tests if a specific vertex buffer is associated with this mesh
  21685. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21686. * - VertexBuffer.PositionKind
  21687. * - VertexBuffer.UVKind
  21688. * - VertexBuffer.UV2Kind
  21689. * - VertexBuffer.UV3Kind
  21690. * - VertexBuffer.UV4Kind
  21691. * - VertexBuffer.UV5Kind
  21692. * - VertexBuffer.UV6Kind
  21693. * - VertexBuffer.ColorKind
  21694. * - VertexBuffer.MatricesIndicesKind
  21695. * - VertexBuffer.MatricesIndicesExtraKind
  21696. * - VertexBuffer.MatricesWeightsKind
  21697. * - VertexBuffer.MatricesWeightsExtraKind
  21698. * @returns a boolean
  21699. */
  21700. isVerticesDataPresent(kind: string): boolean;
  21701. /**
  21702. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21703. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21704. * - VertexBuffer.PositionKind
  21705. * - VertexBuffer.UVKind
  21706. * - VertexBuffer.UV2Kind
  21707. * - VertexBuffer.UV3Kind
  21708. * - VertexBuffer.UV4Kind
  21709. * - VertexBuffer.UV5Kind
  21710. * - VertexBuffer.UV6Kind
  21711. * - VertexBuffer.ColorKind
  21712. * - VertexBuffer.MatricesIndicesKind
  21713. * - VertexBuffer.MatricesIndicesExtraKind
  21714. * - VertexBuffer.MatricesWeightsKind
  21715. * - VertexBuffer.MatricesWeightsExtraKind
  21716. * @returns a boolean
  21717. */
  21718. isVertexBufferUpdatable(kind: string): boolean;
  21719. /**
  21720. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21722. * - VertexBuffer.PositionKind
  21723. * - VertexBuffer.UVKind
  21724. * - VertexBuffer.UV2Kind
  21725. * - VertexBuffer.UV3Kind
  21726. * - VertexBuffer.UV4Kind
  21727. * - VertexBuffer.UV5Kind
  21728. * - VertexBuffer.UV6Kind
  21729. * - VertexBuffer.ColorKind
  21730. * - VertexBuffer.MatricesIndicesKind
  21731. * - VertexBuffer.MatricesIndicesExtraKind
  21732. * - VertexBuffer.MatricesWeightsKind
  21733. * - VertexBuffer.MatricesWeightsExtraKind
  21734. * @returns an array of strings
  21735. */
  21736. getVerticesDataKinds(): string[];
  21737. /**
  21738. * Returns a positive integer : the total number of indices in this mesh geometry.
  21739. * @returns the numner of indices or zero if the mesh has no geometry.
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21744. * @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.
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the indices array or an empty array if the mesh has no geometry
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. readonly isBlocked: boolean;
  21750. /**
  21751. * Determine if the current mesh is ready to be rendered
  21752. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21753. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21754. * @returns true if all associated assets are ready (material, textures, shaders)
  21755. */
  21756. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21757. /**
  21758. * 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.
  21759. */
  21760. readonly areNormalsFrozen: boolean;
  21761. /**
  21762. * 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.
  21763. * @returns the current mesh
  21764. */
  21765. freezeNormals(): Mesh;
  21766. /**
  21767. * 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
  21768. * @returns the current mesh
  21769. */
  21770. unfreezeNormals(): Mesh;
  21771. /**
  21772. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21773. */
  21774. overridenInstanceCount: number;
  21775. /** @hidden */
  21776. _preActivate(): Mesh;
  21777. /** @hidden */
  21778. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21779. /** @hidden */
  21780. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21781. /**
  21782. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21783. * This means the mesh underlying bounding box and sphere are recomputed.
  21784. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21785. * @returns the current mesh
  21786. */
  21787. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21788. /** @hidden */
  21789. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21790. /**
  21791. * This function will subdivide the mesh into multiple submeshes
  21792. * @param count defines the expected number of submeshes
  21793. */
  21794. subdivide(count: number): void;
  21795. /**
  21796. * Copy a FloatArray into a specific associated vertex buffer
  21797. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21798. * - VertexBuffer.PositionKind
  21799. * - VertexBuffer.UVKind
  21800. * - VertexBuffer.UV2Kind
  21801. * - VertexBuffer.UV3Kind
  21802. * - VertexBuffer.UV4Kind
  21803. * - VertexBuffer.UV5Kind
  21804. * - VertexBuffer.UV6Kind
  21805. * - VertexBuffer.ColorKind
  21806. * - VertexBuffer.MatricesIndicesKind
  21807. * - VertexBuffer.MatricesIndicesExtraKind
  21808. * - VertexBuffer.MatricesWeightsKind
  21809. * - VertexBuffer.MatricesWeightsExtraKind
  21810. * @param data defines the data source
  21811. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21812. * @param stride defines the data stride size (can be null)
  21813. * @returns the current mesh
  21814. */
  21815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21816. /**
  21817. * Flags an associated vertex buffer as updatable
  21818. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21819. * - VertexBuffer.PositionKind
  21820. * - VertexBuffer.UVKind
  21821. * - VertexBuffer.UV2Kind
  21822. * - VertexBuffer.UV3Kind
  21823. * - VertexBuffer.UV4Kind
  21824. * - VertexBuffer.UV5Kind
  21825. * - VertexBuffer.UV6Kind
  21826. * - VertexBuffer.ColorKind
  21827. * - VertexBuffer.MatricesIndicesKind
  21828. * - VertexBuffer.MatricesIndicesExtraKind
  21829. * - VertexBuffer.MatricesWeightsKind
  21830. * - VertexBuffer.MatricesWeightsExtraKind
  21831. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21832. */
  21833. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21834. /**
  21835. * Sets the mesh global Vertex Buffer
  21836. * @param buffer defines the buffer to use
  21837. * @returns the current mesh
  21838. */
  21839. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21840. /**
  21841. * Update a specific associated vertex buffer
  21842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21843. * - VertexBuffer.PositionKind
  21844. * - VertexBuffer.UVKind
  21845. * - VertexBuffer.UV2Kind
  21846. * - VertexBuffer.UV3Kind
  21847. * - VertexBuffer.UV4Kind
  21848. * - VertexBuffer.UV5Kind
  21849. * - VertexBuffer.UV6Kind
  21850. * - VertexBuffer.ColorKind
  21851. * - VertexBuffer.MatricesIndicesKind
  21852. * - VertexBuffer.MatricesIndicesExtraKind
  21853. * - VertexBuffer.MatricesWeightsKind
  21854. * - VertexBuffer.MatricesWeightsExtraKind
  21855. * @param data defines the data source
  21856. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21857. * @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)
  21858. * @returns the current mesh
  21859. */
  21860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21861. /**
  21862. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21863. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21864. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21865. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21866. * @returns the current mesh
  21867. */
  21868. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21869. /**
  21870. * Creates a un-shared specific occurence of the geometry for the mesh.
  21871. * @returns the current mesh
  21872. */
  21873. makeGeometryUnique(): Mesh;
  21874. /**
  21875. * Set the index buffer of this mesh
  21876. * @param indices defines the source data
  21877. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21878. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21879. * @returns the current mesh
  21880. */
  21881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21882. /**
  21883. * Update the current index buffer
  21884. * @param indices defines the source data
  21885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21886. * @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)
  21887. * @returns the current mesh
  21888. */
  21889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21890. /**
  21891. * Invert the geometry to move from a right handed system to a left handed one.
  21892. * @returns the current mesh
  21893. */
  21894. toLeftHanded(): Mesh;
  21895. /** @hidden */
  21896. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21897. /** @hidden */
  21898. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21899. /**
  21900. * Registers for this mesh a javascript function called just before the rendering process
  21901. * @param func defines the function to call before rendering this mesh
  21902. * @returns the current mesh
  21903. */
  21904. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21905. /**
  21906. * Disposes a previously registered javascript function called before the rendering
  21907. * @param func defines the function to remove
  21908. * @returns the current mesh
  21909. */
  21910. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21911. /**
  21912. * Registers for this mesh a javascript function called just after the rendering is complete
  21913. * @param func defines the function to call after rendering this mesh
  21914. * @returns the current mesh
  21915. */
  21916. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21917. /**
  21918. * Disposes a previously registered javascript function called after the rendering.
  21919. * @param func defines the function to remove
  21920. * @returns the current mesh
  21921. */
  21922. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21923. /** @hidden */
  21924. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21925. /** @hidden */
  21926. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21927. /** @hidden */
  21928. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21929. /** @hidden */
  21930. _freeze(): void;
  21931. /** @hidden */
  21932. _unFreeze(): void;
  21933. /**
  21934. * 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
  21935. * @param subMesh defines the subMesh to render
  21936. * @param enableAlphaMode defines if alpha mode can be changed
  21937. * @returns the current mesh
  21938. */
  21939. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21940. private _onBeforeDraw;
  21941. /**
  21942. * Renormalize the mesh and patch it up if there are no weights
  21943. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21944. * However in the case of zero weights then we set just a single influence to 1.
  21945. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21946. */
  21947. cleanMatrixWeights(): void;
  21948. private normalizeSkinFourWeights;
  21949. private normalizeSkinWeightsAndExtra;
  21950. /**
  21951. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21952. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21953. * the user know there was an issue with importing the mesh
  21954. * @returns a validation object with skinned, valid and report string
  21955. */
  21956. validateSkinning(): {
  21957. skinned: boolean;
  21958. valid: boolean;
  21959. report: string;
  21960. };
  21961. /** @hidden */
  21962. _checkDelayState(): Mesh;
  21963. private _queueLoad;
  21964. /**
  21965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21966. * A mesh is in the frustum if its bounding box intersects the frustum
  21967. * @param frustumPlanes defines the frustum to test
  21968. * @returns true if the mesh is in the frustum planes
  21969. */
  21970. isInFrustum(frustumPlanes: Plane[]): boolean;
  21971. /**
  21972. * Sets the mesh material by the material or multiMaterial `id` property
  21973. * @param id is a string identifying the material or the multiMaterial
  21974. * @returns the current mesh
  21975. */
  21976. setMaterialByID(id: string): Mesh;
  21977. /**
  21978. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21979. * @returns an array of IAnimatable
  21980. */
  21981. getAnimatables(): IAnimatable[];
  21982. /**
  21983. * Modifies the mesh geometry according to the passed transformation matrix.
  21984. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21985. * The mesh normals are modified using the same transformation.
  21986. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21987. * @param transform defines the transform matrix to use
  21988. * @see http://doc.babylonjs.com/resources/baking_transformations
  21989. * @returns the current mesh
  21990. */
  21991. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21992. /**
  21993. * Modifies the mesh geometry according to its own current World Matrix.
  21994. * The mesh World Matrix is then reset.
  21995. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21997. * @see http://doc.babylonjs.com/resources/baking_transformations
  21998. * @returns the current mesh
  21999. */
  22000. bakeCurrentTransformIntoVertices(): Mesh;
  22001. /** @hidden */
  22002. readonly _positions: Nullable<Vector3[]>;
  22003. /** @hidden */
  22004. _resetPointsArrayCache(): Mesh;
  22005. /** @hidden */
  22006. _generatePointsArray(): boolean;
  22007. /**
  22008. * Returns a new Mesh object generated from the current mesh properties.
  22009. * This method must not get confused with createInstance()
  22010. * @param name is a string, the name given to the new mesh
  22011. * @param newParent can be any Node object (default `null`)
  22012. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22013. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22014. * @returns a new mesh
  22015. */
  22016. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22017. /**
  22018. * Releases resources associated with this mesh.
  22019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22021. */
  22022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22023. /**
  22024. * Modifies the mesh geometry according to a displacement map.
  22025. * 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.
  22026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22027. * @param url is a string, the URL from the image file is to be downloaded.
  22028. * @param minHeight is the lower limit of the displacement.
  22029. * @param maxHeight is the upper limit of the displacement.
  22030. * @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.
  22031. * @param uvOffset is an optional vector2 used to offset UV.
  22032. * @param uvScale is an optional vector2 used to scale UV.
  22033. * @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.
  22034. * @returns the Mesh.
  22035. */
  22036. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22037. /**
  22038. * Modifies the mesh geometry according to a displacementMap buffer.
  22039. * 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.
  22040. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22041. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22042. * @param heightMapWidth is the width of the buffer image.
  22043. * @param heightMapHeight is the height of the buffer image.
  22044. * @param minHeight is the lower limit of the displacement.
  22045. * @param maxHeight is the upper limit of the displacement.
  22046. * @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.
  22047. * @param uvOffset is an optional vector2 used to offset UV.
  22048. * @param uvScale is an optional vector2 used to scale UV.
  22049. * @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.
  22050. * @returns the Mesh.
  22051. */
  22052. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22053. /**
  22054. * Modify the mesh to get a flat shading rendering.
  22055. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22056. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22057. * @returns current mesh
  22058. */
  22059. convertToFlatShadedMesh(): Mesh;
  22060. /**
  22061. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22062. * In other words, more vertices, no more indices and a single bigger VBO.
  22063. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22064. * @returns current mesh
  22065. */
  22066. convertToUnIndexedMesh(): Mesh;
  22067. /**
  22068. * Inverses facet orientations.
  22069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22070. * @param flipNormals will also inverts the normals
  22071. * @returns current mesh
  22072. */
  22073. flipFaces(flipNormals?: boolean): Mesh;
  22074. /**
  22075. * Increase the number of facets and hence vertices in a mesh
  22076. * Vertex normals are interpolated from existing vertex normals
  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 numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22079. */
  22080. increaseVertices(numberPerEdge: number): void;
  22081. /**
  22082. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22083. * This will undo any application of covertToFlatShadedMesh
  22084. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22085. */
  22086. forceSharedVertices(): void;
  22087. /** @hidden */
  22088. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22089. /** @hidden */
  22090. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22091. /**
  22092. * Creates a new InstancedMesh object from the mesh model.
  22093. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22094. * @param name defines the name of the new instance
  22095. * @returns a new InstancedMesh
  22096. */
  22097. createInstance(name: string): InstancedMesh;
  22098. /**
  22099. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22100. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22101. * @returns the current mesh
  22102. */
  22103. synchronizeInstances(): Mesh;
  22104. /**
  22105. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22106. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22107. * This should be used together with the simplification to avoid disappearing triangles.
  22108. * @param successCallback an optional success callback to be called after the optimization finished.
  22109. * @returns the current mesh
  22110. */
  22111. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22112. /**
  22113. * Serialize current mesh
  22114. * @param serializationObject defines the object which will receive the serialization data
  22115. */
  22116. serialize(serializationObject: any): void;
  22117. /** @hidden */
  22118. _syncGeometryWithMorphTargetManager(): void;
  22119. /** @hidden */
  22120. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22121. /**
  22122. * Returns a new Mesh object parsed from the source provided.
  22123. * @param parsedMesh is the source
  22124. * @param scene defines the hosting scene
  22125. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22126. * @returns a new Mesh
  22127. */
  22128. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22129. /**
  22130. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22132. * @param name defines the name of the mesh to create
  22133. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22134. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22135. * @param closePath creates a seam between the first and the last points of each path of the path array
  22136. * @param offset is taken in account only if the `pathArray` is containing a single path
  22137. * @param scene defines the hosting scene
  22138. * @param updatable defines if the mesh must be flagged as updatable
  22139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22140. * @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)
  22141. * @returns a new Mesh
  22142. */
  22143. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22144. /**
  22145. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22146. * @param name defines the name of the mesh to create
  22147. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22148. * @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
  22149. * @param scene defines the hosting scene
  22150. * @param updatable defines if the mesh must be flagged as updatable
  22151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22152. * @returns a new Mesh
  22153. */
  22154. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22155. /**
  22156. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22157. * @param name defines the name of the mesh to create
  22158. * @param size sets the size (float) of each box side (default 1)
  22159. * @param scene defines the hosting scene
  22160. * @param updatable defines if the mesh must be flagged as updatable
  22161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22162. * @returns a new Mesh
  22163. */
  22164. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22165. /**
  22166. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22167. * @param name defines the name of the mesh to create
  22168. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22169. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22170. * @param scene defines the hosting scene
  22171. * @param updatable defines if the mesh must be flagged as updatable
  22172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22173. * @returns a new Mesh
  22174. */
  22175. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22176. /**
  22177. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22178. * @param name defines the name of the mesh to create
  22179. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22180. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22181. * @param scene defines the hosting scene
  22182. * @returns a new Mesh
  22183. */
  22184. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22185. /**
  22186. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22187. * @param name defines the name of the mesh to create
  22188. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22189. * @param diameterTop set the top cap diameter (floats, default 1)
  22190. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22191. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22192. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22193. * @param scene defines the hosting scene
  22194. * @param updatable defines if the mesh must be flagged as updatable
  22195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22196. * @returns a new Mesh
  22197. */
  22198. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22199. /**
  22200. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22201. * @param name defines the name of the mesh to create
  22202. * @param diameter sets the diameter size (float) of the torus (default 1)
  22203. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22204. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22205. * @param scene defines the hosting scene
  22206. * @param updatable defines if the mesh must be flagged as updatable
  22207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22208. * @returns a new Mesh
  22209. */
  22210. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22211. /**
  22212. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22213. * @param name defines the name of the mesh to create
  22214. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22215. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22216. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22217. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22218. * @param p the number of windings on X axis (positive integers, default 2)
  22219. * @param q the number of windings on Y axis (positive integers, default 3)
  22220. * @param scene defines the hosting scene
  22221. * @param updatable defines if the mesh must be flagged as updatable
  22222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22223. * @returns a new Mesh
  22224. */
  22225. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22226. /**
  22227. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22228. * @param name defines the name of the mesh to create
  22229. * @param points is an array successive Vector3
  22230. * @param scene defines the hosting scene
  22231. * @param updatable defines if the mesh must be flagged as updatable
  22232. * @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).
  22233. * @returns a new Mesh
  22234. */
  22235. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22236. /**
  22237. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22238. * @param name defines the name of the mesh to create
  22239. * @param points is an array successive Vector3
  22240. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22241. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22242. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22243. * @param scene defines the hosting scene
  22244. * @param updatable defines if the mesh must be flagged as updatable
  22245. * @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)
  22246. * @returns a new Mesh
  22247. */
  22248. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22249. /**
  22250. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22252. * 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.
  22253. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22254. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22255. * Remember you can only change the shape positions, not their number when updating a polygon.
  22256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22257. * @param name defines the name of the mesh to create
  22258. * @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
  22259. * @param scene defines the hosting scene
  22260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22261. * @param updatable defines if the mesh must be flagged as updatable
  22262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22263. * @param earcutInjection can be used to inject your own earcut reference
  22264. * @returns a new Mesh
  22265. */
  22266. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22267. /**
  22268. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22270. * @param name defines the name of the mesh to create
  22271. * @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
  22272. * @param depth defines the height of extrusion
  22273. * @param scene defines the hosting scene
  22274. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22275. * @param updatable defines if the mesh must be flagged as updatable
  22276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22277. * @param earcutInjection can be used to inject your own earcut reference
  22278. * @returns a new Mesh
  22279. */
  22280. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22281. /**
  22282. * Creates an extruded shape mesh.
  22283. * 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
  22284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22286. * @param name defines the name of the mesh to create
  22287. * @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
  22288. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22289. * @param scale is the value to scale the shape
  22290. * @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
  22291. * @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
  22292. * @param scene defines the hosting scene
  22293. * @param updatable defines if the mesh must be flagged as updatable
  22294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22295. * @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)
  22296. * @returns a new Mesh
  22297. */
  22298. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22299. /**
  22300. * Creates an custom extruded shape mesh.
  22301. * The custom extrusion is a parametric shape.
  22302. * It has no predefined shape. Its final shape will depend on the input parameters.
  22303. * Please consider using the same method from the MeshBuilder class instead
  22304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22305. * @param name defines the name of the mesh to create
  22306. * @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
  22307. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22308. * @param scaleFunction is a custom Javascript function called on each path point
  22309. * @param rotationFunction is a custom Javascript function called on each path point
  22310. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22311. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22312. * @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
  22313. * @param scene defines the hosting scene
  22314. * @param updatable defines if the mesh must be flagged as updatable
  22315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22316. * @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)
  22317. * @returns a new Mesh
  22318. */
  22319. 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;
  22320. /**
  22321. * Creates lathe mesh.
  22322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22323. * Please consider using the same method from the MeshBuilder class instead
  22324. * @param name defines the name of the mesh to create
  22325. * @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
  22326. * @param radius is the radius value of the lathe
  22327. * @param tessellation is the side number of the lathe.
  22328. * @param scene defines the hosting scene
  22329. * @param updatable defines if the mesh must be flagged as updatable
  22330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22331. * @returns a new Mesh
  22332. */
  22333. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22334. /**
  22335. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22336. * @param name defines the name of the mesh to create
  22337. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22338. * @param scene defines the hosting scene
  22339. * @param updatable defines if the mesh must be flagged as updatable
  22340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22341. * @returns a new Mesh
  22342. */
  22343. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22344. /**
  22345. * Creates a ground mesh.
  22346. * Please consider using the same method from the MeshBuilder class instead
  22347. * @param name defines the name of the mesh to create
  22348. * @param width set the width of the ground
  22349. * @param height set the height of the ground
  22350. * @param subdivisions sets the number of subdivisions per side
  22351. * @param scene defines the hosting scene
  22352. * @param updatable defines if the mesh must be flagged as updatable
  22353. * @returns a new Mesh
  22354. */
  22355. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22356. /**
  22357. * Creates a tiled ground mesh.
  22358. * Please consider using the same method from the MeshBuilder class instead
  22359. * @param name defines the name of the mesh to create
  22360. * @param xmin set the ground minimum X coordinate
  22361. * @param zmin set the ground minimum Y coordinate
  22362. * @param xmax set the ground maximum X coordinate
  22363. * @param zmax set the ground maximum Z coordinate
  22364. * @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
  22365. * @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
  22366. * @param scene defines the hosting scene
  22367. * @param updatable defines if the mesh must be flagged as updatable
  22368. * @returns a new Mesh
  22369. */
  22370. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22371. w: number;
  22372. h: number;
  22373. }, precision: {
  22374. w: number;
  22375. h: number;
  22376. }, scene: Scene, updatable?: boolean): Mesh;
  22377. /**
  22378. * Creates a ground mesh from a height map.
  22379. * Please consider using the same method from the MeshBuilder class instead
  22380. * @see http://doc.babylonjs.com/babylon101/height_map
  22381. * @param name defines the name of the mesh to create
  22382. * @param url sets the URL of the height map image resource
  22383. * @param width set the ground width size
  22384. * @param height set the ground height size
  22385. * @param subdivisions sets the number of subdivision per side
  22386. * @param minHeight is the minimum altitude on the ground
  22387. * @param maxHeight is the maximum altitude on the ground
  22388. * @param scene defines the hosting scene
  22389. * @param updatable defines if the mesh must be flagged as updatable
  22390. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22391. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22392. * @returns a new Mesh
  22393. */
  22394. 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;
  22395. /**
  22396. * Creates a tube mesh.
  22397. * The tube is a parametric shape.
  22398. * It has no predefined shape. Its final shape will depend on the input parameters.
  22399. * Please consider using the same method from the MeshBuilder class instead
  22400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22401. * @param name defines the name of the mesh to create
  22402. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22403. * @param radius sets the tube radius size
  22404. * @param tessellation is the number of sides on the tubular surface
  22405. * @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
  22406. * @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
  22407. * @param scene defines the hosting scene
  22408. * @param updatable defines if the mesh must be flagged as updatable
  22409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22410. * @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)
  22411. * @returns a new Mesh
  22412. */
  22413. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22414. (i: number, distance: number): number;
  22415. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22416. /**
  22417. * Creates a polyhedron mesh.
  22418. * Please consider using the same method from the MeshBuilder class instead.
  22419. * * 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
  22420. * * The parameter `size` (positive float, default 1) sets the polygon size
  22421. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22422. * * 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`
  22423. * * 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
  22424. * * 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)`)
  22425. * * 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
  22426. * * 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
  22427. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22428. * * If you create a double-sided mesh, you can choose what parts of 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
  22429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22430. * @param name defines the name of the mesh to create
  22431. * @param options defines the options used to create the mesh
  22432. * @param scene defines the hosting scene
  22433. * @returns a new Mesh
  22434. */
  22435. static CreatePolyhedron(name: string, options: {
  22436. type?: number;
  22437. size?: number;
  22438. sizeX?: number;
  22439. sizeY?: number;
  22440. sizeZ?: number;
  22441. custom?: any;
  22442. faceUV?: Vector4[];
  22443. faceColors?: Color4[];
  22444. updatable?: boolean;
  22445. sideOrientation?: number;
  22446. }, scene: Scene): Mesh;
  22447. /**
  22448. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22449. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22450. * * 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`)
  22451. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22452. * * 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
  22453. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22454. * * If you create a double-sided mesh, you can choose what parts of 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
  22455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22456. * @param name defines the name of the mesh
  22457. * @param options defines the options used to create the mesh
  22458. * @param scene defines the hosting scene
  22459. * @returns a new Mesh
  22460. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22461. */
  22462. static CreateIcoSphere(name: string, options: {
  22463. radius?: number;
  22464. flat?: boolean;
  22465. subdivisions?: number;
  22466. sideOrientation?: number;
  22467. updatable?: boolean;
  22468. }, scene: Scene): Mesh;
  22469. /**
  22470. * Creates a decal mesh.
  22471. * Please consider using the same method from the MeshBuilder class instead.
  22472. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22473. * @param name defines the name of the mesh
  22474. * @param sourceMesh defines the mesh receiving the decal
  22475. * @param position sets the position of the decal in world coordinates
  22476. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22477. * @param size sets the decal scaling
  22478. * @param angle sets the angle to rotate the decal
  22479. * @returns a new Mesh
  22480. */
  22481. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22482. /**
  22483. * Prepare internal position array for software CPU skinning
  22484. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22485. */
  22486. setPositionsForCPUSkinning(): Float32Array;
  22487. /**
  22488. * Prepare internal normal array for software CPU skinning
  22489. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22490. */
  22491. setNormalsForCPUSkinning(): Float32Array;
  22492. /**
  22493. * Updates the vertex buffer by applying transformation from the bones
  22494. * @param skeleton defines the skeleton to apply to current mesh
  22495. * @returns the current mesh
  22496. */
  22497. applySkeleton(skeleton: Skeleton): Mesh;
  22498. /**
  22499. * 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
  22500. * @param meshes defines the list of meshes to scan
  22501. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22502. */
  22503. static MinMax(meshes: AbstractMesh[]): {
  22504. min: Vector3;
  22505. max: Vector3;
  22506. };
  22507. /**
  22508. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22509. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22510. * @returns a vector3
  22511. */
  22512. static Center(meshesOrMinMaxVector: {
  22513. min: Vector3;
  22514. max: Vector3;
  22515. } | AbstractMesh[]): Vector3;
  22516. /**
  22517. * Merge the array of meshes into a single mesh for performance reasons.
  22518. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22519. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22520. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22521. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22522. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22523. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22524. * @returns a new mesh
  22525. */
  22526. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22527. /** @hidden */
  22528. addInstance(instance: InstancedMesh): void;
  22529. /** @hidden */
  22530. removeInstance(instance: InstancedMesh): void;
  22531. }
  22532. }
  22533. declare module "babylonjs/Materials/material" {
  22534. import { IAnimatable } from "babylonjs/Misc/tools";
  22535. import { SmartArray } from "babylonjs/Misc/smartArray";
  22536. import { Observable } from "babylonjs/Misc/observable";
  22537. import { Nullable } from "babylonjs/types";
  22538. import { Scene } from "babylonjs/scene";
  22539. import { Matrix } from "babylonjs/Maths/math";
  22540. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22542. import { Mesh } from "babylonjs/Meshes/mesh";
  22543. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22544. import { Effect } from "babylonjs/Materials/effect";
  22545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22548. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22549. import { Animation } from "babylonjs/Animations/animation";
  22550. /**
  22551. * Base class for the main features of a material in Babylon.js
  22552. */
  22553. export class Material implements IAnimatable {
  22554. /**
  22555. * Returns the triangle fill mode
  22556. */
  22557. static readonly TriangleFillMode: number;
  22558. /**
  22559. * Returns the wireframe mode
  22560. */
  22561. static readonly WireFrameFillMode: number;
  22562. /**
  22563. * Returns the point fill mode
  22564. */
  22565. static readonly PointFillMode: number;
  22566. /**
  22567. * Returns the point list draw mode
  22568. */
  22569. static readonly PointListDrawMode: number;
  22570. /**
  22571. * Returns the line list draw mode
  22572. */
  22573. static readonly LineListDrawMode: number;
  22574. /**
  22575. * Returns the line loop draw mode
  22576. */
  22577. static readonly LineLoopDrawMode: number;
  22578. /**
  22579. * Returns the line strip draw mode
  22580. */
  22581. static readonly LineStripDrawMode: number;
  22582. /**
  22583. * Returns the triangle strip draw mode
  22584. */
  22585. static readonly TriangleStripDrawMode: number;
  22586. /**
  22587. * Returns the triangle fan draw mode
  22588. */
  22589. static readonly TriangleFanDrawMode: number;
  22590. /**
  22591. * Stores the clock-wise side orientation
  22592. */
  22593. static readonly ClockWiseSideOrientation: number;
  22594. /**
  22595. * Stores the counter clock-wise side orientation
  22596. */
  22597. static readonly CounterClockWiseSideOrientation: number;
  22598. /**
  22599. * The dirty texture flag value
  22600. */
  22601. static readonly TextureDirtyFlag: number;
  22602. /**
  22603. * The dirty light flag value
  22604. */
  22605. static readonly LightDirtyFlag: number;
  22606. /**
  22607. * The dirty fresnel flag value
  22608. */
  22609. static readonly FresnelDirtyFlag: number;
  22610. /**
  22611. * The dirty attribute flag value
  22612. */
  22613. static readonly AttributesDirtyFlag: number;
  22614. /**
  22615. * The dirty misc flag value
  22616. */
  22617. static readonly MiscDirtyFlag: number;
  22618. /**
  22619. * The all dirty flag value
  22620. */
  22621. static readonly AllDirtyFlag: number;
  22622. /**
  22623. * The ID of the material
  22624. */
  22625. id: string;
  22626. /**
  22627. * Gets or sets the unique id of the material
  22628. */
  22629. uniqueId: number;
  22630. /**
  22631. * The name of the material
  22632. */
  22633. name: string;
  22634. /**
  22635. * Gets or sets user defined metadata
  22636. */
  22637. metadata: any;
  22638. /**
  22639. * For internal use only. Please do not use.
  22640. */
  22641. reservedDataStore: any;
  22642. /**
  22643. * Specifies if the ready state should be checked on each call
  22644. */
  22645. checkReadyOnEveryCall: boolean;
  22646. /**
  22647. * Specifies if the ready state should be checked once
  22648. */
  22649. checkReadyOnlyOnce: boolean;
  22650. /**
  22651. * The state of the material
  22652. */
  22653. state: string;
  22654. /**
  22655. * The alpha value of the material
  22656. */
  22657. protected _alpha: number;
  22658. /**
  22659. * List of inspectable custom properties (used by the Inspector)
  22660. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22661. */
  22662. inspectableCustomProperties: IInspectable[];
  22663. /**
  22664. * Sets the alpha value of the material
  22665. */
  22666. /**
  22667. * Gets the alpha value of the material
  22668. */
  22669. alpha: number;
  22670. /**
  22671. * Specifies if back face culling is enabled
  22672. */
  22673. protected _backFaceCulling: boolean;
  22674. /**
  22675. * Sets the back-face culling state
  22676. */
  22677. /**
  22678. * Gets the back-face culling state
  22679. */
  22680. backFaceCulling: boolean;
  22681. /**
  22682. * Stores the value for side orientation
  22683. */
  22684. sideOrientation: number;
  22685. /**
  22686. * Callback triggered when the material is compiled
  22687. */
  22688. onCompiled: Nullable<(effect: Effect) => void>;
  22689. /**
  22690. * Callback triggered when an error occurs
  22691. */
  22692. onError: Nullable<(effect: Effect, errors: string) => void>;
  22693. /**
  22694. * Callback triggered to get the render target textures
  22695. */
  22696. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22697. /**
  22698. * Gets a boolean indicating that current material needs to register RTT
  22699. */
  22700. readonly hasRenderTargetTextures: boolean;
  22701. /**
  22702. * Specifies if the material should be serialized
  22703. */
  22704. doNotSerialize: boolean;
  22705. /**
  22706. * @hidden
  22707. */
  22708. _storeEffectOnSubMeshes: boolean;
  22709. /**
  22710. * Stores the animations for the material
  22711. */
  22712. animations: Nullable<Array<Animation>>;
  22713. /**
  22714. * An event triggered when the material is disposed
  22715. */
  22716. onDisposeObservable: Observable<Material>;
  22717. /**
  22718. * An observer which watches for dispose events
  22719. */
  22720. private _onDisposeObserver;
  22721. private _onUnBindObservable;
  22722. /**
  22723. * Called during a dispose event
  22724. */
  22725. onDispose: () => void;
  22726. private _onBindObservable;
  22727. /**
  22728. * An event triggered when the material is bound
  22729. */
  22730. readonly onBindObservable: Observable<AbstractMesh>;
  22731. /**
  22732. * An observer which watches for bind events
  22733. */
  22734. private _onBindObserver;
  22735. /**
  22736. * Called during a bind event
  22737. */
  22738. onBind: (Mesh: AbstractMesh) => void;
  22739. /**
  22740. * An event triggered when the material is unbound
  22741. */
  22742. readonly onUnBindObservable: Observable<Material>;
  22743. /**
  22744. * Stores the value of the alpha mode
  22745. */
  22746. private _alphaMode;
  22747. /**
  22748. * Sets the value of the alpha mode.
  22749. *
  22750. * | Value | Type | Description |
  22751. * | --- | --- | --- |
  22752. * | 0 | ALPHA_DISABLE | |
  22753. * | 1 | ALPHA_ADD | |
  22754. * | 2 | ALPHA_COMBINE | |
  22755. * | 3 | ALPHA_SUBTRACT | |
  22756. * | 4 | ALPHA_MULTIPLY | |
  22757. * | 5 | ALPHA_MAXIMIZED | |
  22758. * | 6 | ALPHA_ONEONE | |
  22759. * | 7 | ALPHA_PREMULTIPLIED | |
  22760. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22761. * | 9 | ALPHA_INTERPOLATE | |
  22762. * | 10 | ALPHA_SCREENMODE | |
  22763. *
  22764. */
  22765. /**
  22766. * Gets the value of the alpha mode
  22767. */
  22768. alphaMode: number;
  22769. /**
  22770. * Stores the state of the need depth pre-pass value
  22771. */
  22772. private _needDepthPrePass;
  22773. /**
  22774. * Sets the need depth pre-pass value
  22775. */
  22776. /**
  22777. * Gets the depth pre-pass value
  22778. */
  22779. needDepthPrePass: boolean;
  22780. /**
  22781. * Specifies if depth writing should be disabled
  22782. */
  22783. disableDepthWrite: boolean;
  22784. /**
  22785. * Specifies if depth writing should be forced
  22786. */
  22787. forceDepthWrite: boolean;
  22788. /**
  22789. * Specifies if there should be a separate pass for culling
  22790. */
  22791. separateCullingPass: boolean;
  22792. /**
  22793. * Stores the state specifing if fog should be enabled
  22794. */
  22795. private _fogEnabled;
  22796. /**
  22797. * Sets the state for enabling fog
  22798. */
  22799. /**
  22800. * Gets the value of the fog enabled state
  22801. */
  22802. fogEnabled: boolean;
  22803. /**
  22804. * Stores the size of points
  22805. */
  22806. pointSize: number;
  22807. /**
  22808. * Stores the z offset value
  22809. */
  22810. zOffset: number;
  22811. /**
  22812. * Gets a value specifying if wireframe mode is enabled
  22813. */
  22814. /**
  22815. * Sets the state of wireframe mode
  22816. */
  22817. wireframe: boolean;
  22818. /**
  22819. * Gets the value specifying if point clouds are enabled
  22820. */
  22821. /**
  22822. * Sets the state of point cloud mode
  22823. */
  22824. pointsCloud: boolean;
  22825. /**
  22826. * Gets the material fill mode
  22827. */
  22828. /**
  22829. * Sets the material fill mode
  22830. */
  22831. fillMode: number;
  22832. /**
  22833. * @hidden
  22834. * Stores the effects for the material
  22835. */
  22836. _effect: Nullable<Effect>;
  22837. /**
  22838. * @hidden
  22839. * Specifies if the material was previously ready
  22840. */
  22841. _wasPreviouslyReady: boolean;
  22842. /**
  22843. * Specifies if uniform buffers should be used
  22844. */
  22845. private _useUBO;
  22846. /**
  22847. * Stores a reference to the scene
  22848. */
  22849. private _scene;
  22850. /**
  22851. * Stores the fill mode state
  22852. */
  22853. private _fillMode;
  22854. /**
  22855. * Specifies if the depth write state should be cached
  22856. */
  22857. private _cachedDepthWriteState;
  22858. /**
  22859. * Stores the uniform buffer
  22860. */
  22861. protected _uniformBuffer: UniformBuffer;
  22862. /** @hidden */
  22863. _indexInSceneMaterialArray: number;
  22864. /** @hidden */
  22865. meshMap: Nullable<{
  22866. [id: string]: AbstractMesh | undefined;
  22867. }>;
  22868. /**
  22869. * Creates a material instance
  22870. * @param name defines the name of the material
  22871. * @param scene defines the scene to reference
  22872. * @param doNotAdd specifies if the material should be added to the scene
  22873. */
  22874. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22875. /**
  22876. * Returns a string representation of the current material
  22877. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22878. * @returns a string with material information
  22879. */
  22880. toString(fullDetails?: boolean): string;
  22881. /**
  22882. * Gets the class name of the material
  22883. * @returns a string with the class name of the material
  22884. */
  22885. getClassName(): string;
  22886. /**
  22887. * Specifies if updates for the material been locked
  22888. */
  22889. readonly isFrozen: boolean;
  22890. /**
  22891. * Locks updates for the material
  22892. */
  22893. freeze(): void;
  22894. /**
  22895. * Unlocks updates for the material
  22896. */
  22897. unfreeze(): void;
  22898. /**
  22899. * Specifies if the material is ready to be used
  22900. * @param mesh defines the mesh to check
  22901. * @param useInstances specifies if instances should be used
  22902. * @returns a boolean indicating if the material is ready to be used
  22903. */
  22904. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22905. /**
  22906. * Specifies that the submesh is ready to be used
  22907. * @param mesh defines the mesh to check
  22908. * @param subMesh defines which submesh to check
  22909. * @param useInstances specifies that instances should be used
  22910. * @returns a boolean indicating that the submesh is ready or not
  22911. */
  22912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22913. /**
  22914. * Returns the material effect
  22915. * @returns the effect associated with the material
  22916. */
  22917. getEffect(): Nullable<Effect>;
  22918. /**
  22919. * Returns the current scene
  22920. * @returns a Scene
  22921. */
  22922. getScene(): Scene;
  22923. /**
  22924. * Specifies if the material will require alpha blending
  22925. * @returns a boolean specifying if alpha blending is needed
  22926. */
  22927. needAlphaBlending(): boolean;
  22928. /**
  22929. * Specifies if the mesh will require alpha blending
  22930. * @param mesh defines the mesh to check
  22931. * @returns a boolean specifying if alpha blending is needed for the mesh
  22932. */
  22933. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22934. /**
  22935. * Specifies if this material should be rendered in alpha test mode
  22936. * @returns a boolean specifying if an alpha test is needed.
  22937. */
  22938. needAlphaTesting(): boolean;
  22939. /**
  22940. * Gets the texture used for the alpha test
  22941. * @returns the texture to use for alpha testing
  22942. */
  22943. getAlphaTestTexture(): Nullable<BaseTexture>;
  22944. /**
  22945. * Marks the material to indicate that it needs to be re-calculated
  22946. */
  22947. markDirty(): void;
  22948. /** @hidden */
  22949. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22950. /**
  22951. * Binds the material to the mesh
  22952. * @param world defines the world transformation matrix
  22953. * @param mesh defines the mesh to bind the material to
  22954. */
  22955. bind(world: Matrix, mesh?: Mesh): void;
  22956. /**
  22957. * Binds the submesh to the material
  22958. * @param world defines the world transformation matrix
  22959. * @param mesh defines the mesh containing the submesh
  22960. * @param subMesh defines the submesh to bind the material to
  22961. */
  22962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22963. /**
  22964. * Binds the world matrix to the material
  22965. * @param world defines the world transformation matrix
  22966. */
  22967. bindOnlyWorldMatrix(world: Matrix): void;
  22968. /**
  22969. * Binds the scene's uniform buffer to the effect.
  22970. * @param effect defines the effect to bind to the scene uniform buffer
  22971. * @param sceneUbo defines the uniform buffer storing scene data
  22972. */
  22973. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22974. /**
  22975. * Binds the view matrix to the effect
  22976. * @param effect defines the effect to bind the view matrix to
  22977. */
  22978. bindView(effect: Effect): void;
  22979. /**
  22980. * Binds the view projection matrix to the effect
  22981. * @param effect defines the effect to bind the view projection matrix to
  22982. */
  22983. bindViewProjection(effect: Effect): void;
  22984. /**
  22985. * Specifies if material alpha testing should be turned on for the mesh
  22986. * @param mesh defines the mesh to check
  22987. */
  22988. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22989. /**
  22990. * Processes to execute after binding the material to a mesh
  22991. * @param mesh defines the rendered mesh
  22992. */
  22993. protected _afterBind(mesh?: Mesh): void;
  22994. /**
  22995. * Unbinds the material from the mesh
  22996. */
  22997. unbind(): void;
  22998. /**
  22999. * Gets the active textures from the material
  23000. * @returns an array of textures
  23001. */
  23002. getActiveTextures(): BaseTexture[];
  23003. /**
  23004. * Specifies if the material uses a texture
  23005. * @param texture defines the texture to check against the material
  23006. * @returns a boolean specifying if the material uses the texture
  23007. */
  23008. hasTexture(texture: BaseTexture): boolean;
  23009. /**
  23010. * Makes a duplicate of the material, and gives it a new name
  23011. * @param name defines the new name for the duplicated material
  23012. * @returns the cloned material
  23013. */
  23014. clone(name: string): Nullable<Material>;
  23015. /**
  23016. * Gets the meshes bound to the material
  23017. * @returns an array of meshes bound to the material
  23018. */
  23019. getBindedMeshes(): AbstractMesh[];
  23020. /**
  23021. * Force shader compilation
  23022. * @param mesh defines the mesh associated with this material
  23023. * @param onCompiled defines a function to execute once the material is compiled
  23024. * @param options defines the options to configure the compilation
  23025. */
  23026. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23027. clipPlane: boolean;
  23028. }>): void;
  23029. /**
  23030. * Force shader compilation
  23031. * @param mesh defines the mesh that will use this material
  23032. * @param options defines additional options for compiling the shaders
  23033. * @returns a promise that resolves when the compilation completes
  23034. */
  23035. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23036. clipPlane: boolean;
  23037. }>): Promise<void>;
  23038. private static readonly _ImageProcessingDirtyCallBack;
  23039. private static readonly _TextureDirtyCallBack;
  23040. private static readonly _FresnelDirtyCallBack;
  23041. private static readonly _MiscDirtyCallBack;
  23042. private static readonly _LightsDirtyCallBack;
  23043. private static readonly _AttributeDirtyCallBack;
  23044. private static _FresnelAndMiscDirtyCallBack;
  23045. private static _TextureAndMiscDirtyCallBack;
  23046. private static readonly _DirtyCallbackArray;
  23047. private static readonly _RunDirtyCallBacks;
  23048. /**
  23049. * Marks a define in the material to indicate that it needs to be re-computed
  23050. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23051. */
  23052. markAsDirty(flag: number): void;
  23053. /**
  23054. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23055. * @param func defines a function which checks material defines against the submeshes
  23056. */
  23057. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23058. /**
  23059. * Indicates that image processing needs to be re-calculated for all submeshes
  23060. */
  23061. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23062. /**
  23063. * Indicates that textures need to be re-calculated for all submeshes
  23064. */
  23065. protected _markAllSubMeshesAsTexturesDirty(): void;
  23066. /**
  23067. * Indicates that fresnel needs to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsFresnelDirty(): void;
  23070. /**
  23071. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23074. /**
  23075. * Indicates that lights need to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsLightsDirty(): void;
  23078. /**
  23079. * Indicates that attributes need to be re-calculated for all submeshes
  23080. */
  23081. protected _markAllSubMeshesAsAttributesDirty(): void;
  23082. /**
  23083. * Indicates that misc needs to be re-calculated for all submeshes
  23084. */
  23085. protected _markAllSubMeshesAsMiscDirty(): void;
  23086. /**
  23087. * Indicates that textures and misc need to be re-calculated for all submeshes
  23088. */
  23089. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23090. /**
  23091. * Disposes the material
  23092. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23093. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23094. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23095. */
  23096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23097. /** @hidden */
  23098. private releaseVertexArrayObject;
  23099. /**
  23100. * Serializes this material
  23101. * @returns the serialized material object
  23102. */
  23103. serialize(): any;
  23104. /**
  23105. * Creates a material from parsed material data
  23106. * @param parsedMaterial defines parsed material data
  23107. * @param scene defines the hosting scene
  23108. * @param rootUrl defines the root URL to use to load textures
  23109. * @returns a new material
  23110. */
  23111. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23112. }
  23113. }
  23114. declare module "babylonjs/Meshes/subMesh" {
  23115. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23116. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23117. import { Engine } from "babylonjs/Engines/engine";
  23118. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23119. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23120. import { Effect } from "babylonjs/Materials/effect";
  23121. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23122. import { Collider } from "babylonjs/Collisions/collider";
  23123. import { Material } from "babylonjs/Materials/material";
  23124. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23126. import { Mesh } from "babylonjs/Meshes/mesh";
  23127. import { Ray } from "babylonjs/Culling/ray";
  23128. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23129. /**
  23130. * Base class for submeshes
  23131. */
  23132. export class BaseSubMesh {
  23133. /** @hidden */
  23134. _materialDefines: Nullable<MaterialDefines>;
  23135. /** @hidden */
  23136. _materialEffect: Nullable<Effect>;
  23137. /**
  23138. * Gets associated effect
  23139. */
  23140. readonly effect: Nullable<Effect>;
  23141. /**
  23142. * Sets associated effect (effect used to render this submesh)
  23143. * @param effect defines the effect to associate with
  23144. * @param defines defines the set of defines used to compile this effect
  23145. */
  23146. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23147. }
  23148. /**
  23149. * Defines a subdivision inside a mesh
  23150. */
  23151. export class SubMesh extends BaseSubMesh implements ICullable {
  23152. /** the material index to use */
  23153. materialIndex: number;
  23154. /** vertex index start */
  23155. verticesStart: number;
  23156. /** vertices count */
  23157. verticesCount: number;
  23158. /** index start */
  23159. indexStart: number;
  23160. /** indices count */
  23161. indexCount: number;
  23162. /** @hidden */
  23163. _linesIndexCount: number;
  23164. private _mesh;
  23165. private _renderingMesh;
  23166. private _boundingInfo;
  23167. private _linesIndexBuffer;
  23168. /** @hidden */
  23169. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23170. /** @hidden */
  23171. _trianglePlanes: Plane[];
  23172. /** @hidden */
  23173. _lastColliderTransformMatrix: Nullable<Matrix>;
  23174. /** @hidden */
  23175. _renderId: number;
  23176. /** @hidden */
  23177. _alphaIndex: number;
  23178. /** @hidden */
  23179. _distanceToCamera: number;
  23180. /** @hidden */
  23181. _id: number;
  23182. private _currentMaterial;
  23183. /**
  23184. * Add a new submesh to a mesh
  23185. * @param materialIndex defines the material index to use
  23186. * @param verticesStart defines vertex index start
  23187. * @param verticesCount defines vertices count
  23188. * @param indexStart defines index start
  23189. * @param indexCount defines indices count
  23190. * @param mesh defines the parent mesh
  23191. * @param renderingMesh defines an optional rendering mesh
  23192. * @param createBoundingBox defines if bounding box should be created for this submesh
  23193. * @returns the new submesh
  23194. */
  23195. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23196. /**
  23197. * Creates a new submesh
  23198. * @param materialIndex defines the material index to use
  23199. * @param verticesStart defines vertex index start
  23200. * @param verticesCount defines vertices count
  23201. * @param indexStart defines index start
  23202. * @param indexCount defines indices count
  23203. * @param mesh defines the parent mesh
  23204. * @param renderingMesh defines an optional rendering mesh
  23205. * @param createBoundingBox defines if bounding box should be created for this submesh
  23206. */
  23207. constructor(
  23208. /** the material index to use */
  23209. materialIndex: number,
  23210. /** vertex index start */
  23211. verticesStart: number,
  23212. /** vertices count */
  23213. verticesCount: number,
  23214. /** index start */
  23215. indexStart: number,
  23216. /** indices count */
  23217. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23218. /**
  23219. * Returns true if this submesh covers the entire parent mesh
  23220. * @ignorenaming
  23221. */
  23222. readonly IsGlobal: boolean;
  23223. /**
  23224. * Returns the submesh BoudingInfo object
  23225. * @returns current bounding info (or mesh's one if the submesh is global)
  23226. */
  23227. getBoundingInfo(): BoundingInfo;
  23228. /**
  23229. * Sets the submesh BoundingInfo
  23230. * @param boundingInfo defines the new bounding info to use
  23231. * @returns the SubMesh
  23232. */
  23233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23234. /**
  23235. * Returns the mesh of the current submesh
  23236. * @return the parent mesh
  23237. */
  23238. getMesh(): AbstractMesh;
  23239. /**
  23240. * Returns the rendering mesh of the submesh
  23241. * @returns the rendering mesh (could be different from parent mesh)
  23242. */
  23243. getRenderingMesh(): Mesh;
  23244. /**
  23245. * Returns the submesh material
  23246. * @returns null or the current material
  23247. */
  23248. getMaterial(): Nullable<Material>;
  23249. /**
  23250. * Sets a new updated BoundingInfo object to the submesh
  23251. * @param data defines an optional position array to use to determine the bounding info
  23252. * @returns the SubMesh
  23253. */
  23254. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23255. /** @hidden */
  23256. _checkCollision(collider: Collider): boolean;
  23257. /**
  23258. * Updates the submesh BoundingInfo
  23259. * @param world defines the world matrix to use to update the bounding info
  23260. * @returns the submesh
  23261. */
  23262. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23263. /**
  23264. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23265. * @param frustumPlanes defines the frustum planes
  23266. * @returns true if the submesh is intersecting with the frustum
  23267. */
  23268. isInFrustum(frustumPlanes: Plane[]): boolean;
  23269. /**
  23270. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23271. * @param frustumPlanes defines the frustum planes
  23272. * @returns true if the submesh is inside the frustum
  23273. */
  23274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23275. /**
  23276. * Renders the submesh
  23277. * @param enableAlphaMode defines if alpha needs to be used
  23278. * @returns the submesh
  23279. */
  23280. render(enableAlphaMode: boolean): SubMesh;
  23281. /**
  23282. * @hidden
  23283. */
  23284. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23285. /**
  23286. * Checks if the submesh intersects with a ray
  23287. * @param ray defines the ray to test
  23288. * @returns true is the passed ray intersects the submesh bounding box
  23289. */
  23290. canIntersects(ray: Ray): boolean;
  23291. /**
  23292. * Intersects current submesh with a ray
  23293. * @param ray defines the ray to test
  23294. * @param positions defines mesh's positions array
  23295. * @param indices defines mesh's indices array
  23296. * @param fastCheck defines if only bounding info should be used
  23297. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23298. * @returns intersection info or null if no intersection
  23299. */
  23300. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23301. /** @hidden */
  23302. private _intersectLines;
  23303. /** @hidden */
  23304. private _intersectTriangles;
  23305. /** @hidden */
  23306. private _intersectUnIndexedTriangles;
  23307. /** @hidden */
  23308. _rebuild(): void;
  23309. /**
  23310. * Creates a new submesh from the passed mesh
  23311. * @param newMesh defines the new hosting mesh
  23312. * @param newRenderingMesh defines an optional rendering mesh
  23313. * @returns the new submesh
  23314. */
  23315. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23316. /**
  23317. * Release associated resources
  23318. */
  23319. dispose(): void;
  23320. /**
  23321. * Gets the class name
  23322. * @returns the string "SubMesh".
  23323. */
  23324. getClassName(): string;
  23325. /**
  23326. * Creates a new submesh from indices data
  23327. * @param materialIndex the index of the main mesh material
  23328. * @param startIndex the index where to start the copy in the mesh indices array
  23329. * @param indexCount the number of indices to copy then from the startIndex
  23330. * @param mesh the main mesh to create the submesh from
  23331. * @param renderingMesh the optional rendering mesh
  23332. * @returns a new submesh
  23333. */
  23334. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23335. }
  23336. }
  23337. declare module "babylonjs/Meshes/geometry" {
  23338. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23339. import { Scene } from "babylonjs/scene";
  23340. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23341. import { Engine } from "babylonjs/Engines/engine";
  23342. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23343. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23344. import { Effect } from "babylonjs/Materials/effect";
  23345. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23347. import { Mesh } from "babylonjs/Meshes/mesh";
  23348. /**
  23349. * Class used to store geometry data (vertex buffers + index buffer)
  23350. */
  23351. export class Geometry implements IGetSetVerticesData {
  23352. /**
  23353. * Gets or sets the ID of the geometry
  23354. */
  23355. id: string;
  23356. /**
  23357. * Gets or sets the unique ID of the geometry
  23358. */
  23359. uniqueId: number;
  23360. /**
  23361. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23362. */
  23363. delayLoadState: number;
  23364. /**
  23365. * Gets the file containing the data to load when running in delay load state
  23366. */
  23367. delayLoadingFile: Nullable<string>;
  23368. /**
  23369. * Callback called when the geometry is updated
  23370. */
  23371. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23372. private _scene;
  23373. private _engine;
  23374. private _meshes;
  23375. private _totalVertices;
  23376. /** @hidden */
  23377. _indices: IndicesArray;
  23378. /** @hidden */
  23379. _vertexBuffers: {
  23380. [key: string]: VertexBuffer;
  23381. };
  23382. private _isDisposed;
  23383. private _extend;
  23384. private _boundingBias;
  23385. /** @hidden */
  23386. _delayInfo: Array<string>;
  23387. private _indexBuffer;
  23388. private _indexBufferIsUpdatable;
  23389. /** @hidden */
  23390. _boundingInfo: Nullable<BoundingInfo>;
  23391. /** @hidden */
  23392. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23393. /** @hidden */
  23394. _softwareSkinningFrameId: number;
  23395. private _vertexArrayObjects;
  23396. private _updatable;
  23397. /** @hidden */
  23398. _positions: Nullable<Vector3[]>;
  23399. /**
  23400. * 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
  23401. */
  23402. /**
  23403. * 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
  23404. */
  23405. boundingBias: Vector2;
  23406. /**
  23407. * Static function used to attach a new empty geometry to a mesh
  23408. * @param mesh defines the mesh to attach the geometry to
  23409. * @returns the new Geometry
  23410. */
  23411. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23412. /**
  23413. * Creates a new geometry
  23414. * @param id defines the unique ID
  23415. * @param scene defines the hosting scene
  23416. * @param vertexData defines the VertexData used to get geometry data
  23417. * @param updatable defines if geometry must be updatable (false by default)
  23418. * @param mesh defines the mesh that will be associated with the geometry
  23419. */
  23420. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23421. /**
  23422. * Gets the current extend of the geometry
  23423. */
  23424. readonly extend: {
  23425. minimum: Vector3;
  23426. maximum: Vector3;
  23427. };
  23428. /**
  23429. * Gets the hosting scene
  23430. * @returns the hosting Scene
  23431. */
  23432. getScene(): Scene;
  23433. /**
  23434. * Gets the hosting engine
  23435. * @returns the hosting Engine
  23436. */
  23437. getEngine(): Engine;
  23438. /**
  23439. * Defines if the geometry is ready to use
  23440. * @returns true if the geometry is ready to be used
  23441. */
  23442. isReady(): boolean;
  23443. /**
  23444. * Gets a value indicating that the geometry should not be serialized
  23445. */
  23446. readonly doNotSerialize: boolean;
  23447. /** @hidden */
  23448. _rebuild(): void;
  23449. /**
  23450. * Affects all geometry data in one call
  23451. * @param vertexData defines the geometry data
  23452. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23453. */
  23454. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23455. /**
  23456. * Set specific vertex data
  23457. * @param kind defines the data kind (Position, normal, etc...)
  23458. * @param data defines the vertex data to use
  23459. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23460. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23461. */
  23462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23463. /**
  23464. * Removes a specific vertex data
  23465. * @param kind defines the data kind (Position, normal, etc...)
  23466. */
  23467. removeVerticesData(kind: string): void;
  23468. /**
  23469. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23470. * @param buffer defines the vertex buffer to use
  23471. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23472. */
  23473. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23474. /**
  23475. * Update a specific vertex buffer
  23476. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23477. * It will do nothing if the buffer is not updatable
  23478. * @param kind defines the data kind (Position, normal, etc...)
  23479. * @param data defines the data to use
  23480. * @param offset defines the offset in the target buffer where to store the data
  23481. * @param useBytes set to true if the offset is in bytes
  23482. */
  23483. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23484. /**
  23485. * Update a specific vertex buffer
  23486. * This function will create a new buffer if the current one is not updatable
  23487. * @param kind defines the data kind (Position, normal, etc...)
  23488. * @param data defines the data to use
  23489. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23490. */
  23491. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23492. private _updateBoundingInfo;
  23493. /** @hidden */
  23494. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23495. /**
  23496. * Gets total number of vertices
  23497. * @returns the total number of vertices
  23498. */
  23499. getTotalVertices(): number;
  23500. /**
  23501. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23502. * @param kind defines the data kind (Position, normal, etc...)
  23503. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23505. * @returns a float array containing vertex data
  23506. */
  23507. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23508. /**
  23509. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23510. * @param kind defines the data kind (Position, normal, etc...)
  23511. * @returns true if the vertex buffer with the specified kind is updatable
  23512. */
  23513. isVertexBufferUpdatable(kind: string): boolean;
  23514. /**
  23515. * Gets a specific vertex buffer
  23516. * @param kind defines the data kind (Position, normal, etc...)
  23517. * @returns a VertexBuffer
  23518. */
  23519. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23520. /**
  23521. * Returns all vertex buffers
  23522. * @return an object holding all vertex buffers indexed by kind
  23523. */
  23524. getVertexBuffers(): Nullable<{
  23525. [key: string]: VertexBuffer;
  23526. }>;
  23527. /**
  23528. * Gets a boolean indicating if specific vertex buffer is present
  23529. * @param kind defines the data kind (Position, normal, etc...)
  23530. * @returns true if data is present
  23531. */
  23532. isVerticesDataPresent(kind: string): boolean;
  23533. /**
  23534. * Gets a list of all attached data kinds (Position, normal, etc...)
  23535. * @returns a list of string containing all kinds
  23536. */
  23537. getVerticesDataKinds(): string[];
  23538. /**
  23539. * Update index buffer
  23540. * @param indices defines the indices to store in the index buffer
  23541. * @param offset defines the offset in the target buffer where to store the data
  23542. * @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)
  23543. */
  23544. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23545. /**
  23546. * Creates a new index buffer
  23547. * @param indices defines the indices to store in the index buffer
  23548. * @param totalVertices defines the total number of vertices (could be null)
  23549. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23550. */
  23551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23552. /**
  23553. * Return the total number of indices
  23554. * @returns the total number of indices
  23555. */
  23556. getTotalIndices(): number;
  23557. /**
  23558. * Gets the index buffer array
  23559. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23560. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23561. * @returns the index buffer array
  23562. */
  23563. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23564. /**
  23565. * Gets the index buffer
  23566. * @return the index buffer
  23567. */
  23568. getIndexBuffer(): Nullable<DataBuffer>;
  23569. /** @hidden */
  23570. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23571. /**
  23572. * Release the associated resources for a specific mesh
  23573. * @param mesh defines the source mesh
  23574. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23575. */
  23576. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23577. /**
  23578. * Apply current geometry to a given mesh
  23579. * @param mesh defines the mesh to apply geometry to
  23580. */
  23581. applyToMesh(mesh: Mesh): void;
  23582. private _updateExtend;
  23583. private _applyToMesh;
  23584. private notifyUpdate;
  23585. /**
  23586. * Load the geometry if it was flagged as delay loaded
  23587. * @param scene defines the hosting scene
  23588. * @param onLoaded defines a callback called when the geometry is loaded
  23589. */
  23590. load(scene: Scene, onLoaded?: () => void): void;
  23591. private _queueLoad;
  23592. /**
  23593. * Invert the geometry to move from a right handed system to a left handed one.
  23594. */
  23595. toLeftHanded(): void;
  23596. /** @hidden */
  23597. _resetPointsArrayCache(): void;
  23598. /** @hidden */
  23599. _generatePointsArray(): boolean;
  23600. /**
  23601. * Gets a value indicating if the geometry is disposed
  23602. * @returns true if the geometry was disposed
  23603. */
  23604. isDisposed(): boolean;
  23605. private _disposeVertexArrayObjects;
  23606. /**
  23607. * Free all associated resources
  23608. */
  23609. dispose(): void;
  23610. /**
  23611. * Clone the current geometry into a new geometry
  23612. * @param id defines the unique ID of the new geometry
  23613. * @returns a new geometry object
  23614. */
  23615. copy(id: string): Geometry;
  23616. /**
  23617. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23618. * @return a JSON representation of the current geometry data (without the vertices data)
  23619. */
  23620. serialize(): any;
  23621. private toNumberArray;
  23622. /**
  23623. * Serialize all vertices data into a JSON oject
  23624. * @returns a JSON representation of the current geometry data
  23625. */
  23626. serializeVerticeData(): any;
  23627. /**
  23628. * Extracts a clone of a mesh geometry
  23629. * @param mesh defines the source mesh
  23630. * @param id defines the unique ID of the new geometry object
  23631. * @returns the new geometry object
  23632. */
  23633. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23634. /**
  23635. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23636. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23637. * Be aware Math.random() could cause collisions, but:
  23638. * "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"
  23639. * @returns a string containing a new GUID
  23640. */
  23641. static RandomId(): string;
  23642. /** @hidden */
  23643. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23644. private static _CleanMatricesWeights;
  23645. /**
  23646. * Create a new geometry from persisted data (Using .babylon file format)
  23647. * @param parsedVertexData defines the persisted data
  23648. * @param scene defines the hosting scene
  23649. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23650. * @returns the new geometry object
  23651. */
  23652. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23653. }
  23654. }
  23655. declare module "babylonjs/Meshes/mesh.vertexData" {
  23656. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23657. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23658. import { Geometry } from "babylonjs/Meshes/geometry";
  23659. import { Mesh } from "babylonjs/Meshes/mesh";
  23660. /**
  23661. * Define an interface for all classes that will get and set the data on vertices
  23662. */
  23663. export interface IGetSetVerticesData {
  23664. /**
  23665. * Gets a boolean indicating if specific vertex data is present
  23666. * @param kind defines the vertex data kind to use
  23667. * @returns true is data kind is present
  23668. */
  23669. isVerticesDataPresent(kind: string): boolean;
  23670. /**
  23671. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23672. * @param kind defines the data kind (Position, normal, etc...)
  23673. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23675. * @returns a float array containing vertex data
  23676. */
  23677. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23678. /**
  23679. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23680. * @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.
  23681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23682. * @returns the indices array or an empty array if the mesh has no geometry
  23683. */
  23684. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23685. /**
  23686. * Set specific vertex data
  23687. * @param kind defines the data kind (Position, normal, etc...)
  23688. * @param data defines the vertex data to use
  23689. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23690. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23691. */
  23692. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23693. /**
  23694. * Update a specific associated vertex buffer
  23695. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23696. * - VertexBuffer.PositionKind
  23697. * - VertexBuffer.UVKind
  23698. * - VertexBuffer.UV2Kind
  23699. * - VertexBuffer.UV3Kind
  23700. * - VertexBuffer.UV4Kind
  23701. * - VertexBuffer.UV5Kind
  23702. * - VertexBuffer.UV6Kind
  23703. * - VertexBuffer.ColorKind
  23704. * - VertexBuffer.MatricesIndicesKind
  23705. * - VertexBuffer.MatricesIndicesExtraKind
  23706. * - VertexBuffer.MatricesWeightsKind
  23707. * - VertexBuffer.MatricesWeightsExtraKind
  23708. * @param data defines the data source
  23709. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23710. * @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)
  23711. */
  23712. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23713. /**
  23714. * Creates a new index buffer
  23715. * @param indices defines the indices to store in the index buffer
  23716. * @param totalVertices defines the total number of vertices (could be null)
  23717. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23718. */
  23719. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23720. }
  23721. /**
  23722. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23723. */
  23724. export class VertexData {
  23725. /**
  23726. * Mesh side orientation : usually the external or front surface
  23727. */
  23728. static readonly FRONTSIDE: number;
  23729. /**
  23730. * Mesh side orientation : usually the internal or back surface
  23731. */
  23732. static readonly BACKSIDE: number;
  23733. /**
  23734. * Mesh side orientation : both internal and external or front and back surfaces
  23735. */
  23736. static readonly DOUBLESIDE: number;
  23737. /**
  23738. * Mesh side orientation : by default, `FRONTSIDE`
  23739. */
  23740. static readonly DEFAULTSIDE: number;
  23741. /**
  23742. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23743. */
  23744. positions: Nullable<FloatArray>;
  23745. /**
  23746. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23747. */
  23748. normals: Nullable<FloatArray>;
  23749. /**
  23750. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23751. */
  23752. tangents: Nullable<FloatArray>;
  23753. /**
  23754. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23755. */
  23756. uvs: Nullable<FloatArray>;
  23757. /**
  23758. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23759. */
  23760. uvs2: Nullable<FloatArray>;
  23761. /**
  23762. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23763. */
  23764. uvs3: Nullable<FloatArray>;
  23765. /**
  23766. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23767. */
  23768. uvs4: Nullable<FloatArray>;
  23769. /**
  23770. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23771. */
  23772. uvs5: Nullable<FloatArray>;
  23773. /**
  23774. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23775. */
  23776. uvs6: Nullable<FloatArray>;
  23777. /**
  23778. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23779. */
  23780. colors: Nullable<FloatArray>;
  23781. /**
  23782. * 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).
  23783. */
  23784. matricesIndices: Nullable<FloatArray>;
  23785. /**
  23786. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23787. */
  23788. matricesWeights: Nullable<FloatArray>;
  23789. /**
  23790. * An array extending the number of possible indices
  23791. */
  23792. matricesIndicesExtra: Nullable<FloatArray>;
  23793. /**
  23794. * An array extending the number of possible weights when the number of indices is extended
  23795. */
  23796. matricesWeightsExtra: Nullable<FloatArray>;
  23797. /**
  23798. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23799. */
  23800. indices: Nullable<IndicesArray>;
  23801. /**
  23802. * Uses the passed data array to set the set the values for the specified kind of data
  23803. * @param data a linear array of floating numbers
  23804. * @param kind the type of data that is being set, eg positions, colors etc
  23805. */
  23806. set(data: FloatArray, kind: string): void;
  23807. /**
  23808. * Associates the vertexData to the passed Mesh.
  23809. * Sets it as updatable or not (default `false`)
  23810. * @param mesh the mesh the vertexData is applied to
  23811. * @param updatable when used and having the value true allows new data to update the vertexData
  23812. * @returns the VertexData
  23813. */
  23814. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23815. /**
  23816. * Associates the vertexData to the passed Geometry.
  23817. * Sets it as updatable or not (default `false`)
  23818. * @param geometry the geometry the vertexData is applied to
  23819. * @param updatable when used and having the value true allows new data to update the vertexData
  23820. * @returns VertexData
  23821. */
  23822. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23823. /**
  23824. * Updates the associated mesh
  23825. * @param mesh the mesh to be updated
  23826. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23827. * @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
  23828. * @returns VertexData
  23829. */
  23830. updateMesh(mesh: Mesh): VertexData;
  23831. /**
  23832. * Updates the associated geometry
  23833. * @param geometry the geometry to be updated
  23834. * @param updateExtends when true 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. updateGeometry(geometry: Geometry): VertexData;
  23839. private _applyTo;
  23840. private _update;
  23841. /**
  23842. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23843. * @param matrix the transforming matrix
  23844. * @returns the VertexData
  23845. */
  23846. transform(matrix: Matrix): VertexData;
  23847. /**
  23848. * Merges the passed VertexData into the current one
  23849. * @param other the VertexData to be merged into the current one
  23850. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23851. * @returns the modified VertexData
  23852. */
  23853. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23854. private _mergeElement;
  23855. private _validate;
  23856. /**
  23857. * Serializes the VertexData
  23858. * @returns a serialized object
  23859. */
  23860. serialize(): any;
  23861. /**
  23862. * Extracts the vertexData from a mesh
  23863. * @param mesh the mesh from which to extract the VertexData
  23864. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23866. * @returns the object VertexData associated to the passed mesh
  23867. */
  23868. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23869. /**
  23870. * Extracts the vertexData from the geometry
  23871. * @param geometry the geometry from which to extract the VertexData
  23872. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is 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 ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23877. private static _ExtractFrom;
  23878. /**
  23879. * Creates the VertexData for a Ribbon
  23880. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23881. * * pathArray array of paths, each of which an array of successive Vector3
  23882. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23883. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23884. * * 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
  23885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23886. * * 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)
  23887. * * 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)
  23888. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23889. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23890. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23891. * @returns the VertexData of the ribbon
  23892. */
  23893. static CreateRibbon(options: {
  23894. pathArray: Vector3[][];
  23895. closeArray?: boolean;
  23896. closePath?: boolean;
  23897. offset?: number;
  23898. sideOrientation?: number;
  23899. frontUVs?: Vector4;
  23900. backUVs?: Vector4;
  23901. invertUV?: boolean;
  23902. uvs?: Vector2[];
  23903. colors?: Color4[];
  23904. }): VertexData;
  23905. /**
  23906. * Creates the VertexData for a box
  23907. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23908. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23909. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23910. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23911. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23912. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23913. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23915. * * 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)
  23916. * * 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)
  23917. * @returns the VertexData of the box
  23918. */
  23919. static CreateBox(options: {
  23920. size?: number;
  23921. width?: number;
  23922. height?: number;
  23923. depth?: number;
  23924. faceUV?: Vector4[];
  23925. faceColors?: Color4[];
  23926. sideOrientation?: number;
  23927. frontUVs?: Vector4;
  23928. backUVs?: Vector4;
  23929. }): VertexData;
  23930. /**
  23931. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23932. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23933. * * segments sets the number of horizontal strips optional, default 32
  23934. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23935. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23936. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23937. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23938. * * 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
  23939. * * 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
  23940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23941. * * 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)
  23942. * * 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)
  23943. * @returns the VertexData of the ellipsoid
  23944. */
  23945. static CreateSphere(options: {
  23946. segments?: number;
  23947. diameter?: number;
  23948. diameterX?: number;
  23949. diameterY?: number;
  23950. diameterZ?: number;
  23951. arc?: number;
  23952. slice?: number;
  23953. sideOrientation?: number;
  23954. frontUVs?: Vector4;
  23955. backUVs?: Vector4;
  23956. }): VertexData;
  23957. /**
  23958. * Creates the VertexData for a cylinder, cone or prism
  23959. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23960. * * height sets the height (y direction) of the cylinder, optional, default 2
  23961. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23962. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23963. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23964. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23965. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23966. * * 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
  23967. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23968. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23969. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23970. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23972. * * 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)
  23973. * * 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)
  23974. * @returns the VertexData of the cylinder, cone or prism
  23975. */
  23976. static CreateCylinder(options: {
  23977. height?: number;
  23978. diameterTop?: number;
  23979. diameterBottom?: number;
  23980. diameter?: number;
  23981. tessellation?: number;
  23982. subdivisions?: number;
  23983. arc?: number;
  23984. faceColors?: Color4[];
  23985. faceUV?: Vector4[];
  23986. hasRings?: boolean;
  23987. enclose?: boolean;
  23988. sideOrientation?: number;
  23989. frontUVs?: Vector4;
  23990. backUVs?: Vector4;
  23991. }): VertexData;
  23992. /**
  23993. * Creates the VertexData for a torus
  23994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23995. * * diameter the diameter of the torus, optional default 1
  23996. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23997. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23999. * * 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)
  24000. * * 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)
  24001. * @returns the VertexData of the torus
  24002. */
  24003. static CreateTorus(options: {
  24004. diameter?: number;
  24005. thickness?: number;
  24006. tessellation?: number;
  24007. sideOrientation?: number;
  24008. frontUVs?: Vector4;
  24009. backUVs?: Vector4;
  24010. }): VertexData;
  24011. /**
  24012. * Creates the VertexData of the LineSystem
  24013. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24014. * - lines an array of lines, each line being an array of successive Vector3
  24015. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24016. * @returns the VertexData of the LineSystem
  24017. */
  24018. static CreateLineSystem(options: {
  24019. lines: Vector3[][];
  24020. colors?: Nullable<Color4[][]>;
  24021. }): VertexData;
  24022. /**
  24023. * Create the VertexData for a DashedLines
  24024. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24025. * - points an array successive Vector3
  24026. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24027. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24028. * - dashNb the intended total number of dashes, optional, default 200
  24029. * @returns the VertexData for the DashedLines
  24030. */
  24031. static CreateDashedLines(options: {
  24032. points: Vector3[];
  24033. dashSize?: number;
  24034. gapSize?: number;
  24035. dashNb?: number;
  24036. }): VertexData;
  24037. /**
  24038. * Creates the VertexData for a Ground
  24039. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24040. * - width the width (x direction) of the ground, optional, default 1
  24041. * - height the height (z direction) of the ground, optional, default 1
  24042. * - subdivisions the number of subdivisions per side, optional, default 1
  24043. * @returns the VertexData of the Ground
  24044. */
  24045. static CreateGround(options: {
  24046. width?: number;
  24047. height?: number;
  24048. subdivisions?: number;
  24049. subdivisionsX?: number;
  24050. subdivisionsY?: number;
  24051. }): VertexData;
  24052. /**
  24053. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24054. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24055. * * xmin the ground minimum X coordinate, optional, default -1
  24056. * * zmin the ground minimum Z coordinate, optional, default -1
  24057. * * xmax the ground maximum X coordinate, optional, default 1
  24058. * * zmax the ground maximum Z coordinate, optional, default 1
  24059. * * 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}
  24060. * * 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}
  24061. * @returns the VertexData of the TiledGround
  24062. */
  24063. static CreateTiledGround(options: {
  24064. xmin: number;
  24065. zmin: number;
  24066. xmax: number;
  24067. zmax: number;
  24068. subdivisions?: {
  24069. w: number;
  24070. h: number;
  24071. };
  24072. precision?: {
  24073. w: number;
  24074. h: number;
  24075. };
  24076. }): VertexData;
  24077. /**
  24078. * Creates the VertexData of the Ground designed from a heightmap
  24079. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24080. * * width the width (x direction) of the ground
  24081. * * height the height (z direction) of the ground
  24082. * * subdivisions the number of subdivisions per side
  24083. * * minHeight the minimum altitude on the ground, optional, default 0
  24084. * * maxHeight the maximum altitude on the ground, optional default 1
  24085. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24086. * * buffer the array holding the image color data
  24087. * * bufferWidth the width of image
  24088. * * bufferHeight the height of image
  24089. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24090. * @returns the VertexData of the Ground designed from a heightmap
  24091. */
  24092. static CreateGroundFromHeightMap(options: {
  24093. width: number;
  24094. height: number;
  24095. subdivisions: number;
  24096. minHeight: number;
  24097. maxHeight: number;
  24098. colorFilter: Color3;
  24099. buffer: Uint8Array;
  24100. bufferWidth: number;
  24101. bufferHeight: number;
  24102. alphaFilter: number;
  24103. }): VertexData;
  24104. /**
  24105. * Creates the VertexData for a Plane
  24106. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24107. * * size sets the width and height of the plane to the value of size, optional default 1
  24108. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24109. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24111. * * 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)
  24112. * * 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)
  24113. * @returns the VertexData of the box
  24114. */
  24115. static CreatePlane(options: {
  24116. size?: number;
  24117. width?: number;
  24118. height?: number;
  24119. sideOrientation?: number;
  24120. frontUVs?: Vector4;
  24121. backUVs?: Vector4;
  24122. }): VertexData;
  24123. /**
  24124. * Creates the VertexData of the Disc or regular Polygon
  24125. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24126. * * radius the radius of the disc, optional default 0.5
  24127. * * tessellation the number of polygon sides, optional, default 64
  24128. * * 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
  24129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24130. * * 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)
  24131. * * 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)
  24132. * @returns the VertexData of the box
  24133. */
  24134. static CreateDisc(options: {
  24135. radius?: number;
  24136. tessellation?: number;
  24137. arc?: number;
  24138. sideOrientation?: number;
  24139. frontUVs?: Vector4;
  24140. backUVs?: Vector4;
  24141. }): VertexData;
  24142. /**
  24143. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24144. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24145. * @param polygon a mesh built from polygonTriangulation.build()
  24146. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24147. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24148. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24149. * @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)
  24150. * @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)
  24151. * @returns the VertexData of the Polygon
  24152. */
  24153. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24154. /**
  24155. * Creates the VertexData of the IcoSphere
  24156. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24157. * * radius the radius of the IcoSphere, optional default 1
  24158. * * radiusX allows stretching in the x direction, optional, default radius
  24159. * * radiusY allows stretching in the y direction, optional, default radius
  24160. * * radiusZ allows stretching in the z direction, optional, default radius
  24161. * * flat when true creates a flat shaded mesh, optional, default true
  24162. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24164. * * 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)
  24165. * * 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)
  24166. * @returns the VertexData of the IcoSphere
  24167. */
  24168. static CreateIcoSphere(options: {
  24169. radius?: number;
  24170. radiusX?: number;
  24171. radiusY?: number;
  24172. radiusZ?: number;
  24173. flat?: boolean;
  24174. subdivisions?: number;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a Polyhedron
  24181. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24182. * * type provided types are:
  24183. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24184. * * 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)
  24185. * * size the size of the IcoSphere, optional default 1
  24186. * * sizeX allows stretching in the x direction, optional, default size
  24187. * * sizeY allows stretching in the y direction, optional, default size
  24188. * * sizeZ allows stretching in the z direction, optional, default size
  24189. * * 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
  24190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24191. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24192. * * flat when true creates a flat shaded mesh, optional, default true
  24193. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24195. * * 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)
  24196. * * 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)
  24197. * @returns the VertexData of the Polyhedron
  24198. */
  24199. static CreatePolyhedron(options: {
  24200. type?: number;
  24201. size?: number;
  24202. sizeX?: number;
  24203. sizeY?: number;
  24204. sizeZ?: number;
  24205. custom?: any;
  24206. faceUV?: Vector4[];
  24207. faceColors?: Color4[];
  24208. flat?: boolean;
  24209. sideOrientation?: number;
  24210. frontUVs?: Vector4;
  24211. backUVs?: Vector4;
  24212. }): VertexData;
  24213. /**
  24214. * Creates the VertexData for a TorusKnot
  24215. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24216. * * radius the radius of the torus knot, optional, default 2
  24217. * * tube the thickness of the tube, optional, default 0.5
  24218. * * radialSegments the number of sides on each tube segments, optional, default 32
  24219. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24220. * * p the number of windings around the z axis, optional, default 2
  24221. * * q the number of windings around the x axis, optional, default 3
  24222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24223. * * 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)
  24224. * * 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)
  24225. * @returns the VertexData of the Torus Knot
  24226. */
  24227. static CreateTorusKnot(options: {
  24228. radius?: number;
  24229. tube?: number;
  24230. radialSegments?: number;
  24231. tubularSegments?: number;
  24232. p?: number;
  24233. q?: number;
  24234. sideOrientation?: number;
  24235. frontUVs?: Vector4;
  24236. backUVs?: Vector4;
  24237. }): VertexData;
  24238. /**
  24239. * Compute normals for given positions and indices
  24240. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24241. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24242. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24243. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24244. * * facetNormals : optional array of facet normals (vector3)
  24245. * * facetPositions : optional array of facet positions (vector3)
  24246. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24247. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24248. * * bInfo : optional bounding info, required for facetPartitioning computation
  24249. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24250. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24251. * * useRightHandedSystem: optional boolean to for right handed system computation
  24252. * * depthSort : optional boolean to enable the facet depth sort computation
  24253. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24254. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24255. */
  24256. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24257. facetNormals?: any;
  24258. facetPositions?: any;
  24259. facetPartitioning?: any;
  24260. ratio?: number;
  24261. bInfo?: any;
  24262. bbSize?: Vector3;
  24263. subDiv?: any;
  24264. useRightHandedSystem?: boolean;
  24265. depthSort?: boolean;
  24266. distanceTo?: Vector3;
  24267. depthSortedFacets?: any;
  24268. }): void;
  24269. /** @hidden */
  24270. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24271. /**
  24272. * Applies VertexData created from the imported parameters to the geometry
  24273. * @param parsedVertexData the parsed data from an imported file
  24274. * @param geometry the geometry to apply the VertexData to
  24275. */
  24276. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24277. }
  24278. }
  24279. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24280. import { Nullable } from "babylonjs/types";
  24281. import { Scene } from "babylonjs/scene";
  24282. import { Vector4 } from "babylonjs/Maths/math";
  24283. import { Mesh } from "babylonjs/Meshes/mesh";
  24284. /**
  24285. * Class containing static functions to help procedurally build meshes
  24286. */
  24287. export class DiscBuilder {
  24288. /**
  24289. * Creates a plane polygonal mesh. By default, this is a disc
  24290. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24291. * * 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
  24292. * * 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
  24293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24296. * @param name defines the name of the mesh
  24297. * @param options defines the options used to create the mesh
  24298. * @param scene defines the hosting scene
  24299. * @returns the plane polygonal mesh
  24300. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24301. */
  24302. static CreateDisc(name: string, options: {
  24303. radius?: number;
  24304. tessellation?: number;
  24305. arc?: number;
  24306. updatable?: boolean;
  24307. sideOrientation?: number;
  24308. frontUVs?: Vector4;
  24309. backUVs?: Vector4;
  24310. }, scene?: Nullable<Scene>): Mesh;
  24311. }
  24312. }
  24313. declare module "babylonjs/Particles/solidParticleSystem" {
  24314. import { Vector3 } from "babylonjs/Maths/math";
  24315. import { Mesh } from "babylonjs/Meshes/mesh";
  24316. import { Scene, IDisposable } from "babylonjs/scene";
  24317. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24318. /**
  24319. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24320. *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.
  24321. * The SPS is also a particle system. It provides some methods to manage the particles.
  24322. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24323. *
  24324. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24325. */
  24326. export class SolidParticleSystem implements IDisposable {
  24327. /**
  24328. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24329. * Example : var p = SPS.particles[i];
  24330. */
  24331. particles: SolidParticle[];
  24332. /**
  24333. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24334. */
  24335. nbParticles: number;
  24336. /**
  24337. * If the particles must ever face the camera (default false). Useful for planar particles.
  24338. */
  24339. billboard: boolean;
  24340. /**
  24341. * Recompute normals when adding a shape
  24342. */
  24343. recomputeNormals: boolean;
  24344. /**
  24345. * This a counter ofr your own usage. It's not set by any SPS functions.
  24346. */
  24347. counter: number;
  24348. /**
  24349. * The SPS name. This name is also given to the underlying mesh.
  24350. */
  24351. name: string;
  24352. /**
  24353. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24354. */
  24355. mesh: Mesh;
  24356. /**
  24357. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24358. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24359. */
  24360. vars: any;
  24361. /**
  24362. * This array is populated when the SPS is set as 'pickable'.
  24363. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24364. * Each element of this array is an object `{idx: int, faceId: int}`.
  24365. * `idx` is the picked particle index in the `SPS.particles` array
  24366. * `faceId` is the picked face index counted within this particle.
  24367. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24368. */
  24369. pickedParticles: {
  24370. idx: number;
  24371. faceId: number;
  24372. }[];
  24373. /**
  24374. * This array is populated when `enableDepthSort` is set to true.
  24375. * Each element of this array is an instance of the class DepthSortedParticle.
  24376. */
  24377. depthSortedParticles: DepthSortedParticle[];
  24378. /**
  24379. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24380. * @hidden
  24381. */
  24382. _bSphereOnly: boolean;
  24383. /**
  24384. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24385. * @hidden
  24386. */
  24387. _bSphereRadiusFactor: number;
  24388. private _scene;
  24389. private _positions;
  24390. private _indices;
  24391. private _normals;
  24392. private _colors;
  24393. private _uvs;
  24394. private _indices32;
  24395. private _positions32;
  24396. private _normals32;
  24397. private _fixedNormal32;
  24398. private _colors32;
  24399. private _uvs32;
  24400. private _index;
  24401. private _updatable;
  24402. private _pickable;
  24403. private _isVisibilityBoxLocked;
  24404. private _alwaysVisible;
  24405. private _depthSort;
  24406. private _shapeCounter;
  24407. private _copy;
  24408. private _color;
  24409. private _computeParticleColor;
  24410. private _computeParticleTexture;
  24411. private _computeParticleRotation;
  24412. private _computeParticleVertex;
  24413. private _computeBoundingBox;
  24414. private _depthSortParticles;
  24415. private _camera;
  24416. private _mustUnrotateFixedNormals;
  24417. private _particlesIntersect;
  24418. private _needs32Bits;
  24419. /**
  24420. * Creates a SPS (Solid Particle System) object.
  24421. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24422. * @param scene (Scene) is the scene in which the SPS is added.
  24423. * @param options defines the options of the sps e.g.
  24424. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24425. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24426. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24427. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24428. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24429. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24430. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24431. */
  24432. constructor(name: string, scene: Scene, options?: {
  24433. updatable?: boolean;
  24434. isPickable?: boolean;
  24435. enableDepthSort?: boolean;
  24436. particleIntersection?: boolean;
  24437. boundingSphereOnly?: boolean;
  24438. bSphereRadiusFactor?: number;
  24439. });
  24440. /**
  24441. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24442. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24443. * @returns the created mesh
  24444. */
  24445. buildMesh(): Mesh;
  24446. /**
  24447. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24448. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24449. * Thus the particles generated from `digest()` have their property `position` set yet.
  24450. * @param mesh ( Mesh ) is the mesh to be digested
  24451. * @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
  24452. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24453. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24454. * @returns the current SPS
  24455. */
  24456. digest(mesh: Mesh, options?: {
  24457. facetNb?: number;
  24458. number?: number;
  24459. delta?: number;
  24460. }): SolidParticleSystem;
  24461. private _unrotateFixedNormals;
  24462. private _resetCopy;
  24463. private _meshBuilder;
  24464. private _posToShape;
  24465. private _uvsToShapeUV;
  24466. private _addParticle;
  24467. /**
  24468. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24469. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24470. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24471. * @param nb (positive integer) the number of particles to be created from this model
  24472. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24473. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24474. * @returns the number of shapes in the system
  24475. */
  24476. addShape(mesh: Mesh, nb: number, options?: {
  24477. positionFunction?: any;
  24478. vertexFunction?: any;
  24479. }): number;
  24480. private _rebuildParticle;
  24481. /**
  24482. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24483. * @returns the SPS.
  24484. */
  24485. rebuildMesh(): SolidParticleSystem;
  24486. /**
  24487. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24488. * This method calls `updateParticle()` for each particle of the SPS.
  24489. * For an animated SPS, it is usually called within the render loop.
  24490. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24491. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24492. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24493. * @returns the SPS.
  24494. */
  24495. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24496. /**
  24497. * Disposes the SPS.
  24498. */
  24499. dispose(): void;
  24500. /**
  24501. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24502. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24503. * @returns the SPS.
  24504. */
  24505. refreshVisibleSize(): SolidParticleSystem;
  24506. /**
  24507. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24508. * @param size the size (float) of the visibility box
  24509. * note : this doesn't lock the SPS mesh bounding box.
  24510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24511. */
  24512. setVisibilityBox(size: number): void;
  24513. /**
  24514. * Gets whether the SPS as always visible or not
  24515. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24516. */
  24517. /**
  24518. * Sets the SPS as always visible or not
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. isAlwaysVisible: boolean;
  24522. /**
  24523. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24524. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24525. */
  24526. /**
  24527. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24529. */
  24530. isVisibilityBoxLocked: boolean;
  24531. /**
  24532. * Tells to `setParticles()` to compute the particle rotations or not.
  24533. * Default value : true. The SPS is faster when it's set to false.
  24534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24535. */
  24536. /**
  24537. * Gets if `setParticles()` computes the particle rotations or not.
  24538. * Default value : true. The SPS is faster when it's set to false.
  24539. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24540. */
  24541. computeParticleRotation: boolean;
  24542. /**
  24543. * Tells to `setParticles()` to compute the particle colors or not.
  24544. * Default value : true. The SPS is faster when it's set to false.
  24545. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24546. */
  24547. /**
  24548. * Gets if `setParticles()` computes the particle colors or not.
  24549. * Default value : true. The SPS is faster when it's set to false.
  24550. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24551. */
  24552. computeParticleColor: boolean;
  24553. /**
  24554. * Gets if `setParticles()` computes the particle textures or not.
  24555. * Default value : true. The SPS is faster when it's set to false.
  24556. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24557. */
  24558. computeParticleTexture: boolean;
  24559. /**
  24560. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24561. * Default value : false. The SPS is faster when it's set to false.
  24562. * Note : the particle custom vertex positions aren't stored values.
  24563. */
  24564. /**
  24565. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24566. * Default value : false. The SPS is faster when it's set to false.
  24567. * Note : the particle custom vertex positions aren't stored values.
  24568. */
  24569. computeParticleVertex: boolean;
  24570. /**
  24571. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24572. */
  24573. /**
  24574. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24575. */
  24576. computeBoundingBox: boolean;
  24577. /**
  24578. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24579. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24580. * Default : `true`
  24581. */
  24582. /**
  24583. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24584. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24585. * Default : `true`
  24586. */
  24587. depthSortParticles: boolean;
  24588. /**
  24589. * This function does nothing. It may be overwritten to set all the particle first values.
  24590. * The SPS doesn't call this function, you may have to call it by your own.
  24591. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24592. */
  24593. initParticles(): void;
  24594. /**
  24595. * This function does nothing. It may be overwritten to recycle a particle.
  24596. * The SPS doesn't call this function, you may have to call it by your own.
  24597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24598. * @param particle The particle to recycle
  24599. * @returns the recycled particle
  24600. */
  24601. recycleParticle(particle: SolidParticle): SolidParticle;
  24602. /**
  24603. * Updates a particle : this function should be overwritten by the user.
  24604. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24606. * @example : just set a particle position or velocity and recycle conditions
  24607. * @param particle The particle to update
  24608. * @returns the updated particle
  24609. */
  24610. updateParticle(particle: SolidParticle): SolidParticle;
  24611. /**
  24612. * Updates a vertex of a particle : it can be overwritten by the user.
  24613. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24614. * @param particle the current particle
  24615. * @param vertex the current index of the current particle
  24616. * @param pt the index of the current vertex in the particle shape
  24617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24618. * @example : just set a vertex particle position
  24619. * @returns the updated vertex
  24620. */
  24621. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24622. /**
  24623. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24624. * This does nothing and may be overwritten by the user.
  24625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24627. * @param update the boolean update value actually passed to setParticles()
  24628. */
  24629. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24630. /**
  24631. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24632. * This will be passed three parameters.
  24633. * This does nothing and may be overwritten by the user.
  24634. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24635. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24636. * @param update the boolean update value actually passed to setParticles()
  24637. */
  24638. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24639. }
  24640. }
  24641. declare module "babylonjs/Particles/solidParticle" {
  24642. import { Nullable } from "babylonjs/types";
  24643. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24644. import { Mesh } from "babylonjs/Meshes/mesh";
  24645. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24646. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24647. /**
  24648. * Represents one particle of a solid particle system.
  24649. */
  24650. export class SolidParticle {
  24651. /**
  24652. * particle global index
  24653. */
  24654. idx: number;
  24655. /**
  24656. * The color of the particle
  24657. */
  24658. color: Nullable<Color4>;
  24659. /**
  24660. * The world space position of the particle.
  24661. */
  24662. position: Vector3;
  24663. /**
  24664. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24665. */
  24666. rotation: Vector3;
  24667. /**
  24668. * The world space rotation quaternion of the particle.
  24669. */
  24670. rotationQuaternion: Nullable<Quaternion>;
  24671. /**
  24672. * The scaling of the particle.
  24673. */
  24674. scaling: Vector3;
  24675. /**
  24676. * The uvs of the particle.
  24677. */
  24678. uvs: Vector4;
  24679. /**
  24680. * The current speed of the particle.
  24681. */
  24682. velocity: Vector3;
  24683. /**
  24684. * The pivot point in the particle local space.
  24685. */
  24686. pivot: Vector3;
  24687. /**
  24688. * Must the particle be translated from its pivot point in its local space ?
  24689. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24690. * Default : false
  24691. */
  24692. translateFromPivot: boolean;
  24693. /**
  24694. * Is the particle active or not ?
  24695. */
  24696. alive: boolean;
  24697. /**
  24698. * Is the particle visible or not ?
  24699. */
  24700. isVisible: boolean;
  24701. /**
  24702. * Index of this particle in the global "positions" array (Internal use)
  24703. * @hidden
  24704. */
  24705. _pos: number;
  24706. /**
  24707. * @hidden Index of this particle in the global "indices" array (Internal use)
  24708. */
  24709. _ind: number;
  24710. /**
  24711. * @hidden ModelShape of this particle (Internal use)
  24712. */
  24713. _model: ModelShape;
  24714. /**
  24715. * ModelShape id of this particle
  24716. */
  24717. shapeId: number;
  24718. /**
  24719. * Index of the particle in its shape id (Internal use)
  24720. */
  24721. idxInShape: number;
  24722. /**
  24723. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24724. */
  24725. _modelBoundingInfo: BoundingInfo;
  24726. /**
  24727. * @hidden Particle BoundingInfo object (Internal use)
  24728. */
  24729. _boundingInfo: BoundingInfo;
  24730. /**
  24731. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24732. */
  24733. _sps: SolidParticleSystem;
  24734. /**
  24735. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24736. */
  24737. _stillInvisible: boolean;
  24738. /**
  24739. * @hidden Last computed particle rotation matrix
  24740. */
  24741. _rotationMatrix: number[];
  24742. /**
  24743. * Parent particle Id, if any.
  24744. * Default null.
  24745. */
  24746. parentId: Nullable<number>;
  24747. /**
  24748. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24749. * The possible values are :
  24750. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24751. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24752. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24753. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24754. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24755. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24756. * */
  24757. cullingStrategy: number;
  24758. /**
  24759. * @hidden Internal global position in the SPS.
  24760. */
  24761. _globalPosition: Vector3;
  24762. /**
  24763. * Creates a Solid Particle object.
  24764. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24765. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24766. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24767. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24768. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24769. * @param shapeId (integer) is the model shape identifier in the SPS.
  24770. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24771. * @param sps defines the sps it is associated to
  24772. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24773. */
  24774. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24775. /**
  24776. * Legacy support, changed scale to scaling
  24777. */
  24778. /**
  24779. * Legacy support, changed scale to scaling
  24780. */
  24781. scale: Vector3;
  24782. /**
  24783. * Legacy support, changed quaternion to rotationQuaternion
  24784. */
  24785. /**
  24786. * Legacy support, changed quaternion to rotationQuaternion
  24787. */
  24788. quaternion: Nullable<Quaternion>;
  24789. /**
  24790. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24791. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24792. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24793. * @returns true if it intersects
  24794. */
  24795. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24796. /**
  24797. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24798. * A particle is in the frustum if its bounding box intersects the frustum
  24799. * @param frustumPlanes defines the frustum to test
  24800. * @returns true if the particle is in the frustum planes
  24801. */
  24802. isInFrustum(frustumPlanes: Plane[]): boolean;
  24803. /**
  24804. * get the rotation matrix of the particle
  24805. * @hidden
  24806. */
  24807. getRotationMatrix(m: Matrix): void;
  24808. }
  24809. /**
  24810. * Represents the shape of the model used by one particle of a solid particle system.
  24811. * SPS internal tool, don't use it manually.
  24812. */
  24813. export class ModelShape {
  24814. /**
  24815. * The shape id
  24816. * @hidden
  24817. */
  24818. shapeID: number;
  24819. /**
  24820. * flat array of model positions (internal use)
  24821. * @hidden
  24822. */
  24823. _shape: Vector3[];
  24824. /**
  24825. * flat array of model UVs (internal use)
  24826. * @hidden
  24827. */
  24828. _shapeUV: number[];
  24829. /**
  24830. * length of the shape in the model indices array (internal use)
  24831. * @hidden
  24832. */
  24833. _indicesLength: number;
  24834. /**
  24835. * Custom position function (internal use)
  24836. * @hidden
  24837. */
  24838. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24839. /**
  24840. * Custom vertex function (internal use)
  24841. * @hidden
  24842. */
  24843. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24844. /**
  24845. * 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.
  24846. * SPS internal tool, don't use it manually.
  24847. * @hidden
  24848. */
  24849. 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>);
  24850. }
  24851. /**
  24852. * Represents a Depth Sorted Particle in the solid particle system.
  24853. */
  24854. export class DepthSortedParticle {
  24855. /**
  24856. * Index of the particle in the "indices" array
  24857. */
  24858. ind: number;
  24859. /**
  24860. * Length of the particle shape in the "indices" array
  24861. */
  24862. indicesLength: number;
  24863. /**
  24864. * Squared distance from the particle to the camera
  24865. */
  24866. sqDistance: number;
  24867. }
  24868. }
  24869. declare module "babylonjs/Collisions/meshCollisionData" {
  24870. import { Collider } from "babylonjs/Collisions/collider";
  24871. import { Vector3 } from "babylonjs/Maths/math";
  24872. import { Nullable } from "babylonjs/types";
  24873. import { Observer } from "babylonjs/Misc/observable";
  24874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24875. /**
  24876. * @hidden
  24877. */
  24878. export class _MeshCollisionData {
  24879. _checkCollisions: boolean;
  24880. _collisionMask: number;
  24881. _collisionGroup: number;
  24882. _collider: Nullable<Collider>;
  24883. _oldPositionForCollisions: Vector3;
  24884. _diffPositionForCollisions: Vector3;
  24885. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24886. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24887. }
  24888. }
  24889. declare module "babylonjs/Meshes/abstractMesh" {
  24890. import { Observable } from "babylonjs/Misc/observable";
  24891. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24892. import { Camera } from "babylonjs/Cameras/camera";
  24893. import { Scene, IDisposable } from "babylonjs/scene";
  24894. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24895. import { Node } from "babylonjs/node";
  24896. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24897. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24900. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24901. import { Material } from "babylonjs/Materials/material";
  24902. import { Light } from "babylonjs/Lights/light";
  24903. import { Skeleton } from "babylonjs/Bones/skeleton";
  24904. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24905. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24906. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24907. import { Ray } from "babylonjs/Culling/ray";
  24908. import { Collider } from "babylonjs/Collisions/collider";
  24909. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24910. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24911. /**
  24912. * Class used to store all common mesh properties
  24913. */
  24914. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24915. /** No occlusion */
  24916. static OCCLUSION_TYPE_NONE: number;
  24917. /** Occlusion set to optimisitic */
  24918. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24919. /** Occlusion set to strict */
  24920. static OCCLUSION_TYPE_STRICT: number;
  24921. /** Use an accurante occlusion algorithm */
  24922. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24923. /** Use a conservative occlusion algorithm */
  24924. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24925. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24926. * Test order :
  24927. * Is the bounding sphere outside the frustum ?
  24928. * If not, are the bounding box vertices outside the frustum ?
  24929. * It not, then the cullable object is in the frustum.
  24930. */
  24931. static readonly CULLINGSTRATEGY_STANDARD: number;
  24932. /** Culling strategy : Bounding Sphere Only.
  24933. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24934. * It's also less accurate than the standard because some not visible objects can still be selected.
  24935. * Test : is the bounding sphere outside the frustum ?
  24936. * If not, then the cullable object is in the frustum.
  24937. */
  24938. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24939. /** Culling strategy : Optimistic Inclusion.
  24940. * This in an inclusion test first, then the standard exclusion test.
  24941. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24942. * 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.
  24943. * Anyway, it's as accurate as the standard strategy.
  24944. * Test :
  24945. * Is the cullable object bounding sphere center in the frustum ?
  24946. * If not, apply the default culling strategy.
  24947. */
  24948. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24949. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24950. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24951. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24952. * 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.
  24953. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24954. * Test :
  24955. * Is the cullable object bounding sphere center in the frustum ?
  24956. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24957. */
  24958. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24959. /**
  24960. * No billboard
  24961. */
  24962. static readonly BILLBOARDMODE_NONE: number;
  24963. /** Billboard on X axis */
  24964. static readonly BILLBOARDMODE_X: number;
  24965. /** Billboard on Y axis */
  24966. static readonly BILLBOARDMODE_Y: number;
  24967. /** Billboard on Z axis */
  24968. static readonly BILLBOARDMODE_Z: number;
  24969. /** Billboard on all axes */
  24970. static readonly BILLBOARDMODE_ALL: number;
  24971. private _internalAbstractMeshDataInfo;
  24972. /**
  24973. * The culling strategy to use to check whether the mesh must be rendered or not.
  24974. * This value can be changed at any time and will be used on the next render mesh selection.
  24975. * The possible values are :
  24976. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24977. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24978. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24979. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24980. * Please read each static variable documentation to get details about the culling process.
  24981. * */
  24982. cullingStrategy: number;
  24983. /**
  24984. * Gets the number of facets in the mesh
  24985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24986. */
  24987. readonly facetNb: number;
  24988. /**
  24989. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24991. */
  24992. partitioningSubdivisions: number;
  24993. /**
  24994. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24995. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24997. */
  24998. partitioningBBoxRatio: number;
  24999. /**
  25000. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25001. * Works only for updatable meshes.
  25002. * Doesn't work with multi-materials
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25004. */
  25005. mustDepthSortFacets: boolean;
  25006. /**
  25007. * The location (Vector3) where the facet depth sort must be computed from.
  25008. * By default, the active camera position.
  25009. * Used only when facet depth sort is enabled
  25010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25011. */
  25012. facetDepthSortFrom: Vector3;
  25013. /**
  25014. * gets a boolean indicating if facetData is enabled
  25015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25016. */
  25017. readonly isFacetDataEnabled: boolean;
  25018. /** @hidden */
  25019. _updateNonUniformScalingState(value: boolean): boolean;
  25020. /**
  25021. * An event triggered when this mesh collides with another one
  25022. */
  25023. onCollideObservable: Observable<AbstractMesh>;
  25024. /** Set a function to call when this mesh collides with another one */
  25025. onCollide: () => void;
  25026. /**
  25027. * An event triggered when the collision's position changes
  25028. */
  25029. onCollisionPositionChangeObservable: Observable<Vector3>;
  25030. /** Set a function to call when the collision's position changes */
  25031. onCollisionPositionChange: () => void;
  25032. /**
  25033. * An event triggered when material is changed
  25034. */
  25035. onMaterialChangedObservable: Observable<AbstractMesh>;
  25036. /**
  25037. * Gets or sets the orientation for POV movement & rotation
  25038. */
  25039. definedFacingForward: boolean;
  25040. /** @hidden */
  25041. _occlusionQuery: Nullable<WebGLQuery>;
  25042. /** @hidden */
  25043. _isActive: boolean;
  25044. /** @hidden */
  25045. _onlyForInstances: boolean;
  25046. /** @hidden */
  25047. _renderingGroup: Nullable<RenderingGroup>;
  25048. /**
  25049. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25050. */
  25051. /**
  25052. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25053. */
  25054. visibility: number;
  25055. /** Gets or sets the alpha index used to sort transparent meshes
  25056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25057. */
  25058. alphaIndex: number;
  25059. /**
  25060. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25061. */
  25062. isVisible: boolean;
  25063. /**
  25064. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25065. */
  25066. isPickable: boolean;
  25067. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25068. showSubMeshesBoundingBox: boolean;
  25069. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25070. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25071. */
  25072. isBlocker: boolean;
  25073. /**
  25074. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25075. */
  25076. enablePointerMoveEvents: boolean;
  25077. /**
  25078. * Specifies the rendering group id for this mesh (0 by default)
  25079. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25080. */
  25081. renderingGroupId: number;
  25082. private _material;
  25083. /** Gets or sets current material */
  25084. material: Nullable<Material>;
  25085. /**
  25086. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25087. * @see http://doc.babylonjs.com/babylon101/shadows
  25088. */
  25089. receiveShadows: boolean;
  25090. /** Defines color to use when rendering outline */
  25091. outlineColor: Color3;
  25092. /** Define width to use when rendering outline */
  25093. outlineWidth: number;
  25094. /** Defines color to use when rendering overlay */
  25095. overlayColor: Color3;
  25096. /** Defines alpha to use when rendering overlay */
  25097. overlayAlpha: number;
  25098. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25099. hasVertexAlpha: boolean;
  25100. /** 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) */
  25101. useVertexColors: boolean;
  25102. /**
  25103. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25104. */
  25105. computeBonesUsingShaders: boolean;
  25106. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25107. numBoneInfluencers: number;
  25108. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25109. applyFog: boolean;
  25110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25111. useOctreeForRenderingSelection: boolean;
  25112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25113. useOctreeForPicking: boolean;
  25114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25115. useOctreeForCollisions: boolean;
  25116. /**
  25117. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25118. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25119. */
  25120. layerMask: number;
  25121. /**
  25122. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25123. */
  25124. alwaysSelectAsActiveMesh: boolean;
  25125. /**
  25126. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25127. */
  25128. doNotSyncBoundingInfo: boolean;
  25129. /**
  25130. * Gets or sets the current action manager
  25131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25132. */
  25133. actionManager: Nullable<AbstractActionManager>;
  25134. private _meshCollisionData;
  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. /**
  25146. * Gets or sets a collision mask used to mask collisions (default is -1).
  25147. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25148. */
  25149. collisionMask: number;
  25150. /**
  25151. * Gets or sets the current collision group mask (-1 by default).
  25152. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25153. */
  25154. collisionGroup: number;
  25155. /**
  25156. * Defines edge width used when edgesRenderer is enabled
  25157. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25158. */
  25159. edgesWidth: number;
  25160. /**
  25161. * Defines edge color used when edgesRenderer is enabled
  25162. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25163. */
  25164. edgesColor: Color4;
  25165. /** @hidden */
  25166. _edgesRenderer: Nullable<IEdgesRenderer>;
  25167. /** @hidden */
  25168. _masterMesh: Nullable<AbstractMesh>;
  25169. /** @hidden */
  25170. _boundingInfo: Nullable<BoundingInfo>;
  25171. /** @hidden */
  25172. _renderId: number;
  25173. /**
  25174. * Gets or sets the list of subMeshes
  25175. * @see http://doc.babylonjs.com/how_to/multi_materials
  25176. */
  25177. subMeshes: SubMesh[];
  25178. /** @hidden */
  25179. _intersectionsInProgress: AbstractMesh[];
  25180. /** @hidden */
  25181. _unIndexed: boolean;
  25182. /** @hidden */
  25183. _lightSources: Light[];
  25184. /** Gets the list of lights affecting that mesh */
  25185. readonly lightSources: Light[];
  25186. /** @hidden */
  25187. readonly _positions: Nullable<Vector3[]>;
  25188. /** @hidden */
  25189. _waitingData: {
  25190. lods: Nullable<any>;
  25191. actions: Nullable<any>;
  25192. freezeWorldMatrix: Nullable<boolean>;
  25193. };
  25194. /** @hidden */
  25195. _bonesTransformMatrices: Nullable<Float32Array>;
  25196. /**
  25197. * Gets or sets a skeleton to apply skining transformations
  25198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25199. */
  25200. skeleton: Nullable<Skeleton>;
  25201. /**
  25202. * An event triggered when the mesh is rebuilt.
  25203. */
  25204. onRebuildObservable: Observable<AbstractMesh>;
  25205. /**
  25206. * Creates a new AbstractMesh
  25207. * @param name defines the name of the mesh
  25208. * @param scene defines the hosting scene
  25209. */
  25210. constructor(name: string, scene?: Nullable<Scene>);
  25211. /**
  25212. * Returns the string "AbstractMesh"
  25213. * @returns "AbstractMesh"
  25214. */
  25215. getClassName(): string;
  25216. /**
  25217. * Gets a string representation of the current mesh
  25218. * @param fullDetails defines a boolean indicating if full details must be included
  25219. * @returns a string representation of the current mesh
  25220. */
  25221. toString(fullDetails?: boolean): string;
  25222. /**
  25223. * @hidden
  25224. */
  25225. protected _getEffectiveParent(): Nullable<Node>;
  25226. /** @hidden */
  25227. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25228. /** @hidden */
  25229. _rebuild(): void;
  25230. /** @hidden */
  25231. _resyncLightSources(): void;
  25232. /** @hidden */
  25233. _resyncLighSource(light: Light): void;
  25234. /** @hidden */
  25235. _unBindEffect(): void;
  25236. /** @hidden */
  25237. _removeLightSource(light: Light): void;
  25238. private _markSubMeshesAsDirty;
  25239. /** @hidden */
  25240. _markSubMeshesAsLightDirty(): void;
  25241. /** @hidden */
  25242. _markSubMeshesAsAttributesDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsMiscDirty(): void;
  25245. /**
  25246. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25247. */
  25248. scaling: Vector3;
  25249. /**
  25250. * Returns true if the mesh is blocked. Implemented by child classes
  25251. */
  25252. readonly isBlocked: boolean;
  25253. /**
  25254. * Returns the mesh itself by default. Implemented by child classes
  25255. * @param camera defines the camera to use to pick the right LOD level
  25256. * @returns the currentAbstractMesh
  25257. */
  25258. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25259. /**
  25260. * Returns 0 by default. Implemented by child classes
  25261. * @returns an integer
  25262. */
  25263. getTotalVertices(): number;
  25264. /**
  25265. * Returns a positive integer : the total number of indices in this mesh geometry.
  25266. * @returns the numner of indices or zero if the mesh has no geometry.
  25267. */
  25268. getTotalIndices(): number;
  25269. /**
  25270. * Returns null by default. Implemented by child classes
  25271. * @returns null
  25272. */
  25273. getIndices(): Nullable<IndicesArray>;
  25274. /**
  25275. * Returns the array of the requested vertex data kind. Implemented by child classes
  25276. * @param kind defines the vertex data kind to use
  25277. * @returns null
  25278. */
  25279. getVerticesData(kind: string): Nullable<FloatArray>;
  25280. /**
  25281. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25282. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25283. * Note that a new underlying VertexBuffer object is created each call.
  25284. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25285. * @param kind defines vertex data kind:
  25286. * * VertexBuffer.PositionKind
  25287. * * VertexBuffer.UVKind
  25288. * * VertexBuffer.UV2Kind
  25289. * * VertexBuffer.UV3Kind
  25290. * * VertexBuffer.UV4Kind
  25291. * * VertexBuffer.UV5Kind
  25292. * * VertexBuffer.UV6Kind
  25293. * * VertexBuffer.ColorKind
  25294. * * VertexBuffer.MatricesIndicesKind
  25295. * * VertexBuffer.MatricesIndicesExtraKind
  25296. * * VertexBuffer.MatricesWeightsKind
  25297. * * VertexBuffer.MatricesWeightsExtraKind
  25298. * @param data defines the data source
  25299. * @param updatable defines if the data must be flagged as updatable (or static)
  25300. * @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
  25301. * @returns the current mesh
  25302. */
  25303. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25304. /**
  25305. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25306. * If the mesh has no geometry, it is simply returned as it is.
  25307. * @param kind defines vertex data kind:
  25308. * * VertexBuffer.PositionKind
  25309. * * VertexBuffer.UVKind
  25310. * * VertexBuffer.UV2Kind
  25311. * * VertexBuffer.UV3Kind
  25312. * * VertexBuffer.UV4Kind
  25313. * * VertexBuffer.UV5Kind
  25314. * * VertexBuffer.UV6Kind
  25315. * * VertexBuffer.ColorKind
  25316. * * VertexBuffer.MatricesIndicesKind
  25317. * * VertexBuffer.MatricesIndicesExtraKind
  25318. * * VertexBuffer.MatricesWeightsKind
  25319. * * VertexBuffer.MatricesWeightsExtraKind
  25320. * @param data defines the data source
  25321. * @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
  25322. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25323. * @returns the current mesh
  25324. */
  25325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25326. /**
  25327. * Sets the mesh indices,
  25328. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25329. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25330. * @param totalVertices Defines the total number of vertices
  25331. * @returns the current mesh
  25332. */
  25333. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25334. /**
  25335. * Gets a boolean indicating if specific vertex data is present
  25336. * @param kind defines the vertex data kind to use
  25337. * @returns true is data kind is present
  25338. */
  25339. isVerticesDataPresent(kind: string): boolean;
  25340. /**
  25341. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25342. * @returns a BoundingInfo
  25343. */
  25344. getBoundingInfo(): BoundingInfo;
  25345. /**
  25346. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25347. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25348. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25349. * @returns the current mesh
  25350. */
  25351. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25352. /**
  25353. * Overwrite the current bounding info
  25354. * @param boundingInfo defines the new bounding info
  25355. * @returns the current mesh
  25356. */
  25357. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25358. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25359. readonly useBones: boolean;
  25360. /** @hidden */
  25361. _preActivate(): void;
  25362. /** @hidden */
  25363. _preActivateForIntermediateRendering(renderId: number): void;
  25364. /** @hidden */
  25365. _activate(renderId: number): boolean;
  25366. /** @hidden */
  25367. _postActivate(): void;
  25368. /** @hidden */
  25369. _freeze(): void;
  25370. /** @hidden */
  25371. _unFreeze(): void;
  25372. /**
  25373. * Gets the current world matrix
  25374. * @returns a Matrix
  25375. */
  25376. getWorldMatrix(): Matrix;
  25377. /** @hidden */
  25378. _getWorldMatrixDeterminant(): number;
  25379. /**
  25380. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25381. */
  25382. readonly isAnInstance: boolean;
  25383. /**
  25384. * Perform relative position change from the point of view of behind the front of the mesh.
  25385. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25386. * Supports definition of mesh facing forward or backward
  25387. * @param amountRight defines the distance on the right axis
  25388. * @param amountUp defines the distance on the up axis
  25389. * @param amountForward defines the distance on the forward axis
  25390. * @returns the current mesh
  25391. */
  25392. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25393. /**
  25394. * Calculate relative position change from the point of view of behind the front of the mesh.
  25395. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25396. * Supports definition of mesh facing forward or backward
  25397. * @param amountRight defines the distance on the right axis
  25398. * @param amountUp defines the distance on the up axis
  25399. * @param amountForward defines the distance on the forward axis
  25400. * @returns the new displacement vector
  25401. */
  25402. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25403. /**
  25404. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25405. * Supports definition of mesh facing forward or backward
  25406. * @param flipBack defines the flip
  25407. * @param twirlClockwise defines the twirl
  25408. * @param tiltRight defines the tilt
  25409. * @returns the current mesh
  25410. */
  25411. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25412. /**
  25413. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25414. * Supports definition of mesh facing forward or backward.
  25415. * @param flipBack defines the flip
  25416. * @param twirlClockwise defines the twirl
  25417. * @param tiltRight defines the tilt
  25418. * @returns the new rotation vector
  25419. */
  25420. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25421. /**
  25422. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25423. * This means the mesh underlying bounding box and sphere are recomputed.
  25424. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25425. * @returns the current mesh
  25426. */
  25427. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25428. /** @hidden */
  25429. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25430. /** @hidden */
  25431. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25432. /** @hidden */
  25433. _updateBoundingInfo(): AbstractMesh;
  25434. /** @hidden */
  25435. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25436. /** @hidden */
  25437. protected _afterComputeWorldMatrix(): void;
  25438. /** @hidden */
  25439. readonly _effectiveMesh: AbstractMesh;
  25440. /**
  25441. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25442. * A mesh is in the frustum if its bounding box intersects the frustum
  25443. * @param frustumPlanes defines the frustum to test
  25444. * @returns true if the mesh is in the frustum planes
  25445. */
  25446. isInFrustum(frustumPlanes: Plane[]): boolean;
  25447. /**
  25448. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25449. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25450. * @param frustumPlanes defines the frustum to test
  25451. * @returns true if the mesh is completely in the frustum planes
  25452. */
  25453. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25454. /**
  25455. * True if the mesh intersects another mesh or a SolidParticle object
  25456. * @param mesh defines a target mesh or SolidParticle to test
  25457. * @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)
  25458. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25459. * @returns true if there is an intersection
  25460. */
  25461. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25462. /**
  25463. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25464. * @param point defines the point to test
  25465. * @returns true if there is an intersection
  25466. */
  25467. intersectsPoint(point: Vector3): boolean;
  25468. /**
  25469. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25471. */
  25472. checkCollisions: boolean;
  25473. /**
  25474. * Gets Collider object used to compute collisions (not physics)
  25475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25476. */
  25477. readonly collider: Nullable<Collider>;
  25478. /**
  25479. * Move the mesh using collision engine
  25480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25481. * @param displacement defines the requested displacement vector
  25482. * @returns the current mesh
  25483. */
  25484. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25485. private _onCollisionPositionChange;
  25486. /** @hidden */
  25487. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25488. /** @hidden */
  25489. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25490. /** @hidden */
  25491. _checkCollision(collider: Collider): AbstractMesh;
  25492. /** @hidden */
  25493. _generatePointsArray(): boolean;
  25494. /**
  25495. * Checks if the passed Ray intersects with the mesh
  25496. * @param ray defines the ray to use
  25497. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25499. * @returns the picking info
  25500. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25501. */
  25502. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25503. /**
  25504. * Clones the current mesh
  25505. * @param name defines the mesh name
  25506. * @param newParent defines the new mesh parent
  25507. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25508. * @returns the new mesh
  25509. */
  25510. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25511. /**
  25512. * Disposes all the submeshes of the current meshnp
  25513. * @returns the current mesh
  25514. */
  25515. releaseSubMeshes(): AbstractMesh;
  25516. /**
  25517. * Releases resources associated with this abstract mesh.
  25518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25520. */
  25521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25522. /**
  25523. * Adds the passed mesh as a child to the current mesh
  25524. * @param mesh defines the child mesh
  25525. * @returns the current mesh
  25526. */
  25527. addChild(mesh: AbstractMesh): AbstractMesh;
  25528. /**
  25529. * Removes the passed mesh from the current mesh children list
  25530. * @param mesh defines the child mesh
  25531. * @returns the current mesh
  25532. */
  25533. removeChild(mesh: AbstractMesh): AbstractMesh;
  25534. /** @hidden */
  25535. private _initFacetData;
  25536. /**
  25537. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25538. * This method can be called within the render loop.
  25539. * 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
  25540. * @returns the current mesh
  25541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25542. */
  25543. updateFacetData(): AbstractMesh;
  25544. /**
  25545. * Returns the facetLocalNormals array.
  25546. * The normals are expressed in the mesh local spac
  25547. * @returns an array of Vector3
  25548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25549. */
  25550. getFacetLocalNormals(): Vector3[];
  25551. /**
  25552. * Returns the facetLocalPositions array.
  25553. * The facet positions are expressed in the mesh local space
  25554. * @returns an array of Vector3
  25555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25556. */
  25557. getFacetLocalPositions(): Vector3[];
  25558. /**
  25559. * Returns the facetLocalPartioning array
  25560. * @returns an array of array of numbers
  25561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25562. */
  25563. getFacetLocalPartitioning(): number[][];
  25564. /**
  25565. * Returns the i-th facet position in the world system.
  25566. * This method allocates a new Vector3 per call
  25567. * @param i defines the facet index
  25568. * @returns a new Vector3
  25569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25570. */
  25571. getFacetPosition(i: number): Vector3;
  25572. /**
  25573. * Sets the reference Vector3 with the i-th facet position in the world system
  25574. * @param i defines the facet index
  25575. * @param ref defines the target vector
  25576. * @returns the current mesh
  25577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25578. */
  25579. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25580. /**
  25581. * Returns the i-th facet normal in the world system.
  25582. * This method allocates a new Vector3 per call
  25583. * @param i defines the facet index
  25584. * @returns a new Vector3
  25585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25586. */
  25587. getFacetNormal(i: number): Vector3;
  25588. /**
  25589. * Sets the reference Vector3 with the i-th facet normal in the world system
  25590. * @param i defines the facet index
  25591. * @param ref defines the target vector
  25592. * @returns the current mesh
  25593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25594. */
  25595. getFacetNormalToRef(i: number, ref: Vector3): this;
  25596. /**
  25597. * 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)
  25598. * @param x defines x coordinate
  25599. * @param y defines y coordinate
  25600. * @param z defines z coordinate
  25601. * @returns the array of facet indexes
  25602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25603. */
  25604. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25605. /**
  25606. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25607. * @param projected sets as the (x,y,z) world projection on the facet
  25608. * @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
  25609. * @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
  25610. * @param x defines x coordinate
  25611. * @param y defines y coordinate
  25612. * @param z defines z coordinate
  25613. * @returns the face index if found (or null instead)
  25614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25615. */
  25616. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25617. /**
  25618. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25619. * @param projected sets as the (x,y,z) local projection on the facet
  25620. * @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
  25621. * @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
  25622. * @param x defines x coordinate
  25623. * @param y defines y coordinate
  25624. * @param z defines z coordinate
  25625. * @returns the face index if found (or null instead)
  25626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25627. */
  25628. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25629. /**
  25630. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25631. * @returns the parameters
  25632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25633. */
  25634. getFacetDataParameters(): any;
  25635. /**
  25636. * Disables the feature FacetData and frees the related memory
  25637. * @returns the current mesh
  25638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25639. */
  25640. disableFacetData(): AbstractMesh;
  25641. /**
  25642. * Updates the AbstractMesh indices array
  25643. * @param indices defines the data source
  25644. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25645. * @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)
  25646. * @returns the current mesh
  25647. */
  25648. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25649. /**
  25650. * Creates new normals data for the mesh
  25651. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25652. * @returns the current mesh
  25653. */
  25654. createNormals(updatable: boolean): AbstractMesh;
  25655. /**
  25656. * Align the mesh with a normal
  25657. * @param normal defines the normal to use
  25658. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25659. * @returns the current mesh
  25660. */
  25661. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25662. /** @hidden */
  25663. _checkOcclusionQuery(): boolean;
  25664. }
  25665. }
  25666. declare module "babylonjs/Actions/actionEvent" {
  25667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25668. import { Nullable } from "babylonjs/types";
  25669. import { Sprite } from "babylonjs/Sprites/sprite";
  25670. import { Scene } from "babylonjs/scene";
  25671. import { Vector2 } from "babylonjs/Maths/math";
  25672. /**
  25673. * Interface used to define ActionEvent
  25674. */
  25675. export interface IActionEvent {
  25676. /** The mesh or sprite that triggered the action */
  25677. source: any;
  25678. /** The X mouse cursor position at the time of the event */
  25679. pointerX: number;
  25680. /** The Y mouse cursor position at the time of the event */
  25681. pointerY: number;
  25682. /** The mesh that is currently pointed at (can be null) */
  25683. meshUnderPointer: Nullable<AbstractMesh>;
  25684. /** the original (browser) event that triggered the ActionEvent */
  25685. sourceEvent?: any;
  25686. /** additional data for the event */
  25687. additionalData?: any;
  25688. }
  25689. /**
  25690. * ActionEvent is the event being sent when an action is triggered.
  25691. */
  25692. export class ActionEvent implements IActionEvent {
  25693. /** The mesh or sprite that triggered the action */
  25694. source: any;
  25695. /** The X mouse cursor position at the time of the event */
  25696. pointerX: number;
  25697. /** The Y mouse cursor position at the time of the event */
  25698. pointerY: number;
  25699. /** The mesh that is currently pointed at (can be null) */
  25700. meshUnderPointer: Nullable<AbstractMesh>;
  25701. /** the original (browser) event that triggered the ActionEvent */
  25702. sourceEvent?: any;
  25703. /** additional data for the event */
  25704. additionalData?: any;
  25705. /**
  25706. * Creates a new ActionEvent
  25707. * @param source The mesh or sprite that triggered the action
  25708. * @param pointerX The X mouse cursor position at the time of the event
  25709. * @param pointerY The Y mouse cursor position at the time of the event
  25710. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25711. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25712. * @param additionalData additional data for the event
  25713. */
  25714. constructor(
  25715. /** The mesh or sprite that triggered the action */
  25716. source: any,
  25717. /** The X mouse cursor position at the time of the event */
  25718. pointerX: number,
  25719. /** The Y mouse cursor position at the time of the event */
  25720. pointerY: number,
  25721. /** The mesh that is currently pointed at (can be null) */
  25722. meshUnderPointer: Nullable<AbstractMesh>,
  25723. /** the original (browser) event that triggered the ActionEvent */
  25724. sourceEvent?: any,
  25725. /** additional data for the event */
  25726. additionalData?: any);
  25727. /**
  25728. * Helper function to auto-create an ActionEvent from a source mesh.
  25729. * @param source The source mesh that triggered the event
  25730. * @param evt The original (browser) event
  25731. * @param additionalData additional data for the event
  25732. * @returns the new ActionEvent
  25733. */
  25734. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25735. /**
  25736. * Helper function to auto-create an ActionEvent from a source sprite
  25737. * @param source The source sprite that triggered the event
  25738. * @param scene Scene associated with the sprite
  25739. * @param evt The original (browser) event
  25740. * @param additionalData additional data for the event
  25741. * @returns the new ActionEvent
  25742. */
  25743. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25744. /**
  25745. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25746. * @param scene the scene where the event occurred
  25747. * @param evt The original (browser) event
  25748. * @returns the new ActionEvent
  25749. */
  25750. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25751. /**
  25752. * Helper function to auto-create an ActionEvent from a primitive
  25753. * @param prim defines the target primitive
  25754. * @param pointerPos defines the pointer position
  25755. * @param evt The original (browser) event
  25756. * @param additionalData additional data for the event
  25757. * @returns the new ActionEvent
  25758. */
  25759. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25760. }
  25761. }
  25762. declare module "babylonjs/Actions/abstractActionManager" {
  25763. import { IDisposable } from "babylonjs/scene";
  25764. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25765. import { IAction } from "babylonjs/Actions/action";
  25766. import { Nullable } from "babylonjs/types";
  25767. /**
  25768. * Abstract class used to decouple action Manager from scene and meshes.
  25769. * Do not instantiate.
  25770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25771. */
  25772. export abstract class AbstractActionManager implements IDisposable {
  25773. /** Gets the list of active triggers */
  25774. static Triggers: {
  25775. [key: string]: number;
  25776. };
  25777. /** Gets the cursor to use when hovering items */
  25778. hoverCursor: string;
  25779. /** Gets the list of actions */
  25780. actions: IAction[];
  25781. /**
  25782. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25783. */
  25784. isRecursive: boolean;
  25785. /**
  25786. * Releases all associated resources
  25787. */
  25788. abstract dispose(): void;
  25789. /**
  25790. * Does this action manager has pointer triggers
  25791. */
  25792. abstract readonly hasPointerTriggers: boolean;
  25793. /**
  25794. * Does this action manager has pick triggers
  25795. */
  25796. abstract readonly hasPickTriggers: boolean;
  25797. /**
  25798. * Process a specific trigger
  25799. * @param trigger defines the trigger to process
  25800. * @param evt defines the event details to be processed
  25801. */
  25802. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25803. /**
  25804. * Does this action manager handles actions of any of the given triggers
  25805. * @param triggers defines the triggers to be tested
  25806. * @return a boolean indicating whether one (or more) of the triggers is handled
  25807. */
  25808. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25809. /**
  25810. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25811. * speed.
  25812. * @param triggerA defines the trigger to be tested
  25813. * @param triggerB defines the trigger to be tested
  25814. * @return a boolean indicating whether one (or more) of the triggers is handled
  25815. */
  25816. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25817. /**
  25818. * Does this action manager handles actions of a given trigger
  25819. * @param trigger defines the trigger to be tested
  25820. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25821. * @return whether the trigger is handled
  25822. */
  25823. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25824. /**
  25825. * Serialize this manager to a JSON object
  25826. * @param name defines the property name to store this manager
  25827. * @returns a JSON representation of this manager
  25828. */
  25829. abstract serialize(name: string): any;
  25830. /**
  25831. * Registers an action to this action manager
  25832. * @param action defines the action to be registered
  25833. * @return the action amended (prepared) after registration
  25834. */
  25835. abstract registerAction(action: IAction): Nullable<IAction>;
  25836. /**
  25837. * Unregisters an action to this action manager
  25838. * @param action defines the action to be unregistered
  25839. * @return a boolean indicating whether the action has been unregistered
  25840. */
  25841. abstract unregisterAction(action: IAction): Boolean;
  25842. /**
  25843. * Does exist one action manager with at least one trigger
  25844. **/
  25845. static readonly HasTriggers: boolean;
  25846. /**
  25847. * Does exist one action manager with at least one pick trigger
  25848. **/
  25849. static readonly HasPickTriggers: boolean;
  25850. /**
  25851. * Does exist one action manager that handles actions of a given trigger
  25852. * @param trigger defines the trigger to be tested
  25853. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25854. **/
  25855. static HasSpecificTrigger(trigger: number): boolean;
  25856. }
  25857. }
  25858. declare module "babylonjs/node" {
  25859. import { Scene } from "babylonjs/scene";
  25860. import { Nullable } from "babylonjs/types";
  25861. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25862. import { Engine } from "babylonjs/Engines/engine";
  25863. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25864. import { Observable } from "babylonjs/Misc/observable";
  25865. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25866. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25867. import { Animatable } from "babylonjs/Animations/animatable";
  25868. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25869. import { Animation } from "babylonjs/Animations/animation";
  25870. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25872. /**
  25873. * Defines how a node can be built from a string name.
  25874. */
  25875. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25876. /**
  25877. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25878. */
  25879. export class Node implements IBehaviorAware<Node> {
  25880. /** @hidden */
  25881. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25882. private static _NodeConstructors;
  25883. /**
  25884. * Add a new node constructor
  25885. * @param type defines the type name of the node to construct
  25886. * @param constructorFunc defines the constructor function
  25887. */
  25888. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25889. /**
  25890. * Returns a node constructor based on type name
  25891. * @param type defines the type name
  25892. * @param name defines the new node name
  25893. * @param scene defines the hosting scene
  25894. * @param options defines optional options to transmit to constructors
  25895. * @returns the new constructor or null
  25896. */
  25897. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25898. /**
  25899. * Gets or sets the name of the node
  25900. */
  25901. name: string;
  25902. /**
  25903. * Gets or sets the id of the node
  25904. */
  25905. id: string;
  25906. /**
  25907. * Gets or sets the unique id of the node
  25908. */
  25909. uniqueId: number;
  25910. /**
  25911. * Gets or sets a string used to store user defined state for the node
  25912. */
  25913. state: string;
  25914. /**
  25915. * Gets or sets an object used to store user defined information for the node
  25916. */
  25917. metadata: any;
  25918. /**
  25919. * For internal use only. Please do not use.
  25920. */
  25921. reservedDataStore: any;
  25922. /**
  25923. * List of inspectable custom properties (used by the Inspector)
  25924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25925. */
  25926. inspectableCustomProperties: IInspectable[];
  25927. /**
  25928. * Gets or sets a boolean used to define if the node must be serialized
  25929. */
  25930. doNotSerialize: boolean;
  25931. /** @hidden */
  25932. _isDisposed: boolean;
  25933. /**
  25934. * Gets a list of Animations associated with the node
  25935. */
  25936. animations: import("babylonjs/Animations/animation").Animation[];
  25937. protected _ranges: {
  25938. [name: string]: Nullable<AnimationRange>;
  25939. };
  25940. /**
  25941. * Callback raised when the node is ready to be used
  25942. */
  25943. onReady: Nullable<(node: Node) => void>;
  25944. private _isEnabled;
  25945. private _isParentEnabled;
  25946. private _isReady;
  25947. /** @hidden */
  25948. _currentRenderId: number;
  25949. private _parentUpdateId;
  25950. /** @hidden */
  25951. _childUpdateId: number;
  25952. /** @hidden */
  25953. _waitingParentId: Nullable<string>;
  25954. /** @hidden */
  25955. _scene: Scene;
  25956. /** @hidden */
  25957. _cache: any;
  25958. private _parentNode;
  25959. private _children;
  25960. /** @hidden */
  25961. _worldMatrix: Matrix;
  25962. /** @hidden */
  25963. _worldMatrixDeterminant: number;
  25964. /** @hidden */
  25965. _worldMatrixDeterminantIsDirty: boolean;
  25966. /** @hidden */
  25967. private _sceneRootNodesIndex;
  25968. /**
  25969. * Gets a boolean indicating if the node has been disposed
  25970. * @returns true if the node was disposed
  25971. */
  25972. isDisposed(): boolean;
  25973. /**
  25974. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25975. * @see https://doc.babylonjs.com/how_to/parenting
  25976. */
  25977. parent: Nullable<Node>;
  25978. private addToSceneRootNodes;
  25979. private removeFromSceneRootNodes;
  25980. private _animationPropertiesOverride;
  25981. /**
  25982. * Gets or sets the animation properties override
  25983. */
  25984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25985. /**
  25986. * Gets a string idenfifying the name of the class
  25987. * @returns "Node" string
  25988. */
  25989. getClassName(): string;
  25990. /** @hidden */
  25991. readonly _isNode: boolean;
  25992. /**
  25993. * An event triggered when the mesh is disposed
  25994. */
  25995. onDisposeObservable: Observable<Node>;
  25996. private _onDisposeObserver;
  25997. /**
  25998. * Sets a callback that will be raised when the node will be disposed
  25999. */
  26000. onDispose: () => void;
  26001. /**
  26002. * Creates a new Node
  26003. * @param name the name and id to be given to this node
  26004. * @param scene the scene this node will be added to
  26005. * @param addToRootNodes the node will be added to scene.rootNodes
  26006. */
  26007. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26008. /**
  26009. * Gets the scene of the node
  26010. * @returns a scene
  26011. */
  26012. getScene(): Scene;
  26013. /**
  26014. * Gets the engine of the node
  26015. * @returns a Engine
  26016. */
  26017. getEngine(): Engine;
  26018. private _behaviors;
  26019. /**
  26020. * Attach a behavior to the node
  26021. * @see http://doc.babylonjs.com/features/behaviour
  26022. * @param behavior defines the behavior to attach
  26023. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26024. * @returns the current Node
  26025. */
  26026. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26027. /**
  26028. * Remove an attached behavior
  26029. * @see http://doc.babylonjs.com/features/behaviour
  26030. * @param behavior defines the behavior to attach
  26031. * @returns the current Node
  26032. */
  26033. removeBehavior(behavior: Behavior<Node>): Node;
  26034. /**
  26035. * Gets the list of attached behaviors
  26036. * @see http://doc.babylonjs.com/features/behaviour
  26037. */
  26038. readonly behaviors: Behavior<Node>[];
  26039. /**
  26040. * Gets an attached behavior by name
  26041. * @param name defines the name of the behavior to look for
  26042. * @see http://doc.babylonjs.com/features/behaviour
  26043. * @returns null if behavior was not found else the requested behavior
  26044. */
  26045. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26046. /**
  26047. * Returns the latest update of the World matrix
  26048. * @returns a Matrix
  26049. */
  26050. getWorldMatrix(): Matrix;
  26051. /** @hidden */
  26052. _getWorldMatrixDeterminant(): number;
  26053. /**
  26054. * Returns directly the latest state of the mesh World matrix.
  26055. * A Matrix is returned.
  26056. */
  26057. readonly worldMatrixFromCache: Matrix;
  26058. /** @hidden */
  26059. _initCache(): void;
  26060. /** @hidden */
  26061. updateCache(force?: boolean): void;
  26062. /** @hidden */
  26063. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26064. /** @hidden */
  26065. _updateCache(ignoreParentClass?: boolean): void;
  26066. /** @hidden */
  26067. _isSynchronized(): boolean;
  26068. /** @hidden */
  26069. _markSyncedWithParent(): void;
  26070. /** @hidden */
  26071. isSynchronizedWithParent(): boolean;
  26072. /** @hidden */
  26073. isSynchronized(): boolean;
  26074. /**
  26075. * Is this node ready to be used/rendered
  26076. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26077. * @return true if the node is ready
  26078. */
  26079. isReady(completeCheck?: boolean): boolean;
  26080. /**
  26081. * Is this node enabled?
  26082. * 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
  26083. * @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
  26084. * @return whether this node (and its parent) is enabled
  26085. */
  26086. isEnabled(checkAncestors?: boolean): boolean;
  26087. /** @hidden */
  26088. protected _syncParentEnabledState(): void;
  26089. /**
  26090. * Set the enabled state of this node
  26091. * @param value defines the new enabled state
  26092. */
  26093. setEnabled(value: boolean): void;
  26094. /**
  26095. * Is this node a descendant of the given node?
  26096. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26097. * @param ancestor defines the parent node to inspect
  26098. * @returns a boolean indicating if this node is a descendant of the given node
  26099. */
  26100. isDescendantOf(ancestor: Node): boolean;
  26101. /** @hidden */
  26102. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26103. /**
  26104. * Will return all nodes that have this node as ascendant
  26105. * @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
  26106. * @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
  26107. * @return all children nodes of all types
  26108. */
  26109. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26110. /**
  26111. * Get all child-meshes of this node
  26112. * @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)
  26113. * @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
  26114. * @returns an array of AbstractMesh
  26115. */
  26116. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26117. /**
  26118. * Get all direct children of this node
  26119. * @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
  26120. * @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)
  26121. * @returns an array of Node
  26122. */
  26123. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26124. /** @hidden */
  26125. _setReady(state: boolean): void;
  26126. /**
  26127. * Get an animation by name
  26128. * @param name defines the name of the animation to look for
  26129. * @returns null if not found else the requested animation
  26130. */
  26131. getAnimationByName(name: string): Nullable<Animation>;
  26132. /**
  26133. * Creates an animation range for this node
  26134. * @param name defines the name of the range
  26135. * @param from defines the starting key
  26136. * @param to defines the end key
  26137. */
  26138. createAnimationRange(name: string, from: number, to: number): void;
  26139. /**
  26140. * Delete a specific animation range
  26141. * @param name defines the name of the range to delete
  26142. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26143. */
  26144. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26145. /**
  26146. * Get an animation range by name
  26147. * @param name defines the name of the animation range to look for
  26148. * @returns null if not found else the requested animation range
  26149. */
  26150. getAnimationRange(name: string): Nullable<AnimationRange>;
  26151. /**
  26152. * Gets the list of all animation ranges defined on this node
  26153. * @returns an array
  26154. */
  26155. getAnimationRanges(): Nullable<AnimationRange>[];
  26156. /**
  26157. * Will start the animation sequence
  26158. * @param name defines the range frames for animation sequence
  26159. * @param loop defines if the animation should loop (false by default)
  26160. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26161. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26162. * @returns the object created for this animation. If range does not exist, it will return null
  26163. */
  26164. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26165. /**
  26166. * Serialize animation ranges into a JSON compatible object
  26167. * @returns serialization object
  26168. */
  26169. serializeAnimationRanges(): any;
  26170. /**
  26171. * Computes the world matrix of the node
  26172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26173. * @returns the world matrix
  26174. */
  26175. computeWorldMatrix(force?: boolean): Matrix;
  26176. /**
  26177. * Releases resources associated with this node.
  26178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26180. */
  26181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26182. /**
  26183. * Parse animation range data from a serialization object and store them into a given node
  26184. * @param node defines where to store the animation ranges
  26185. * @param parsedNode defines the serialization object to read data from
  26186. * @param scene defines the hosting scene
  26187. */
  26188. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26189. /**
  26190. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26191. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26192. * @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
  26193. * @returns the new bounding vectors
  26194. */
  26195. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26196. min: Vector3;
  26197. max: Vector3;
  26198. };
  26199. }
  26200. }
  26201. declare module "babylonjs/Animations/animation" {
  26202. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26203. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26204. import { Nullable } from "babylonjs/types";
  26205. import { Scene } from "babylonjs/scene";
  26206. import { IAnimatable } from "babylonjs/Misc/tools";
  26207. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26208. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26209. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26210. import { Node } from "babylonjs/node";
  26211. import { Animatable } from "babylonjs/Animations/animatable";
  26212. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26213. /**
  26214. * @hidden
  26215. */
  26216. export class _IAnimationState {
  26217. key: number;
  26218. repeatCount: number;
  26219. workValue?: any;
  26220. loopMode?: number;
  26221. offsetValue?: any;
  26222. highLimitValue?: any;
  26223. }
  26224. /**
  26225. * Class used to store any kind of animation
  26226. */
  26227. export class Animation {
  26228. /**Name of the animation */
  26229. name: string;
  26230. /**Property to animate */
  26231. targetProperty: string;
  26232. /**The frames per second of the animation */
  26233. framePerSecond: number;
  26234. /**The data type of the animation */
  26235. dataType: number;
  26236. /**The loop mode of the animation */
  26237. loopMode?: number | undefined;
  26238. /**Specifies if blending should be enabled */
  26239. enableBlending?: boolean | undefined;
  26240. /**
  26241. * Use matrix interpolation instead of using direct key value when animating matrices
  26242. */
  26243. static AllowMatricesInterpolation: boolean;
  26244. /**
  26245. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26246. */
  26247. static AllowMatrixDecomposeForInterpolation: boolean;
  26248. /**
  26249. * Stores the key frames of the animation
  26250. */
  26251. private _keys;
  26252. /**
  26253. * Stores the easing function of the animation
  26254. */
  26255. private _easingFunction;
  26256. /**
  26257. * @hidden Internal use only
  26258. */
  26259. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26260. /**
  26261. * The set of event that will be linked to this animation
  26262. */
  26263. private _events;
  26264. /**
  26265. * Stores an array of target property paths
  26266. */
  26267. targetPropertyPath: string[];
  26268. /**
  26269. * Stores the blending speed of the animation
  26270. */
  26271. blendingSpeed: number;
  26272. /**
  26273. * Stores the animation ranges for the animation
  26274. */
  26275. private _ranges;
  26276. /**
  26277. * @hidden Internal use
  26278. */
  26279. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26280. /**
  26281. * Sets up an animation
  26282. * @param property The property to animate
  26283. * @param animationType The animation type to apply
  26284. * @param framePerSecond The frames per second of the animation
  26285. * @param easingFunction The easing function used in the animation
  26286. * @returns The created animation
  26287. */
  26288. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26289. /**
  26290. * Create and start an animation on a node
  26291. * @param name defines the name of the global animation that will be run on all nodes
  26292. * @param node defines the root node where the animation will take place
  26293. * @param targetProperty defines property to animate
  26294. * @param framePerSecond defines the number of frame per second yo use
  26295. * @param totalFrame defines the number of frames in total
  26296. * @param from defines the initial value
  26297. * @param to defines the final value
  26298. * @param loopMode defines which loop mode you want to use (off by default)
  26299. * @param easingFunction defines the easing function to use (linear by default)
  26300. * @param onAnimationEnd defines the callback to call when animation end
  26301. * @returns the animatable created for this animation
  26302. */
  26303. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26304. /**
  26305. * Create and start an animation on a node and its descendants
  26306. * @param name defines the name of the global animation that will be run on all nodes
  26307. * @param node defines the root node where the animation will take place
  26308. * @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
  26309. * @param targetProperty defines property to animate
  26310. * @param framePerSecond defines the number of frame per second to use
  26311. * @param totalFrame defines the number of frames in total
  26312. * @param from defines the initial value
  26313. * @param to defines the final value
  26314. * @param loopMode defines which loop mode you want to use (off by default)
  26315. * @param easingFunction defines the easing function to use (linear by default)
  26316. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26317. * @returns the list of animatables created for all nodes
  26318. * @example https://www.babylonjs-playground.com/#MH0VLI
  26319. */
  26320. 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[]>;
  26321. /**
  26322. * Creates a new animation, merges it with the existing animations and starts it
  26323. * @param name Name of the animation
  26324. * @param node Node which contains the scene that begins the animations
  26325. * @param targetProperty Specifies which property to animate
  26326. * @param framePerSecond The frames per second of the animation
  26327. * @param totalFrame The total number of frames
  26328. * @param from The frame at the beginning of the animation
  26329. * @param to The frame at the end of the animation
  26330. * @param loopMode Specifies the loop mode of the animation
  26331. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26332. * @param onAnimationEnd Callback to run once the animation is complete
  26333. * @returns Nullable animation
  26334. */
  26335. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26336. /**
  26337. * Transition property of an host to the target Value
  26338. * @param property The property to transition
  26339. * @param targetValue The target Value of the property
  26340. * @param host The object where the property to animate belongs
  26341. * @param scene Scene used to run the animation
  26342. * @param frameRate Framerate (in frame/s) to use
  26343. * @param transition The transition type we want to use
  26344. * @param duration The duration of the animation, in milliseconds
  26345. * @param onAnimationEnd Callback trigger at the end of the animation
  26346. * @returns Nullable animation
  26347. */
  26348. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26349. /**
  26350. * Return the array of runtime animations currently using this animation
  26351. */
  26352. readonly runtimeAnimations: RuntimeAnimation[];
  26353. /**
  26354. * Specifies if any of the runtime animations are currently running
  26355. */
  26356. readonly hasRunningRuntimeAnimations: boolean;
  26357. /**
  26358. * Initializes the animation
  26359. * @param name Name of the animation
  26360. * @param targetProperty Property to animate
  26361. * @param framePerSecond The frames per second of the animation
  26362. * @param dataType The data type of the animation
  26363. * @param loopMode The loop mode of the animation
  26364. * @param enableBlending Specifies if blending should be enabled
  26365. */
  26366. constructor(
  26367. /**Name of the animation */
  26368. name: string,
  26369. /**Property to animate */
  26370. targetProperty: string,
  26371. /**The frames per second of the animation */
  26372. framePerSecond: number,
  26373. /**The data type of the animation */
  26374. dataType: number,
  26375. /**The loop mode of the animation */
  26376. loopMode?: number | undefined,
  26377. /**Specifies if blending should be enabled */
  26378. enableBlending?: boolean | undefined);
  26379. /**
  26380. * Converts the animation to a string
  26381. * @param fullDetails support for multiple levels of logging within scene loading
  26382. * @returns String form of the animation
  26383. */
  26384. toString(fullDetails?: boolean): string;
  26385. /**
  26386. * Add an event to this animation
  26387. * @param event Event to add
  26388. */
  26389. addEvent(event: AnimationEvent): void;
  26390. /**
  26391. * Remove all events found at the given frame
  26392. * @param frame The frame to remove events from
  26393. */
  26394. removeEvents(frame: number): void;
  26395. /**
  26396. * Retrieves all the events from the animation
  26397. * @returns Events from the animation
  26398. */
  26399. getEvents(): AnimationEvent[];
  26400. /**
  26401. * Creates an animation range
  26402. * @param name Name of the animation range
  26403. * @param from Starting frame of the animation range
  26404. * @param to Ending frame of the animation
  26405. */
  26406. createRange(name: string, from: number, to: number): void;
  26407. /**
  26408. * Deletes an animation range by name
  26409. * @param name Name of the animation range to delete
  26410. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26411. */
  26412. deleteRange(name: string, deleteFrames?: boolean): void;
  26413. /**
  26414. * Gets the animation range by name, or null if not defined
  26415. * @param name Name of the animation range
  26416. * @returns Nullable animation range
  26417. */
  26418. getRange(name: string): Nullable<AnimationRange>;
  26419. /**
  26420. * Gets the key frames from the animation
  26421. * @returns The key frames of the animation
  26422. */
  26423. getKeys(): Array<IAnimationKey>;
  26424. /**
  26425. * Gets the highest frame rate of the animation
  26426. * @returns Highest frame rate of the animation
  26427. */
  26428. getHighestFrame(): number;
  26429. /**
  26430. * Gets the easing function of the animation
  26431. * @returns Easing function of the animation
  26432. */
  26433. getEasingFunction(): IEasingFunction;
  26434. /**
  26435. * Sets the easing function of the animation
  26436. * @param easingFunction A custom mathematical formula for animation
  26437. */
  26438. setEasingFunction(easingFunction: EasingFunction): void;
  26439. /**
  26440. * Interpolates a scalar linearly
  26441. * @param startValue Start value of the animation curve
  26442. * @param endValue End value of the animation curve
  26443. * @param gradient Scalar amount to interpolate
  26444. * @returns Interpolated scalar value
  26445. */
  26446. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26447. /**
  26448. * Interpolates a scalar cubically
  26449. * @param startValue Start value of the animation curve
  26450. * @param outTangent End tangent of the animation
  26451. * @param endValue End value of the animation curve
  26452. * @param inTangent Start tangent of the animation curve
  26453. * @param gradient Scalar amount to interpolate
  26454. * @returns Interpolated scalar value
  26455. */
  26456. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26457. /**
  26458. * Interpolates a quaternion using a spherical linear interpolation
  26459. * @param startValue Start value of the animation curve
  26460. * @param endValue End value of the animation curve
  26461. * @param gradient Scalar amount to interpolate
  26462. * @returns Interpolated quaternion value
  26463. */
  26464. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26465. /**
  26466. * Interpolates a quaternion cubically
  26467. * @param startValue Start value of the animation curve
  26468. * @param outTangent End tangent of the animation curve
  26469. * @param endValue End value of the animation curve
  26470. * @param inTangent Start tangent of the animation curve
  26471. * @param gradient Scalar amount to interpolate
  26472. * @returns Interpolated quaternion value
  26473. */
  26474. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26475. /**
  26476. * Interpolates a Vector3 linearl
  26477. * @param startValue Start value of the animation curve
  26478. * @param endValue End value of the animation curve
  26479. * @param gradient Scalar amount to interpolate
  26480. * @returns Interpolated scalar value
  26481. */
  26482. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26483. /**
  26484. * Interpolates a Vector3 cubically
  26485. * @param startValue Start value of the animation curve
  26486. * @param outTangent End tangent of the animation
  26487. * @param endValue End value of the animation curve
  26488. * @param inTangent Start tangent of the animation curve
  26489. * @param gradient Scalar amount to interpolate
  26490. * @returns InterpolatedVector3 value
  26491. */
  26492. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26493. /**
  26494. * Interpolates a Vector2 linearly
  26495. * @param startValue Start value of the animation curve
  26496. * @param endValue End value of the animation curve
  26497. * @param gradient Scalar amount to interpolate
  26498. * @returns Interpolated Vector2 value
  26499. */
  26500. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26501. /**
  26502. * Interpolates a Vector2 cubically
  26503. * @param startValue Start value of the animation curve
  26504. * @param outTangent End tangent of the animation
  26505. * @param endValue End value of the animation curve
  26506. * @param inTangent Start tangent of the animation curve
  26507. * @param gradient Scalar amount to interpolate
  26508. * @returns Interpolated Vector2 value
  26509. */
  26510. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26511. /**
  26512. * Interpolates a size linearly
  26513. * @param startValue Start value of the animation curve
  26514. * @param endValue End value of the animation curve
  26515. * @param gradient Scalar amount to interpolate
  26516. * @returns Interpolated Size value
  26517. */
  26518. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26519. /**
  26520. * Interpolates a Color3 linearly
  26521. * @param startValue Start value of the animation curve
  26522. * @param endValue End value of the animation curve
  26523. * @param gradient Scalar amount to interpolate
  26524. * @returns Interpolated Color3 value
  26525. */
  26526. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26527. /**
  26528. * @hidden Internal use only
  26529. */
  26530. _getKeyValue(value: any): any;
  26531. /**
  26532. * @hidden Internal use only
  26533. */
  26534. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26535. /**
  26536. * Defines the function to use to interpolate matrices
  26537. * @param startValue defines the start matrix
  26538. * @param endValue defines the end matrix
  26539. * @param gradient defines the gradient between both matrices
  26540. * @param result defines an optional target matrix where to store the interpolation
  26541. * @returns the interpolated matrix
  26542. */
  26543. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26544. /**
  26545. * Makes a copy of the animation
  26546. * @returns Cloned animation
  26547. */
  26548. clone(): Animation;
  26549. /**
  26550. * Sets the key frames of the animation
  26551. * @param values The animation key frames to set
  26552. */
  26553. setKeys(values: Array<IAnimationKey>): void;
  26554. /**
  26555. * Serializes the animation to an object
  26556. * @returns Serialized object
  26557. */
  26558. serialize(): any;
  26559. /**
  26560. * Float animation type
  26561. */
  26562. private static _ANIMATIONTYPE_FLOAT;
  26563. /**
  26564. * Vector3 animation type
  26565. */
  26566. private static _ANIMATIONTYPE_VECTOR3;
  26567. /**
  26568. * Quaternion animation type
  26569. */
  26570. private static _ANIMATIONTYPE_QUATERNION;
  26571. /**
  26572. * Matrix animation type
  26573. */
  26574. private static _ANIMATIONTYPE_MATRIX;
  26575. /**
  26576. * Color3 animation type
  26577. */
  26578. private static _ANIMATIONTYPE_COLOR3;
  26579. /**
  26580. * Vector2 animation type
  26581. */
  26582. private static _ANIMATIONTYPE_VECTOR2;
  26583. /**
  26584. * Size animation type
  26585. */
  26586. private static _ANIMATIONTYPE_SIZE;
  26587. /**
  26588. * Relative Loop Mode
  26589. */
  26590. private static _ANIMATIONLOOPMODE_RELATIVE;
  26591. /**
  26592. * Cycle Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_CYCLE;
  26595. /**
  26596. * Constant Loop Mode
  26597. */
  26598. private static _ANIMATIONLOOPMODE_CONSTANT;
  26599. /**
  26600. * Get the float animation type
  26601. */
  26602. static readonly ANIMATIONTYPE_FLOAT: number;
  26603. /**
  26604. * Get the Vector3 animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_VECTOR3: number;
  26607. /**
  26608. * Get the Vector2 animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_VECTOR2: number;
  26611. /**
  26612. * Get the Size animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_SIZE: number;
  26615. /**
  26616. * Get the Quaternion animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_QUATERNION: number;
  26619. /**
  26620. * Get the Matrix animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_MATRIX: number;
  26623. /**
  26624. * Get the Color3 animation type
  26625. */
  26626. static readonly ANIMATIONTYPE_COLOR3: number;
  26627. /**
  26628. * Get the Relative Loop Mode
  26629. */
  26630. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26631. /**
  26632. * Get the Cycle Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26635. /**
  26636. * Get the Constant Loop Mode
  26637. */
  26638. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26639. /** @hidden */
  26640. static _UniversalLerp(left: any, right: any, amount: number): any;
  26641. /**
  26642. * Parses an animation object and creates an animation
  26643. * @param parsedAnimation Parsed animation object
  26644. * @returns Animation object
  26645. */
  26646. static Parse(parsedAnimation: any): Animation;
  26647. /**
  26648. * Appends the serialized animations from the source animations
  26649. * @param source Source containing the animations
  26650. * @param destination Target to store the animations
  26651. */
  26652. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26653. }
  26654. }
  26655. declare module "babylonjs/Materials/Textures/baseTexture" {
  26656. import { Observable } from "babylonjs/Misc/observable";
  26657. import { IAnimatable } from "babylonjs/Misc/tools";
  26658. import { Nullable } from "babylonjs/types";
  26659. import { Scene } from "babylonjs/scene";
  26660. import { Matrix, ISize } from "babylonjs/Maths/math";
  26661. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26663. /**
  26664. * Base class of all the textures in babylon.
  26665. * It groups all the common properties the materials, post process, lights... might need
  26666. * in order to make a correct use of the texture.
  26667. */
  26668. export class BaseTexture implements IAnimatable {
  26669. /**
  26670. * Default anisotropic filtering level for the application.
  26671. * It is set to 4 as a good tradeoff between perf and quality.
  26672. */
  26673. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26674. /**
  26675. * Gets or sets the unique id of the texture
  26676. */
  26677. uniqueId: number;
  26678. /**
  26679. * Define the name of the texture.
  26680. */
  26681. name: string;
  26682. /**
  26683. * Gets or sets an object used to store user defined information.
  26684. */
  26685. metadata: any;
  26686. /**
  26687. * For internal use only. Please do not use.
  26688. */
  26689. reservedDataStore: any;
  26690. private _hasAlpha;
  26691. /**
  26692. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26693. */
  26694. hasAlpha: boolean;
  26695. /**
  26696. * Defines if the alpha value should be determined via the rgb values.
  26697. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26698. */
  26699. getAlphaFromRGB: boolean;
  26700. /**
  26701. * Intensity or strength of the texture.
  26702. * It is commonly used by materials to fine tune the intensity of the texture
  26703. */
  26704. level: number;
  26705. /**
  26706. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26707. * This is part of the texture as textures usually maps to one uv set.
  26708. */
  26709. coordinatesIndex: number;
  26710. private _coordinatesMode;
  26711. /**
  26712. * How a texture is mapped.
  26713. *
  26714. * | Value | Type | Description |
  26715. * | ----- | ----------------------------------- | ----------- |
  26716. * | 0 | EXPLICIT_MODE | |
  26717. * | 1 | SPHERICAL_MODE | |
  26718. * | 2 | PLANAR_MODE | |
  26719. * | 3 | CUBIC_MODE | |
  26720. * | 4 | PROJECTION_MODE | |
  26721. * | 5 | SKYBOX_MODE | |
  26722. * | 6 | INVCUBIC_MODE | |
  26723. * | 7 | EQUIRECTANGULAR_MODE | |
  26724. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26725. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26726. */
  26727. coordinatesMode: number;
  26728. /**
  26729. * | Value | Type | Description |
  26730. * | ----- | ------------------ | ----------- |
  26731. * | 0 | CLAMP_ADDRESSMODE | |
  26732. * | 1 | WRAP_ADDRESSMODE | |
  26733. * | 2 | MIRROR_ADDRESSMODE | |
  26734. */
  26735. wrapU: number;
  26736. /**
  26737. * | Value | Type | Description |
  26738. * | ----- | ------------------ | ----------- |
  26739. * | 0 | CLAMP_ADDRESSMODE | |
  26740. * | 1 | WRAP_ADDRESSMODE | |
  26741. * | 2 | MIRROR_ADDRESSMODE | |
  26742. */
  26743. wrapV: number;
  26744. /**
  26745. * | Value | Type | Description |
  26746. * | ----- | ------------------ | ----------- |
  26747. * | 0 | CLAMP_ADDRESSMODE | |
  26748. * | 1 | WRAP_ADDRESSMODE | |
  26749. * | 2 | MIRROR_ADDRESSMODE | |
  26750. */
  26751. wrapR: number;
  26752. /**
  26753. * With compliant hardware and browser (supporting anisotropic filtering)
  26754. * this defines the level of anisotropic filtering in the texture.
  26755. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26756. */
  26757. anisotropicFilteringLevel: number;
  26758. /**
  26759. * Define if the texture is a cube texture or if false a 2d texture.
  26760. */
  26761. isCube: boolean;
  26762. /**
  26763. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26764. */
  26765. is3D: boolean;
  26766. /**
  26767. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26768. * HDR texture are usually stored in linear space.
  26769. * This only impacts the PBR and Background materials
  26770. */
  26771. gammaSpace: boolean;
  26772. /**
  26773. * Gets whether or not the texture contains RGBD data.
  26774. */
  26775. readonly isRGBD: boolean;
  26776. /**
  26777. * Is Z inverted in the texture (useful in a cube texture).
  26778. */
  26779. invertZ: boolean;
  26780. /**
  26781. * Are mip maps generated for this texture or not.
  26782. */
  26783. readonly noMipmap: boolean;
  26784. /**
  26785. * @hidden
  26786. */
  26787. lodLevelInAlpha: boolean;
  26788. /**
  26789. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26790. */
  26791. lodGenerationOffset: number;
  26792. /**
  26793. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26794. */
  26795. lodGenerationScale: number;
  26796. /**
  26797. * Define if the texture is a render target.
  26798. */
  26799. isRenderTarget: boolean;
  26800. /**
  26801. * Define the unique id of the texture in the scene.
  26802. */
  26803. readonly uid: string;
  26804. /**
  26805. * Return a string representation of the texture.
  26806. * @returns the texture as a string
  26807. */
  26808. toString(): string;
  26809. /**
  26810. * Get the class name of the texture.
  26811. * @returns "BaseTexture"
  26812. */
  26813. getClassName(): string;
  26814. /**
  26815. * Define the list of animation attached to the texture.
  26816. */
  26817. animations: import("babylonjs/Animations/animation").Animation[];
  26818. /**
  26819. * An event triggered when the texture is disposed.
  26820. */
  26821. onDisposeObservable: Observable<BaseTexture>;
  26822. private _onDisposeObserver;
  26823. /**
  26824. * Callback triggered when the texture has been disposed.
  26825. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26826. */
  26827. onDispose: () => void;
  26828. /**
  26829. * Define the current state of the loading sequence when in delayed load mode.
  26830. */
  26831. delayLoadState: number;
  26832. private _scene;
  26833. /** @hidden */
  26834. _texture: Nullable<InternalTexture>;
  26835. private _uid;
  26836. /**
  26837. * Define if the texture is preventinga material to render or not.
  26838. * If not and the texture is not ready, the engine will use a default black texture instead.
  26839. */
  26840. readonly isBlocking: boolean;
  26841. /**
  26842. * Instantiates a new BaseTexture.
  26843. * Base class of all the textures in babylon.
  26844. * It groups all the common properties the materials, post process, lights... might need
  26845. * in order to make a correct use of the texture.
  26846. * @param scene Define the scene the texture blongs to
  26847. */
  26848. constructor(scene: Nullable<Scene>);
  26849. /**
  26850. * Get the scene the texture belongs to.
  26851. * @returns the scene or null if undefined
  26852. */
  26853. getScene(): Nullable<Scene>;
  26854. /**
  26855. * Get the texture transform matrix used to offset tile the texture for istance.
  26856. * @returns the transformation matrix
  26857. */
  26858. getTextureMatrix(): Matrix;
  26859. /**
  26860. * Get the texture reflection matrix used to rotate/transform the reflection.
  26861. * @returns the reflection matrix
  26862. */
  26863. getReflectionTextureMatrix(): Matrix;
  26864. /**
  26865. * Get the underlying lower level texture from Babylon.
  26866. * @returns the insternal texture
  26867. */
  26868. getInternalTexture(): Nullable<InternalTexture>;
  26869. /**
  26870. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26871. * @returns true if ready or not blocking
  26872. */
  26873. isReadyOrNotBlocking(): boolean;
  26874. /**
  26875. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26876. * @returns true if fully ready
  26877. */
  26878. isReady(): boolean;
  26879. private _cachedSize;
  26880. /**
  26881. * Get the size of the texture.
  26882. * @returns the texture size.
  26883. */
  26884. getSize(): ISize;
  26885. /**
  26886. * Get the base size of the texture.
  26887. * It can be different from the size if the texture has been resized for POT for instance
  26888. * @returns the base size
  26889. */
  26890. getBaseSize(): ISize;
  26891. /**
  26892. * Update the sampling mode of the texture.
  26893. * Default is Trilinear mode.
  26894. *
  26895. * | Value | Type | Description |
  26896. * | ----- | ------------------ | ----------- |
  26897. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26898. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26899. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26900. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26901. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26902. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26903. * | 7 | NEAREST_LINEAR | |
  26904. * | 8 | NEAREST_NEAREST | |
  26905. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26906. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26907. * | 11 | LINEAR_LINEAR | |
  26908. * | 12 | LINEAR_NEAREST | |
  26909. *
  26910. * > _mag_: magnification filter (close to the viewer)
  26911. * > _min_: minification filter (far from the viewer)
  26912. * > _mip_: filter used between mip map levels
  26913. *@param samplingMode Define the new sampling mode of the texture
  26914. */
  26915. updateSamplingMode(samplingMode: number): void;
  26916. /**
  26917. * Scales the texture if is `canRescale()`
  26918. * @param ratio the resize factor we want to use to rescale
  26919. */
  26920. scale(ratio: number): void;
  26921. /**
  26922. * Get if the texture can rescale.
  26923. */
  26924. readonly canRescale: boolean;
  26925. /** @hidden */
  26926. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26927. /** @hidden */
  26928. _rebuild(): void;
  26929. /**
  26930. * Triggers the load sequence in delayed load mode.
  26931. */
  26932. delayLoad(): void;
  26933. /**
  26934. * Clones the texture.
  26935. * @returns the cloned texture
  26936. */
  26937. clone(): Nullable<BaseTexture>;
  26938. /**
  26939. * Get the texture underlying type (INT, FLOAT...)
  26940. */
  26941. readonly textureType: number;
  26942. /**
  26943. * Get the texture underlying format (RGB, RGBA...)
  26944. */
  26945. readonly textureFormat: number;
  26946. /**
  26947. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26948. * This will returns an RGBA array buffer containing either in values (0-255) or
  26949. * float values (0-1) depending of the underlying buffer type.
  26950. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26951. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26952. * @param buffer defines a user defined buffer to fill with data (can be null)
  26953. * @returns The Array buffer containing the pixels data.
  26954. */
  26955. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26956. /**
  26957. * Release and destroy the underlying lower level texture aka internalTexture.
  26958. */
  26959. releaseInternalTexture(): void;
  26960. /**
  26961. * Get the polynomial representation of the texture data.
  26962. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26963. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26964. */
  26965. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26966. /** @hidden */
  26967. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26968. /** @hidden */
  26969. readonly _lodTextureMid: Nullable<BaseTexture>;
  26970. /** @hidden */
  26971. readonly _lodTextureLow: Nullable<BaseTexture>;
  26972. /**
  26973. * Dispose the texture and release its associated resources.
  26974. */
  26975. dispose(): void;
  26976. /**
  26977. * Serialize the texture into a JSON representation that can be parsed later on.
  26978. * @returns the JSON representation of the texture
  26979. */
  26980. serialize(): any;
  26981. /**
  26982. * Helper function to be called back once a list of texture contains only ready textures.
  26983. * @param textures Define the list of textures to wait for
  26984. * @param callback Define the callback triggered once the entire list will be ready
  26985. */
  26986. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26987. }
  26988. }
  26989. declare module "babylonjs/Materials/uniformBuffer" {
  26990. import { Nullable, FloatArray } from "babylonjs/types";
  26991. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26992. import { Engine } from "babylonjs/Engines/engine";
  26993. import { Effect } from "babylonjs/Materials/effect";
  26994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26995. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26996. /**
  26997. * Uniform buffer objects.
  26998. *
  26999. * Handles blocks of uniform on the GPU.
  27000. *
  27001. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27002. *
  27003. * For more information, please refer to :
  27004. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27005. */
  27006. export class UniformBuffer {
  27007. private _engine;
  27008. private _buffer;
  27009. private _data;
  27010. private _bufferData;
  27011. private _dynamic?;
  27012. private _uniformLocations;
  27013. private _uniformSizes;
  27014. private _uniformLocationPointer;
  27015. private _needSync;
  27016. private _noUBO;
  27017. private _currentEffect;
  27018. private static _MAX_UNIFORM_SIZE;
  27019. private static _tempBuffer;
  27020. /**
  27021. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27022. * This is dynamic to allow compat with webgl 1 and 2.
  27023. * You will need to pass the name of the uniform as well as the value.
  27024. */
  27025. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27026. /**
  27027. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27028. * This is dynamic to allow compat with webgl 1 and 2.
  27029. * You will need to pass the name of the uniform as well as the value.
  27030. */
  27031. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27032. /**
  27033. * Lambda to Update a single float in a uniform buffer.
  27034. * This is dynamic to allow compat with webgl 1 and 2.
  27035. * You will need to pass the name of the uniform as well as the value.
  27036. */
  27037. updateFloat: (name: string, x: number) => void;
  27038. /**
  27039. * Lambda to Update a vec2 of float in a uniform buffer.
  27040. * This is dynamic to allow compat with webgl 1 and 2.
  27041. * You will need to pass the name of the uniform as well as the value.
  27042. */
  27043. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27044. /**
  27045. * Lambda to Update a vec3 of float in a uniform buffer.
  27046. * This is dynamic to allow compat with webgl 1 and 2.
  27047. * You will need to pass the name of the uniform as well as the value.
  27048. */
  27049. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27050. /**
  27051. * Lambda to Update a vec4 of float in a uniform buffer.
  27052. * This is dynamic to allow compat with webgl 1 and 2.
  27053. * You will need to pass the name of the uniform as well as the value.
  27054. */
  27055. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27056. /**
  27057. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27058. * This is dynamic to allow compat with webgl 1 and 2.
  27059. * You will need to pass the name of the uniform as well as the value.
  27060. */
  27061. updateMatrix: (name: string, mat: Matrix) => void;
  27062. /**
  27063. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27064. * This is dynamic to allow compat with webgl 1 and 2.
  27065. * You will need to pass the name of the uniform as well as the value.
  27066. */
  27067. updateVector3: (name: string, vector: Vector3) => void;
  27068. /**
  27069. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27070. * This is dynamic to allow compat with webgl 1 and 2.
  27071. * You will need to pass the name of the uniform as well as the value.
  27072. */
  27073. updateVector4: (name: string, vector: Vector4) => void;
  27074. /**
  27075. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27076. * This is dynamic to allow compat with webgl 1 and 2.
  27077. * You will need to pass the name of the uniform as well as the value.
  27078. */
  27079. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27080. /**
  27081. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27082. * This is dynamic to allow compat with webgl 1 and 2.
  27083. * You will need to pass the name of the uniform as well as the value.
  27084. */
  27085. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27086. /**
  27087. * Instantiates a new Uniform buffer objects.
  27088. *
  27089. * Handles blocks of uniform on the GPU.
  27090. *
  27091. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27092. *
  27093. * For more information, please refer to :
  27094. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27095. * @param engine Define the engine the buffer is associated with
  27096. * @param data Define the data contained in the buffer
  27097. * @param dynamic Define if the buffer is updatable
  27098. */
  27099. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27100. /**
  27101. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27102. * or just falling back on setUniformXXX calls.
  27103. */
  27104. readonly useUbo: boolean;
  27105. /**
  27106. * Indicates if the WebGL underlying uniform buffer is in sync
  27107. * with the javascript cache data.
  27108. */
  27109. readonly isSync: boolean;
  27110. /**
  27111. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27112. * Also, a dynamic UniformBuffer will disable cache verification and always
  27113. * update the underlying WebGL uniform buffer to the GPU.
  27114. * @returns if Dynamic, otherwise false
  27115. */
  27116. isDynamic(): boolean;
  27117. /**
  27118. * The data cache on JS side.
  27119. * @returns the underlying data as a float array
  27120. */
  27121. getData(): Float32Array;
  27122. /**
  27123. * The underlying WebGL Uniform buffer.
  27124. * @returns the webgl buffer
  27125. */
  27126. getBuffer(): Nullable<DataBuffer>;
  27127. /**
  27128. * std140 layout specifies how to align data within an UBO structure.
  27129. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27130. * for specs.
  27131. */
  27132. private _fillAlignment;
  27133. /**
  27134. * Adds an uniform in the buffer.
  27135. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27136. * for the layout to be correct !
  27137. * @param name Name of the uniform, as used in the uniform block in the shader.
  27138. * @param size Data size, or data directly.
  27139. */
  27140. addUniform(name: string, size: number | number[]): void;
  27141. /**
  27142. * Adds a Matrix 4x4 to the uniform buffer.
  27143. * @param name Name of the uniform, as used in the uniform block in the shader.
  27144. * @param mat A 4x4 matrix.
  27145. */
  27146. addMatrix(name: string, mat: Matrix): void;
  27147. /**
  27148. * Adds a vec2 to the uniform buffer.
  27149. * @param name Name of the uniform, as used in the uniform block in the shader.
  27150. * @param x Define the x component value of the vec2
  27151. * @param y Define the y component value of the vec2
  27152. */
  27153. addFloat2(name: string, x: number, y: number): void;
  27154. /**
  27155. * Adds a vec3 to the uniform buffer.
  27156. * @param name Name of the uniform, as used in the uniform block in the shader.
  27157. * @param x Define the x component value of the vec3
  27158. * @param y Define the y component value of the vec3
  27159. * @param z Define the z component value of the vec3
  27160. */
  27161. addFloat3(name: string, x: number, y: number, z: number): void;
  27162. /**
  27163. * Adds a vec3 to the uniform buffer.
  27164. * @param name Name of the uniform, as used in the uniform block in the shader.
  27165. * @param color Define the vec3 from a Color
  27166. */
  27167. addColor3(name: string, color: Color3): void;
  27168. /**
  27169. * Adds a vec4 to the uniform buffer.
  27170. * @param name Name of the uniform, as used in the uniform block in the shader.
  27171. * @param color Define the rgb components from a Color
  27172. * @param alpha Define the a component of the vec4
  27173. */
  27174. addColor4(name: string, color: Color3, alpha: number): void;
  27175. /**
  27176. * Adds a vec3 to the uniform buffer.
  27177. * @param name Name of the uniform, as used in the uniform block in the shader.
  27178. * @param vector Define the vec3 components from a Vector
  27179. */
  27180. addVector3(name: string, vector: Vector3): void;
  27181. /**
  27182. * Adds a Matrix 3x3 to the uniform buffer.
  27183. * @param name Name of the uniform, as used in the uniform block in the shader.
  27184. */
  27185. addMatrix3x3(name: string): void;
  27186. /**
  27187. * Adds a Matrix 2x2 to the uniform buffer.
  27188. * @param name Name of the uniform, as used in the uniform block in the shader.
  27189. */
  27190. addMatrix2x2(name: string): void;
  27191. /**
  27192. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27193. */
  27194. create(): void;
  27195. /** @hidden */
  27196. _rebuild(): void;
  27197. /**
  27198. * Updates the WebGL Uniform Buffer on the GPU.
  27199. * If the `dynamic` flag is set to true, no cache comparison is done.
  27200. * Otherwise, the buffer will be updated only if the cache differs.
  27201. */
  27202. update(): void;
  27203. /**
  27204. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27205. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27206. * @param data Define the flattened data
  27207. * @param size Define the size of the data.
  27208. */
  27209. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27210. private _updateMatrix3x3ForUniform;
  27211. private _updateMatrix3x3ForEffect;
  27212. private _updateMatrix2x2ForEffect;
  27213. private _updateMatrix2x2ForUniform;
  27214. private _updateFloatForEffect;
  27215. private _updateFloatForUniform;
  27216. private _updateFloat2ForEffect;
  27217. private _updateFloat2ForUniform;
  27218. private _updateFloat3ForEffect;
  27219. private _updateFloat3ForUniform;
  27220. private _updateFloat4ForEffect;
  27221. private _updateFloat4ForUniform;
  27222. private _updateMatrixForEffect;
  27223. private _updateMatrixForUniform;
  27224. private _updateVector3ForEffect;
  27225. private _updateVector3ForUniform;
  27226. private _updateVector4ForEffect;
  27227. private _updateVector4ForUniform;
  27228. private _updateColor3ForEffect;
  27229. private _updateColor3ForUniform;
  27230. private _updateColor4ForEffect;
  27231. private _updateColor4ForUniform;
  27232. /**
  27233. * Sets a sampler uniform on the effect.
  27234. * @param name Define the name of the sampler.
  27235. * @param texture Define the texture to set in the sampler
  27236. */
  27237. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27238. /**
  27239. * Directly updates the value of the uniform in the cache AND on the GPU.
  27240. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27241. * @param data Define the flattened data
  27242. */
  27243. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27244. /**
  27245. * Binds this uniform buffer to an effect.
  27246. * @param effect Define the effect to bind the buffer to
  27247. * @param name Name of the uniform block in the shader.
  27248. */
  27249. bindToEffect(effect: Effect, name: string): void;
  27250. /**
  27251. * Disposes the uniform buffer.
  27252. */
  27253. dispose(): void;
  27254. }
  27255. }
  27256. declare module "babylonjs/Audio/analyser" {
  27257. import { Scene } from "babylonjs/scene";
  27258. /**
  27259. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27261. */
  27262. export class Analyser {
  27263. /**
  27264. * Gets or sets the smoothing
  27265. * @ignorenaming
  27266. */
  27267. SMOOTHING: number;
  27268. /**
  27269. * Gets or sets the FFT table size
  27270. * @ignorenaming
  27271. */
  27272. FFT_SIZE: number;
  27273. /**
  27274. * Gets or sets the bar graph amplitude
  27275. * @ignorenaming
  27276. */
  27277. BARGRAPHAMPLITUDE: number;
  27278. /**
  27279. * Gets or sets the position of the debug canvas
  27280. * @ignorenaming
  27281. */
  27282. DEBUGCANVASPOS: {
  27283. x: number;
  27284. y: number;
  27285. };
  27286. /**
  27287. * Gets or sets the debug canvas size
  27288. * @ignorenaming
  27289. */
  27290. DEBUGCANVASSIZE: {
  27291. width: number;
  27292. height: number;
  27293. };
  27294. private _byteFreqs;
  27295. private _byteTime;
  27296. private _floatFreqs;
  27297. private _webAudioAnalyser;
  27298. private _debugCanvas;
  27299. private _debugCanvasContext;
  27300. private _scene;
  27301. private _registerFunc;
  27302. private _audioEngine;
  27303. /**
  27304. * Creates a new analyser
  27305. * @param scene defines hosting scene
  27306. */
  27307. constructor(scene: Scene);
  27308. /**
  27309. * Get the number of data values you will have to play with for the visualization
  27310. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27311. * @returns a number
  27312. */
  27313. getFrequencyBinCount(): number;
  27314. /**
  27315. * Gets the current frequency data as a byte array
  27316. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27317. * @returns a Uint8Array
  27318. */
  27319. getByteFrequencyData(): Uint8Array;
  27320. /**
  27321. * Gets the current waveform as a byte array
  27322. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27323. * @returns a Uint8Array
  27324. */
  27325. getByteTimeDomainData(): Uint8Array;
  27326. /**
  27327. * Gets the current frequency data as a float array
  27328. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27329. * @returns a Float32Array
  27330. */
  27331. getFloatFrequencyData(): Float32Array;
  27332. /**
  27333. * Renders the debug canvas
  27334. */
  27335. drawDebugCanvas(): void;
  27336. /**
  27337. * Stops rendering the debug canvas and removes it
  27338. */
  27339. stopDebugCanvas(): void;
  27340. /**
  27341. * Connects two audio nodes
  27342. * @param inputAudioNode defines first node to connect
  27343. * @param outputAudioNode defines second node to connect
  27344. */
  27345. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27346. /**
  27347. * Releases all associated resources
  27348. */
  27349. dispose(): void;
  27350. }
  27351. }
  27352. declare module "babylonjs/Audio/audioEngine" {
  27353. import { IDisposable } from "babylonjs/scene";
  27354. import { Analyser } from "babylonjs/Audio/analyser";
  27355. import { Nullable } from "babylonjs/types";
  27356. import { Observable } from "babylonjs/Misc/observable";
  27357. /**
  27358. * This represents an audio engine and it is responsible
  27359. * to play, synchronize and analyse sounds throughout the application.
  27360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27361. */
  27362. export interface IAudioEngine extends IDisposable {
  27363. /**
  27364. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27365. */
  27366. readonly canUseWebAudio: boolean;
  27367. /**
  27368. * Gets the current AudioContext if available.
  27369. */
  27370. readonly audioContext: Nullable<AudioContext>;
  27371. /**
  27372. * The master gain node defines the global audio volume of your audio engine.
  27373. */
  27374. readonly masterGain: GainNode;
  27375. /**
  27376. * Gets whether or not mp3 are supported by your browser.
  27377. */
  27378. readonly isMP3supported: boolean;
  27379. /**
  27380. * Gets whether or not ogg are supported by your browser.
  27381. */
  27382. readonly isOGGsupported: boolean;
  27383. /**
  27384. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27385. * @ignoreNaming
  27386. */
  27387. WarnedWebAudioUnsupported: boolean;
  27388. /**
  27389. * Defines if the audio engine relies on a custom unlocked button.
  27390. * In this case, the embedded button will not be displayed.
  27391. */
  27392. useCustomUnlockedButton: boolean;
  27393. /**
  27394. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27395. */
  27396. readonly unlocked: boolean;
  27397. /**
  27398. * Event raised when audio has been unlocked on the browser.
  27399. */
  27400. onAudioUnlockedObservable: Observable<AudioEngine>;
  27401. /**
  27402. * Event raised when audio has been locked on the browser.
  27403. */
  27404. onAudioLockedObservable: Observable<AudioEngine>;
  27405. /**
  27406. * Flags the audio engine in Locked state.
  27407. * This happens due to new browser policies preventing audio to autoplay.
  27408. */
  27409. lock(): void;
  27410. /**
  27411. * Unlocks the audio engine once a user action has been done on the dom.
  27412. * This is helpful to resume play once browser policies have been satisfied.
  27413. */
  27414. unlock(): void;
  27415. }
  27416. /**
  27417. * This represents the default audio engine used in babylon.
  27418. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27420. */
  27421. export class AudioEngine implements IAudioEngine {
  27422. private _audioContext;
  27423. private _audioContextInitialized;
  27424. private _muteButton;
  27425. private _hostElement;
  27426. /**
  27427. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27428. */
  27429. canUseWebAudio: boolean;
  27430. /**
  27431. * The master gain node defines the global audio volume of your audio engine.
  27432. */
  27433. masterGain: GainNode;
  27434. /**
  27435. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27436. * @ignoreNaming
  27437. */
  27438. WarnedWebAudioUnsupported: boolean;
  27439. /**
  27440. * Gets whether or not mp3 are supported by your browser.
  27441. */
  27442. isMP3supported: boolean;
  27443. /**
  27444. * Gets whether or not ogg are supported by your browser.
  27445. */
  27446. isOGGsupported: boolean;
  27447. /**
  27448. * Gets whether audio has been unlocked on the device.
  27449. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27450. * a user interaction has happened.
  27451. */
  27452. unlocked: boolean;
  27453. /**
  27454. * Defines if the audio engine relies on a custom unlocked button.
  27455. * In this case, the embedded button will not be displayed.
  27456. */
  27457. useCustomUnlockedButton: boolean;
  27458. /**
  27459. * Event raised when audio has been unlocked on the browser.
  27460. */
  27461. onAudioUnlockedObservable: Observable<AudioEngine>;
  27462. /**
  27463. * Event raised when audio has been locked on the browser.
  27464. */
  27465. onAudioLockedObservable: Observable<AudioEngine>;
  27466. /**
  27467. * Gets the current AudioContext if available.
  27468. */
  27469. readonly audioContext: Nullable<AudioContext>;
  27470. private _connectedAnalyser;
  27471. /**
  27472. * Instantiates a new audio engine.
  27473. *
  27474. * There should be only one per page as some browsers restrict the number
  27475. * of audio contexts you can create.
  27476. * @param hostElement defines the host element where to display the mute icon if necessary
  27477. */
  27478. constructor(hostElement?: Nullable<HTMLElement>);
  27479. /**
  27480. * Flags the audio engine in Locked state.
  27481. * This happens due to new browser policies preventing audio to autoplay.
  27482. */
  27483. lock(): void;
  27484. /**
  27485. * Unlocks the audio engine once a user action has been done on the dom.
  27486. * This is helpful to resume play once browser policies have been satisfied.
  27487. */
  27488. unlock(): void;
  27489. private _resumeAudioContext;
  27490. private _initializeAudioContext;
  27491. private _tryToRun;
  27492. private _triggerRunningState;
  27493. private _triggerSuspendedState;
  27494. private _displayMuteButton;
  27495. private _moveButtonToTopLeft;
  27496. private _onResize;
  27497. private _hideMuteButton;
  27498. /**
  27499. * Destroy and release the resources associated with the audio ccontext.
  27500. */
  27501. dispose(): void;
  27502. /**
  27503. * Gets the global volume sets on the master gain.
  27504. * @returns the global volume if set or -1 otherwise
  27505. */
  27506. getGlobalVolume(): number;
  27507. /**
  27508. * Sets the global volume of your experience (sets on the master gain).
  27509. * @param newVolume Defines the new global volume of the application
  27510. */
  27511. setGlobalVolume(newVolume: number): void;
  27512. /**
  27513. * Connect the audio engine to an audio analyser allowing some amazing
  27514. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27516. * @param analyser The analyser to connect to the engine
  27517. */
  27518. connectToAnalyser(analyser: Analyser): void;
  27519. }
  27520. }
  27521. declare module "babylonjs/Loading/loadingScreen" {
  27522. /**
  27523. * Interface used to present a loading screen while loading a scene
  27524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27525. */
  27526. export interface ILoadingScreen {
  27527. /**
  27528. * Function called to display the loading screen
  27529. */
  27530. displayLoadingUI: () => void;
  27531. /**
  27532. * Function called to hide the loading screen
  27533. */
  27534. hideLoadingUI: () => void;
  27535. /**
  27536. * Gets or sets the color to use for the background
  27537. */
  27538. loadingUIBackgroundColor: string;
  27539. /**
  27540. * Gets or sets the text to display while loading
  27541. */
  27542. loadingUIText: string;
  27543. }
  27544. /**
  27545. * Class used for the default loading screen
  27546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27547. */
  27548. export class DefaultLoadingScreen implements ILoadingScreen {
  27549. private _renderingCanvas;
  27550. private _loadingText;
  27551. private _loadingDivBackgroundColor;
  27552. private _loadingDiv;
  27553. private _loadingTextDiv;
  27554. /**
  27555. * Creates a new default loading screen
  27556. * @param _renderingCanvas defines the canvas used to render the scene
  27557. * @param _loadingText defines the default text to display
  27558. * @param _loadingDivBackgroundColor defines the default background color
  27559. */
  27560. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27561. /**
  27562. * Function called to display the loading screen
  27563. */
  27564. displayLoadingUI(): void;
  27565. /**
  27566. * Function called to hide the loading screen
  27567. */
  27568. hideLoadingUI(): void;
  27569. /**
  27570. * Gets or sets the text to display while loading
  27571. */
  27572. loadingUIText: string;
  27573. /**
  27574. * Gets or sets the color to use for the background
  27575. */
  27576. loadingUIBackgroundColor: string;
  27577. private _resizeLoadingUI;
  27578. }
  27579. }
  27580. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27581. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27582. import { Engine } from "babylonjs/Engines/engine";
  27583. import { Nullable } from "babylonjs/types";
  27584. /** @hidden */
  27585. export class WebGLPipelineContext implements IPipelineContext {
  27586. engine: Engine;
  27587. program: Nullable<WebGLProgram>;
  27588. context?: WebGLRenderingContext;
  27589. vertexShader?: WebGLShader;
  27590. fragmentShader?: WebGLShader;
  27591. isParallelCompiled: boolean;
  27592. onCompiled?: () => void;
  27593. transformFeedback?: WebGLTransformFeedback | null;
  27594. readonly isAsync: boolean;
  27595. readonly isReady: boolean;
  27596. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27597. }
  27598. }
  27599. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27600. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27601. /** @hidden */
  27602. export class WebGLDataBuffer extends DataBuffer {
  27603. private _buffer;
  27604. constructor(resource: WebGLBuffer);
  27605. readonly underlyingResource: any;
  27606. }
  27607. }
  27608. declare module "babylonjs/Materials/Textures/videoTexture" {
  27609. import { Observable } from "babylonjs/Misc/observable";
  27610. import { Nullable } from "babylonjs/types";
  27611. import { Scene } from "babylonjs/scene";
  27612. import { Texture } from "babylonjs/Materials/Textures/texture";
  27613. /**
  27614. * Settings for finer control over video usage
  27615. */
  27616. export interface VideoTextureSettings {
  27617. /**
  27618. * Applies `autoplay` to video, if specified
  27619. */
  27620. autoPlay?: boolean;
  27621. /**
  27622. * Applies `loop` to video, if specified
  27623. */
  27624. loop?: boolean;
  27625. /**
  27626. * Automatically updates internal texture from video at every frame in the render loop
  27627. */
  27628. autoUpdateTexture: boolean;
  27629. /**
  27630. * Image src displayed during the video loading or until the user interacts with the video.
  27631. */
  27632. poster?: string;
  27633. }
  27634. /**
  27635. * If you want to display a video in your scene, this is the special texture for that.
  27636. * This special texture works similar to other textures, with the exception of a few parameters.
  27637. * @see https://doc.babylonjs.com/how_to/video_texture
  27638. */
  27639. export class VideoTexture extends Texture {
  27640. /**
  27641. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27642. */
  27643. readonly autoUpdateTexture: boolean;
  27644. /**
  27645. * The video instance used by the texture internally
  27646. */
  27647. readonly video: HTMLVideoElement;
  27648. private _onUserActionRequestedObservable;
  27649. /**
  27650. * Event triggerd when a dom action is required by the user to play the video.
  27651. * This happens due to recent changes in browser policies preventing video to auto start.
  27652. */
  27653. readonly onUserActionRequestedObservable: Observable<Texture>;
  27654. private _generateMipMaps;
  27655. private _engine;
  27656. private _stillImageCaptured;
  27657. private _displayingPosterTexture;
  27658. private _settings;
  27659. private _createInternalTextureOnEvent;
  27660. /**
  27661. * Creates a video texture.
  27662. * If you want to display a video in your scene, this is the special texture for that.
  27663. * This special texture works similar to other textures, with the exception of a few parameters.
  27664. * @see https://doc.babylonjs.com/how_to/video_texture
  27665. * @param name optional name, will detect from video source, if not defined
  27666. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27667. * @param scene is obviously the current scene.
  27668. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27669. * @param invertY is false by default but can be used to invert video on Y axis
  27670. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27671. * @param settings allows finer control over video usage
  27672. */
  27673. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27674. private _getName;
  27675. private _getVideo;
  27676. private _createInternalTexture;
  27677. private reset;
  27678. /**
  27679. * @hidden Internal method to initiate `update`.
  27680. */
  27681. _rebuild(): void;
  27682. /**
  27683. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27684. */
  27685. update(): void;
  27686. /**
  27687. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27688. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27689. */
  27690. updateTexture(isVisible: boolean): void;
  27691. protected _updateInternalTexture: () => void;
  27692. /**
  27693. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27694. * @param url New url.
  27695. */
  27696. updateURL(url: string): void;
  27697. /**
  27698. * Dispose the texture and release its associated resources.
  27699. */
  27700. dispose(): void;
  27701. /**
  27702. * Creates a video texture straight from a stream.
  27703. * @param scene Define the scene the texture should be created in
  27704. * @param stream Define the stream the texture should be created from
  27705. * @returns The created video texture as a promise
  27706. */
  27707. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27708. /**
  27709. * Creates a video texture straight from your WebCam video feed.
  27710. * @param scene Define the scene the texture should be created in
  27711. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27712. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27713. * @returns The created video texture as a promise
  27714. */
  27715. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27716. minWidth: number;
  27717. maxWidth: number;
  27718. minHeight: number;
  27719. maxHeight: number;
  27720. deviceId: string;
  27721. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27722. /**
  27723. * Creates a video texture straight from your WebCam video feed.
  27724. * @param scene Define the scene the texture should be created in
  27725. * @param onReady Define a callback to triggered once the texture will be ready
  27726. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27727. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27728. */
  27729. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27730. minWidth: number;
  27731. maxWidth: number;
  27732. minHeight: number;
  27733. maxHeight: number;
  27734. deviceId: string;
  27735. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27736. }
  27737. }
  27738. declare module "babylonjs/Engines/engine" {
  27739. import { Observable } from "babylonjs/Misc/observable";
  27740. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27741. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27742. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27743. import { Camera } from "babylonjs/Cameras/camera";
  27744. import { Scene } from "babylonjs/scene";
  27745. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27746. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27747. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27748. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27749. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27750. import { Material } from "babylonjs/Materials/material";
  27751. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27754. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27756. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27757. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27758. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27759. import { WebRequest } from "babylonjs/Misc/webRequest";
  27760. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27761. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27762. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27764. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27765. /**
  27766. * Interface for attribute information associated with buffer instanciation
  27767. */
  27768. export class InstancingAttributeInfo {
  27769. /**
  27770. * Index/offset of the attribute in the vertex shader
  27771. */
  27772. index: number;
  27773. /**
  27774. * size of the attribute, 1, 2, 3 or 4
  27775. */
  27776. attributeSize: number;
  27777. /**
  27778. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27779. * default is FLOAT
  27780. */
  27781. attribyteType: number;
  27782. /**
  27783. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27784. */
  27785. normalized: boolean;
  27786. /**
  27787. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27788. */
  27789. offset: number;
  27790. /**
  27791. * Name of the GLSL attribute, for debugging purpose only
  27792. */
  27793. attributeName: string;
  27794. }
  27795. /**
  27796. * Define options used to create a depth texture
  27797. */
  27798. export class DepthTextureCreationOptions {
  27799. /** Specifies whether or not a stencil should be allocated in the texture */
  27800. generateStencil?: boolean;
  27801. /** Specifies whether or not bilinear filtering is enable on the texture */
  27802. bilinearFiltering?: boolean;
  27803. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27804. comparisonFunction?: number;
  27805. /** Specifies if the created texture is a cube texture */
  27806. isCube?: boolean;
  27807. }
  27808. /**
  27809. * Class used to describe the capabilities of the engine relatively to the current browser
  27810. */
  27811. export class EngineCapabilities {
  27812. /** Maximum textures units per fragment shader */
  27813. maxTexturesImageUnits: number;
  27814. /** Maximum texture units per vertex shader */
  27815. maxVertexTextureImageUnits: number;
  27816. /** Maximum textures units in the entire pipeline */
  27817. maxCombinedTexturesImageUnits: number;
  27818. /** Maximum texture size */
  27819. maxTextureSize: number;
  27820. /** Maximum cube texture size */
  27821. maxCubemapTextureSize: number;
  27822. /** Maximum render texture size */
  27823. maxRenderTextureSize: number;
  27824. /** Maximum number of vertex attributes */
  27825. maxVertexAttribs: number;
  27826. /** Maximum number of varyings */
  27827. maxVaryingVectors: number;
  27828. /** Maximum number of uniforms per vertex shader */
  27829. maxVertexUniformVectors: number;
  27830. /** Maximum number of uniforms per fragment shader */
  27831. maxFragmentUniformVectors: number;
  27832. /** Defines if standard derivates (dx/dy) are supported */
  27833. standardDerivatives: boolean;
  27834. /** Defines if s3tc texture compression is supported */
  27835. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27836. /** Defines if pvrtc texture compression is supported */
  27837. pvrtc: any;
  27838. /** Defines if etc1 texture compression is supported */
  27839. etc1: any;
  27840. /** Defines if etc2 texture compression is supported */
  27841. etc2: any;
  27842. /** Defines if astc texture compression is supported */
  27843. astc: any;
  27844. /** Defines if float textures are supported */
  27845. textureFloat: boolean;
  27846. /** Defines if vertex array objects are supported */
  27847. vertexArrayObject: boolean;
  27848. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27849. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27850. /** Gets the maximum level of anisotropy supported */
  27851. maxAnisotropy: number;
  27852. /** Defines if instancing is supported */
  27853. instancedArrays: boolean;
  27854. /** Defines if 32 bits indices are supported */
  27855. uintIndices: boolean;
  27856. /** Defines if high precision shaders are supported */
  27857. highPrecisionShaderSupported: boolean;
  27858. /** Defines if depth reading in the fragment shader is supported */
  27859. fragmentDepthSupported: boolean;
  27860. /** Defines if float texture linear filtering is supported*/
  27861. textureFloatLinearFiltering: boolean;
  27862. /** Defines if rendering to float textures is supported */
  27863. textureFloatRender: boolean;
  27864. /** Defines if half float textures are supported*/
  27865. textureHalfFloat: boolean;
  27866. /** Defines if half float texture linear filtering is supported*/
  27867. textureHalfFloatLinearFiltering: boolean;
  27868. /** Defines if rendering to half float textures is supported */
  27869. textureHalfFloatRender: boolean;
  27870. /** Defines if textureLOD shader command is supported */
  27871. textureLOD: boolean;
  27872. /** Defines if draw buffers extension is supported */
  27873. drawBuffersExtension: boolean;
  27874. /** Defines if depth textures are supported */
  27875. depthTextureExtension: boolean;
  27876. /** Defines if float color buffer are supported */
  27877. colorBufferFloat: boolean;
  27878. /** Gets disjoint timer query extension (null if not supported) */
  27879. timerQuery: EXT_disjoint_timer_query;
  27880. /** Defines if timestamp can be used with timer query */
  27881. canUseTimestampForTimerQuery: boolean;
  27882. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27883. multiview: any;
  27884. /** Function used to let the system compiles shaders in background */
  27885. parallelShaderCompile: {
  27886. COMPLETION_STATUS_KHR: number;
  27887. };
  27888. }
  27889. /** Interface defining initialization parameters for Engine class */
  27890. export interface EngineOptions extends WebGLContextAttributes {
  27891. /**
  27892. * Defines if the engine should no exceed a specified device ratio
  27893. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27894. */
  27895. limitDeviceRatio?: number;
  27896. /**
  27897. * Defines if webvr should be enabled automatically
  27898. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27899. */
  27900. autoEnableWebVR?: boolean;
  27901. /**
  27902. * Defines if webgl2 should be turned off even if supported
  27903. * @see http://doc.babylonjs.com/features/webgl2
  27904. */
  27905. disableWebGL2Support?: boolean;
  27906. /**
  27907. * Defines if webaudio should be initialized as well
  27908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27909. */
  27910. audioEngine?: boolean;
  27911. /**
  27912. * Defines if animations should run using a deterministic lock step
  27913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27914. */
  27915. deterministicLockstep?: boolean;
  27916. /** Defines the maximum steps to use with deterministic lock step mode */
  27917. lockstepMaxSteps?: number;
  27918. /**
  27919. * Defines that engine should ignore context lost events
  27920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27921. */
  27922. doNotHandleContextLost?: boolean;
  27923. /**
  27924. * Defines that engine should ignore modifying touch action attribute and style
  27925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27926. */
  27927. doNotHandleTouchAction?: boolean;
  27928. /**
  27929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27930. */
  27931. useHighPrecisionFloats?: boolean;
  27932. }
  27933. /**
  27934. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27935. */
  27936. export class Engine {
  27937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27938. static ExceptionList: ({
  27939. key: string;
  27940. capture: string;
  27941. captureConstraint: number;
  27942. targets: string[];
  27943. } | {
  27944. key: string;
  27945. capture: null;
  27946. captureConstraint: null;
  27947. targets: string[];
  27948. })[];
  27949. /** Gets the list of created engines */
  27950. static readonly Instances: Engine[];
  27951. /**
  27952. * Gets the latest created engine
  27953. */
  27954. static readonly LastCreatedEngine: Nullable<Engine>;
  27955. /**
  27956. * Gets the latest created scene
  27957. */
  27958. static readonly LastCreatedScene: Nullable<Scene>;
  27959. /**
  27960. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27961. * @param flag defines which part of the materials must be marked as dirty
  27962. * @param predicate defines a predicate used to filter which materials should be affected
  27963. */
  27964. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27965. /**
  27966. * Hidden
  27967. */
  27968. static _TextureLoaders: IInternalTextureLoader[];
  27969. /** Defines that alpha blending is disabled */
  27970. static readonly ALPHA_DISABLE: number;
  27971. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27972. static readonly ALPHA_ADD: number;
  27973. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27974. static readonly ALPHA_COMBINE: number;
  27975. /** Defines that alpha blending to DEST - SRC * DEST */
  27976. static readonly ALPHA_SUBTRACT: number;
  27977. /** Defines that alpha blending to SRC * DEST */
  27978. static readonly ALPHA_MULTIPLY: number;
  27979. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27980. static readonly ALPHA_MAXIMIZED: number;
  27981. /** Defines that alpha blending to SRC + DEST */
  27982. static readonly ALPHA_ONEONE: number;
  27983. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27984. static readonly ALPHA_PREMULTIPLIED: number;
  27985. /**
  27986. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27987. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27988. */
  27989. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27990. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27991. static readonly ALPHA_INTERPOLATE: number;
  27992. /**
  27993. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27994. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27995. */
  27996. static readonly ALPHA_SCREENMODE: number;
  27997. /** Defines that the ressource is not delayed*/
  27998. static readonly DELAYLOADSTATE_NONE: number;
  27999. /** Defines that the ressource was successfully delay loaded */
  28000. static readonly DELAYLOADSTATE_LOADED: number;
  28001. /** Defines that the ressource is currently delay loading */
  28002. static readonly DELAYLOADSTATE_LOADING: number;
  28003. /** Defines that the ressource is delayed and has not started loading */
  28004. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28006. static readonly NEVER: number;
  28007. /** 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 */
  28008. static readonly ALWAYS: number;
  28009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28010. static readonly LESS: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28012. static readonly EQUAL: number;
  28013. /** 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 */
  28014. static readonly LEQUAL: number;
  28015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28016. static readonly GREATER: number;
  28017. /** 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 */
  28018. static readonly GEQUAL: number;
  28019. /** 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 */
  28020. static readonly NOTEQUAL: number;
  28021. /** Passed to stencilOperation to specify that stencil value must be kept */
  28022. static readonly KEEP: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28024. static readonly REPLACE: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28026. static readonly INCR: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28028. static readonly DECR: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28030. static readonly INVERT: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28032. static readonly INCR_WRAP: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28034. static readonly DECR_WRAP: number;
  28035. /** Texture is not repeating outside of 0..1 UVs */
  28036. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28037. /** Texture is repeating outside of 0..1 UVs */
  28038. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28039. /** Texture is repeating and mirrored */
  28040. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28041. /** ALPHA */
  28042. static readonly TEXTUREFORMAT_ALPHA: number;
  28043. /** LUMINANCE */
  28044. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28045. /** LUMINANCE_ALPHA */
  28046. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28047. /** RGB */
  28048. static readonly TEXTUREFORMAT_RGB: number;
  28049. /** RGBA */
  28050. static readonly TEXTUREFORMAT_RGBA: number;
  28051. /** RED */
  28052. static readonly TEXTUREFORMAT_RED: number;
  28053. /** RED (2nd reference) */
  28054. static readonly TEXTUREFORMAT_R: number;
  28055. /** RG */
  28056. static readonly TEXTUREFORMAT_RG: number;
  28057. /** RED_INTEGER */
  28058. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28059. /** RED_INTEGER (2nd reference) */
  28060. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28061. /** RG_INTEGER */
  28062. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28063. /** RGB_INTEGER */
  28064. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28065. /** RGBA_INTEGER */
  28066. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28067. /** UNSIGNED_BYTE */
  28068. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28069. /** UNSIGNED_BYTE (2nd reference) */
  28070. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28071. /** FLOAT */
  28072. static readonly TEXTURETYPE_FLOAT: number;
  28073. /** HALF_FLOAT */
  28074. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28075. /** BYTE */
  28076. static readonly TEXTURETYPE_BYTE: number;
  28077. /** SHORT */
  28078. static readonly TEXTURETYPE_SHORT: number;
  28079. /** UNSIGNED_SHORT */
  28080. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28081. /** INT */
  28082. static readonly TEXTURETYPE_INT: number;
  28083. /** UNSIGNED_INT */
  28084. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28085. /** UNSIGNED_SHORT_4_4_4_4 */
  28086. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28087. /** UNSIGNED_SHORT_5_5_5_1 */
  28088. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28089. /** UNSIGNED_SHORT_5_6_5 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28091. /** UNSIGNED_INT_2_10_10_10_REV */
  28092. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28093. /** UNSIGNED_INT_24_8 */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28095. /** UNSIGNED_INT_10F_11F_11F_REV */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28097. /** UNSIGNED_INT_5_9_9_9_REV */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28099. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28100. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28101. /** nearest is mag = nearest and min = nearest and mip = linear */
  28102. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28104. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28105. /** Trilinear is mag = linear and min = linear and mip = linear */
  28106. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28107. /** nearest is mag = nearest and min = nearest and mip = linear */
  28108. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28109. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28110. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28111. /** Trilinear is mag = linear and min = linear and mip = linear */
  28112. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28113. /** mag = nearest and min = nearest and mip = nearest */
  28114. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28115. /** mag = nearest and min = linear and mip = nearest */
  28116. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28117. /** mag = nearest and min = linear and mip = linear */
  28118. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28119. /** mag = nearest and min = linear and mip = none */
  28120. static readonly TEXTURE_NEAREST_LINEAR: number;
  28121. /** mag = nearest and min = nearest and mip = none */
  28122. static readonly TEXTURE_NEAREST_NEAREST: number;
  28123. /** mag = linear and min = nearest and mip = nearest */
  28124. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28125. /** mag = linear and min = nearest and mip = linear */
  28126. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28127. /** mag = linear and min = linear and mip = none */
  28128. static readonly TEXTURE_LINEAR_LINEAR: number;
  28129. /** mag = linear and min = nearest and mip = none */
  28130. static readonly TEXTURE_LINEAR_NEAREST: number;
  28131. /** Explicit coordinates mode */
  28132. static readonly TEXTURE_EXPLICIT_MODE: number;
  28133. /** Spherical coordinates mode */
  28134. static readonly TEXTURE_SPHERICAL_MODE: number;
  28135. /** Planar coordinates mode */
  28136. static readonly TEXTURE_PLANAR_MODE: number;
  28137. /** Cubic coordinates mode */
  28138. static readonly TEXTURE_CUBIC_MODE: number;
  28139. /** Projection coordinates mode */
  28140. static readonly TEXTURE_PROJECTION_MODE: number;
  28141. /** Skybox coordinates mode */
  28142. static readonly TEXTURE_SKYBOX_MODE: number;
  28143. /** Inverse Cubic coordinates mode */
  28144. static readonly TEXTURE_INVCUBIC_MODE: number;
  28145. /** Equirectangular coordinates mode */
  28146. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28147. /** Equirectangular Fixed coordinates mode */
  28148. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28149. /** Equirectangular Fixed Mirrored coordinates mode */
  28150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28151. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28152. static readonly SCALEMODE_FLOOR: number;
  28153. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28154. static readonly SCALEMODE_NEAREST: number;
  28155. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28156. static readonly SCALEMODE_CEILING: number;
  28157. /**
  28158. * Returns the current npm package of the sdk
  28159. */
  28160. static readonly NpmPackage: string;
  28161. /**
  28162. * Returns the current version of the framework
  28163. */
  28164. static readonly Version: string;
  28165. /**
  28166. * Returns a string describing the current engine
  28167. */
  28168. readonly description: string;
  28169. /**
  28170. * Gets or sets the epsilon value used by collision engine
  28171. */
  28172. static CollisionsEpsilon: number;
  28173. /**
  28174. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28175. */
  28176. static ShadersRepository: string;
  28177. /**
  28178. * Method called to create the default loading screen.
  28179. * This can be overriden in your own app.
  28180. * @param canvas The rendering canvas element
  28181. * @returns The loading screen
  28182. */
  28183. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28184. /**
  28185. * Method called to create the default rescale post process on each engine.
  28186. */
  28187. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28188. /**
  28189. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28190. */
  28191. forcePOTTextures: boolean;
  28192. /**
  28193. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28194. */
  28195. isFullscreen: boolean;
  28196. /**
  28197. * Gets a boolean indicating if the pointer is currently locked
  28198. */
  28199. isPointerLock: boolean;
  28200. /**
  28201. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28202. */
  28203. cullBackFaces: boolean;
  28204. /**
  28205. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28206. */
  28207. renderEvenInBackground: boolean;
  28208. /**
  28209. * Gets or sets a boolean indicating that cache can be kept between frames
  28210. */
  28211. preventCacheWipeBetweenFrames: boolean;
  28212. /**
  28213. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28214. **/
  28215. enableOfflineSupport: boolean;
  28216. /**
  28217. * 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)
  28218. **/
  28219. disableManifestCheck: boolean;
  28220. /**
  28221. * Gets the list of created scenes
  28222. */
  28223. scenes: Scene[];
  28224. /**
  28225. * Event raised when a new scene is created
  28226. */
  28227. onNewSceneAddedObservable: Observable<Scene>;
  28228. /**
  28229. * Gets the list of created postprocesses
  28230. */
  28231. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28232. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28233. validateShaderPrograms: boolean;
  28234. /**
  28235. * Observable event triggered each time the rendering canvas is resized
  28236. */
  28237. onResizeObservable: Observable<Engine>;
  28238. /**
  28239. * Observable event triggered each time the canvas loses focus
  28240. */
  28241. onCanvasBlurObservable: Observable<Engine>;
  28242. /**
  28243. * Observable event triggered each time the canvas gains focus
  28244. */
  28245. onCanvasFocusObservable: Observable<Engine>;
  28246. /**
  28247. * Observable event triggered each time the canvas receives pointerout event
  28248. */
  28249. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28250. /**
  28251. * Observable event triggered before each texture is initialized
  28252. */
  28253. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28254. /**
  28255. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28256. */
  28257. disableUniformBuffers: boolean;
  28258. /** @hidden */
  28259. _uniformBuffers: UniformBuffer[];
  28260. /**
  28261. * Gets a boolean indicating that the engine supports uniform buffers
  28262. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28263. */
  28264. readonly supportsUniformBuffers: boolean;
  28265. /**
  28266. * Observable raised when the engine begins a new frame
  28267. */
  28268. onBeginFrameObservable: Observable<Engine>;
  28269. /**
  28270. * If set, will be used to request the next animation frame for the render loop
  28271. */
  28272. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28273. /**
  28274. * Observable raised when the engine ends the current frame
  28275. */
  28276. onEndFrameObservable: Observable<Engine>;
  28277. /**
  28278. * Observable raised when the engine is about to compile a shader
  28279. */
  28280. onBeforeShaderCompilationObservable: Observable<Engine>;
  28281. /**
  28282. * Observable raised when the engine has jsut compiled a shader
  28283. */
  28284. onAfterShaderCompilationObservable: Observable<Engine>;
  28285. /** @hidden */
  28286. _gl: WebGLRenderingContext;
  28287. private _renderingCanvas;
  28288. private _windowIsBackground;
  28289. private _webGLVersion;
  28290. protected _highPrecisionShadersAllowed: boolean;
  28291. /** @hidden */
  28292. readonly _shouldUseHighPrecisionShader: boolean;
  28293. /**
  28294. * Gets a boolean indicating that only power of 2 textures are supported
  28295. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28296. */
  28297. readonly needPOTTextures: boolean;
  28298. /** @hidden */
  28299. _badOS: boolean;
  28300. /** @hidden */
  28301. _badDesktopOS: boolean;
  28302. /**
  28303. * Gets the audio engine
  28304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28305. * @ignorenaming
  28306. */
  28307. static audioEngine: IAudioEngine;
  28308. /**
  28309. * Default AudioEngine factory responsible of creating the Audio Engine.
  28310. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28311. */
  28312. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28313. /**
  28314. * Default offline support factory responsible of creating a tool used to store data locally.
  28315. * By default, this will create a Database object if the workload has been embedded.
  28316. */
  28317. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28318. private _onFocus;
  28319. private _onBlur;
  28320. private _onCanvasPointerOut;
  28321. private _onCanvasBlur;
  28322. private _onCanvasFocus;
  28323. private _onFullscreenChange;
  28324. private _onPointerLockChange;
  28325. private _hardwareScalingLevel;
  28326. /** @hidden */
  28327. _caps: EngineCapabilities;
  28328. private _pointerLockRequested;
  28329. private _isStencilEnable;
  28330. private _colorWrite;
  28331. private _loadingScreen;
  28332. /** @hidden */
  28333. _drawCalls: PerfCounter;
  28334. private _glVersion;
  28335. private _glRenderer;
  28336. private _glVendor;
  28337. private _videoTextureSupported;
  28338. private _renderingQueueLaunched;
  28339. private _activeRenderLoops;
  28340. private _deterministicLockstep;
  28341. private _lockstepMaxSteps;
  28342. /**
  28343. * Observable signaled when a context lost event is raised
  28344. */
  28345. onContextLostObservable: Observable<Engine>;
  28346. /**
  28347. * Observable signaled when a context restored event is raised
  28348. */
  28349. onContextRestoredObservable: Observable<Engine>;
  28350. private _onContextLost;
  28351. private _onContextRestored;
  28352. private _contextWasLost;
  28353. /** @hidden */
  28354. _doNotHandleContextLost: boolean;
  28355. /**
  28356. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28358. */
  28359. doNotHandleContextLost: boolean;
  28360. private _performanceMonitor;
  28361. private _fps;
  28362. private _deltaTime;
  28363. /**
  28364. * Turn this value on if you want to pause FPS computation when in background
  28365. */
  28366. disablePerformanceMonitorInBackground: boolean;
  28367. /**
  28368. * Gets the performance monitor attached to this engine
  28369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28370. */
  28371. readonly performanceMonitor: PerformanceMonitor;
  28372. /**
  28373. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28374. */
  28375. disableVertexArrayObjects: boolean;
  28376. /** @hidden */
  28377. protected _depthCullingState: _DepthCullingState;
  28378. /** @hidden */
  28379. protected _stencilState: _StencilState;
  28380. /** @hidden */
  28381. protected _alphaState: _AlphaState;
  28382. /** @hidden */
  28383. protected _alphaMode: number;
  28384. /** @hidden */
  28385. _internalTexturesCache: InternalTexture[];
  28386. /** @hidden */
  28387. protected _activeChannel: number;
  28388. private _currentTextureChannel;
  28389. /** @hidden */
  28390. protected _boundTexturesCache: {
  28391. [key: string]: Nullable<InternalTexture>;
  28392. };
  28393. /** @hidden */
  28394. protected _currentEffect: Nullable<Effect>;
  28395. /** @hidden */
  28396. protected _currentProgram: Nullable<WebGLProgram>;
  28397. private _compiledEffects;
  28398. private _vertexAttribArraysEnabled;
  28399. /** @hidden */
  28400. protected _cachedViewport: Nullable<Viewport>;
  28401. private _cachedVertexArrayObject;
  28402. /** @hidden */
  28403. protected _cachedVertexBuffers: any;
  28404. /** @hidden */
  28405. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28406. /** @hidden */
  28407. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28408. /** @hidden */
  28409. _currentRenderTarget: Nullable<InternalTexture>;
  28410. private _uintIndicesCurrentlySet;
  28411. private _currentBoundBuffer;
  28412. /** @hidden */
  28413. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28414. private _currentBufferPointers;
  28415. private _currentInstanceLocations;
  28416. private _currentInstanceBuffers;
  28417. private _textureUnits;
  28418. /** @hidden */
  28419. _workingCanvas: Nullable<HTMLCanvasElement>;
  28420. /** @hidden */
  28421. _workingContext: Nullable<CanvasRenderingContext2D>;
  28422. private _rescalePostProcess;
  28423. private _dummyFramebuffer;
  28424. private _externalData;
  28425. /** @hidden */
  28426. _bindedRenderFunction: any;
  28427. private _vaoRecordInProgress;
  28428. private _mustWipeVertexAttributes;
  28429. private _emptyTexture;
  28430. private _emptyCubeTexture;
  28431. private _emptyTexture3D;
  28432. /** @hidden */
  28433. _frameHandler: number;
  28434. private _nextFreeTextureSlots;
  28435. private _maxSimultaneousTextures;
  28436. private _activeRequests;
  28437. private _texturesSupported;
  28438. /** @hidden */
  28439. _textureFormatInUse: Nullable<string>;
  28440. /**
  28441. * Gets the list of texture formats supported
  28442. */
  28443. readonly texturesSupported: Array<string>;
  28444. /**
  28445. * Gets the list of texture formats in use
  28446. */
  28447. readonly textureFormatInUse: Nullable<string>;
  28448. /**
  28449. * Gets the current viewport
  28450. */
  28451. readonly currentViewport: Nullable<Viewport>;
  28452. /**
  28453. * Gets the default empty texture
  28454. */
  28455. readonly emptyTexture: InternalTexture;
  28456. /**
  28457. * Gets the default empty 3D texture
  28458. */
  28459. readonly emptyTexture3D: InternalTexture;
  28460. /**
  28461. * Gets the default empty cube texture
  28462. */
  28463. readonly emptyCubeTexture: InternalTexture;
  28464. /**
  28465. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28466. */
  28467. readonly premultipliedAlpha: boolean;
  28468. /**
  28469. * Creates a new engine
  28470. * @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
  28471. * @param antialias defines enable antialiasing (default: false)
  28472. * @param options defines further options to be sent to the getContext() function
  28473. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28474. */
  28475. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28476. /**
  28477. * Initializes a webVR display and starts listening to display change events
  28478. * The onVRDisplayChangedObservable will be notified upon these changes
  28479. * @returns The onVRDisplayChangedObservable
  28480. */
  28481. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28482. /** @hidden */
  28483. _prepareVRComponent(): void;
  28484. /** @hidden */
  28485. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28486. /** @hidden */
  28487. _submitVRFrame(): void;
  28488. /**
  28489. * Call this function to leave webVR mode
  28490. * Will do nothing if webVR is not supported or if there is no webVR device
  28491. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28492. */
  28493. disableVR(): void;
  28494. /**
  28495. * Gets a boolean indicating that the system is in VR mode and is presenting
  28496. * @returns true if VR mode is engaged
  28497. */
  28498. isVRPresenting(): boolean;
  28499. /** @hidden */
  28500. _requestVRFrame(): void;
  28501. private _disableTouchAction;
  28502. private _rebuildInternalTextures;
  28503. private _rebuildEffects;
  28504. /**
  28505. * Gets a boolean indicating if all created effects are ready
  28506. * @returns true if all effects are ready
  28507. */
  28508. areAllEffectsReady(): boolean;
  28509. private _rebuildBuffers;
  28510. private _initGLContext;
  28511. /**
  28512. * Gets version of the current webGL context
  28513. */
  28514. readonly webGLVersion: number;
  28515. /**
  28516. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28517. */
  28518. readonly isStencilEnable: boolean;
  28519. /** @hidden */
  28520. _prepareWorkingCanvas(): void;
  28521. /**
  28522. * Reset the texture cache to empty state
  28523. */
  28524. resetTextureCache(): void;
  28525. /**
  28526. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28528. * @returns true if engine is in deterministic lock step mode
  28529. */
  28530. isDeterministicLockStep(): boolean;
  28531. /**
  28532. * Gets the max steps when engine is running in deterministic lock step
  28533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28534. * @returns the max steps
  28535. */
  28536. getLockstepMaxSteps(): number;
  28537. /**
  28538. * Gets an object containing information about the current webGL context
  28539. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28540. */
  28541. getGlInfo(): {
  28542. vendor: string;
  28543. renderer: string;
  28544. version: string;
  28545. };
  28546. /**
  28547. * Gets current aspect ratio
  28548. * @param camera defines the camera to use to get the aspect ratio
  28549. * @param useScreen defines if screen size must be used (or the current render target if any)
  28550. * @returns a number defining the aspect ratio
  28551. */
  28552. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28553. /**
  28554. * Gets current screen aspect ratio
  28555. * @returns a number defining the aspect ratio
  28556. */
  28557. getScreenAspectRatio(): number;
  28558. /**
  28559. * Gets the current render width
  28560. * @param useScreen defines if screen size must be used (or the current render target if any)
  28561. * @returns a number defining the current render width
  28562. */
  28563. getRenderWidth(useScreen?: boolean): number;
  28564. /**
  28565. * Gets the current render height
  28566. * @param useScreen defines if screen size must be used (or the current render target if any)
  28567. * @returns a number defining the current render height
  28568. */
  28569. getRenderHeight(useScreen?: boolean): number;
  28570. /**
  28571. * Gets the HTML canvas attached with the current webGL context
  28572. * @returns a HTML canvas
  28573. */
  28574. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28575. /**
  28576. * Gets the client rect of the HTML canvas attached with the current webGL context
  28577. * @returns a client rectanglee
  28578. */
  28579. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28580. /**
  28581. * Defines the hardware scaling level.
  28582. * By default the hardware scaling level is computed from the window device ratio.
  28583. * 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.
  28584. * @param level defines the level to use
  28585. */
  28586. setHardwareScalingLevel(level: number): void;
  28587. /**
  28588. * Gets the current hardware scaling level.
  28589. * By default the hardware scaling level is computed from the window device ratio.
  28590. * 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.
  28591. * @returns a number indicating the current hardware scaling level
  28592. */
  28593. getHardwareScalingLevel(): number;
  28594. /**
  28595. * Gets the list of loaded textures
  28596. * @returns an array containing all loaded textures
  28597. */
  28598. getLoadedTexturesCache(): InternalTexture[];
  28599. /**
  28600. * Gets the object containing all engine capabilities
  28601. * @returns the EngineCapabilities object
  28602. */
  28603. getCaps(): EngineCapabilities;
  28604. /**
  28605. * Gets the current depth function
  28606. * @returns a number defining the depth function
  28607. */
  28608. getDepthFunction(): Nullable<number>;
  28609. /**
  28610. * Sets the current depth function
  28611. * @param depthFunc defines the function to use
  28612. */
  28613. setDepthFunction(depthFunc: number): void;
  28614. /**
  28615. * Sets the current depth function to GREATER
  28616. */
  28617. setDepthFunctionToGreater(): void;
  28618. /**
  28619. * Sets the current depth function to GEQUAL
  28620. */
  28621. setDepthFunctionToGreaterOrEqual(): void;
  28622. /**
  28623. * Sets the current depth function to LESS
  28624. */
  28625. setDepthFunctionToLess(): void;
  28626. private _cachedStencilBuffer;
  28627. private _cachedStencilFunction;
  28628. private _cachedStencilMask;
  28629. private _cachedStencilOperationPass;
  28630. private _cachedStencilOperationFail;
  28631. private _cachedStencilOperationDepthFail;
  28632. private _cachedStencilReference;
  28633. /**
  28634. * Caches the the state of the stencil buffer
  28635. */
  28636. cacheStencilState(): void;
  28637. /**
  28638. * Restores the state of the stencil buffer
  28639. */
  28640. restoreStencilState(): void;
  28641. /**
  28642. * Sets the current depth function to LEQUAL
  28643. */
  28644. setDepthFunctionToLessOrEqual(): void;
  28645. /**
  28646. * Gets a boolean indicating if stencil buffer is enabled
  28647. * @returns the current stencil buffer state
  28648. */
  28649. getStencilBuffer(): boolean;
  28650. /**
  28651. * Enable or disable the stencil buffer
  28652. * @param enable defines if the stencil buffer must be enabled or disabled
  28653. */
  28654. setStencilBuffer(enable: boolean): void;
  28655. /**
  28656. * Gets the current stencil mask
  28657. * @returns a number defining the new stencil mask to use
  28658. */
  28659. getStencilMask(): number;
  28660. /**
  28661. * Sets the current stencil mask
  28662. * @param mask defines the new stencil mask to use
  28663. */
  28664. setStencilMask(mask: number): void;
  28665. /**
  28666. * Gets the current stencil function
  28667. * @returns a number defining the stencil function to use
  28668. */
  28669. getStencilFunction(): number;
  28670. /**
  28671. * Gets the current stencil reference value
  28672. * @returns a number defining the stencil reference value to use
  28673. */
  28674. getStencilFunctionReference(): number;
  28675. /**
  28676. * Gets the current stencil mask
  28677. * @returns a number defining the stencil mask to use
  28678. */
  28679. getStencilFunctionMask(): number;
  28680. /**
  28681. * Sets the current stencil function
  28682. * @param stencilFunc defines the new stencil function to use
  28683. */
  28684. setStencilFunction(stencilFunc: number): void;
  28685. /**
  28686. * Sets the current stencil reference
  28687. * @param reference defines the new stencil reference to use
  28688. */
  28689. setStencilFunctionReference(reference: number): void;
  28690. /**
  28691. * Sets the current stencil mask
  28692. * @param mask defines the new stencil mask to use
  28693. */
  28694. setStencilFunctionMask(mask: number): void;
  28695. /**
  28696. * Gets the current stencil operation when stencil fails
  28697. * @returns a number defining stencil operation to use when stencil fails
  28698. */
  28699. getStencilOperationFail(): number;
  28700. /**
  28701. * Gets the current stencil operation when depth fails
  28702. * @returns a number defining stencil operation to use when depth fails
  28703. */
  28704. getStencilOperationDepthFail(): number;
  28705. /**
  28706. * Gets the current stencil operation when stencil passes
  28707. * @returns a number defining stencil operation to use when stencil passes
  28708. */
  28709. getStencilOperationPass(): number;
  28710. /**
  28711. * Sets the stencil operation to use when stencil fails
  28712. * @param operation defines the stencil operation to use when stencil fails
  28713. */
  28714. setStencilOperationFail(operation: number): void;
  28715. /**
  28716. * Sets the stencil operation to use when depth fails
  28717. * @param operation defines the stencil operation to use when depth fails
  28718. */
  28719. setStencilOperationDepthFail(operation: number): void;
  28720. /**
  28721. * Sets the stencil operation to use when stencil passes
  28722. * @param operation defines the stencil operation to use when stencil passes
  28723. */
  28724. setStencilOperationPass(operation: number): void;
  28725. /**
  28726. * Sets a boolean indicating if the dithering state is enabled or disabled
  28727. * @param value defines the dithering state
  28728. */
  28729. setDitheringState(value: boolean): void;
  28730. /**
  28731. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28732. * @param value defines the rasterizer state
  28733. */
  28734. setRasterizerState(value: boolean): void;
  28735. /**
  28736. * stop executing a render loop function and remove it from the execution array
  28737. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28738. */
  28739. stopRenderLoop(renderFunction?: () => void): void;
  28740. /** @hidden */
  28741. _renderLoop(): void;
  28742. /**
  28743. * Register and execute a render loop. The engine can have more than one render function
  28744. * @param renderFunction defines the function to continuously execute
  28745. */
  28746. runRenderLoop(renderFunction: () => void): void;
  28747. /**
  28748. * Toggle full screen mode
  28749. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28750. */
  28751. switchFullscreen(requestPointerLock: boolean): void;
  28752. /**
  28753. * Enters full screen mode
  28754. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28755. */
  28756. enterFullscreen(requestPointerLock: boolean): void;
  28757. /**
  28758. * Exits full screen mode
  28759. */
  28760. exitFullscreen(): void;
  28761. /**
  28762. * Clear the current render buffer or the current render target (if any is set up)
  28763. * @param color defines the color to use
  28764. * @param backBuffer defines if the back buffer must be cleared
  28765. * @param depth defines if the depth buffer must be cleared
  28766. * @param stencil defines if the stencil buffer must be cleared
  28767. */
  28768. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28769. /**
  28770. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28771. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28772. * @param y defines the y-coordinate of the corner of the clear rectangle
  28773. * @param width defines the width of the clear rectangle
  28774. * @param height defines the height of the clear rectangle
  28775. * @param clearColor defines the clear color
  28776. */
  28777. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28778. /**
  28779. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28780. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28781. * @param y defines the y-coordinate of the corner of the clear rectangle
  28782. * @param width defines the width of the clear rectangle
  28783. * @param height defines the height of the clear rectangle
  28784. */
  28785. enableScissor(x: number, y: number, width: number, height: number): void;
  28786. /**
  28787. * Disable previously set scissor test rectangle
  28788. */
  28789. disableScissor(): void;
  28790. private _viewportCached;
  28791. /** @hidden */
  28792. _viewport(x: number, y: number, width: number, height: number): void;
  28793. /**
  28794. * Set the WebGL's viewport
  28795. * @param viewport defines the viewport element to be used
  28796. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28797. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28798. */
  28799. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28800. /**
  28801. * Directly set the WebGL Viewport
  28802. * @param x defines the x coordinate of the viewport (in screen space)
  28803. * @param y defines the y coordinate of the viewport (in screen space)
  28804. * @param width defines the width of the viewport (in screen space)
  28805. * @param height defines the height of the viewport (in screen space)
  28806. * @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
  28807. */
  28808. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28809. /**
  28810. * Begin a new frame
  28811. */
  28812. beginFrame(): void;
  28813. /**
  28814. * Enf the current frame
  28815. */
  28816. endFrame(): void;
  28817. /**
  28818. * Resize the view according to the canvas' size
  28819. */
  28820. resize(): void;
  28821. /**
  28822. * Force a specific size of the canvas
  28823. * @param width defines the new canvas' width
  28824. * @param height defines the new canvas' height
  28825. */
  28826. setSize(width: number, height: number): void;
  28827. /**
  28828. * Binds the frame buffer to the specified texture.
  28829. * @param texture The texture to render to or null for the default canvas
  28830. * @param faceIndex The face of the texture to render to in case of cube texture
  28831. * @param requiredWidth The width of the target to render to
  28832. * @param requiredHeight The height of the target to render to
  28833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28834. * @param depthStencilTexture The depth stencil texture to use to render
  28835. * @param lodLevel defines le lod level to bind to the frame buffer
  28836. */
  28837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28838. /** @hidden */
  28839. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28840. /**
  28841. * Unbind the current render target texture from the webGL context
  28842. * @param texture defines the render target texture to unbind
  28843. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28844. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28845. */
  28846. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28847. /**
  28848. * Force the mipmap generation for the given render target texture
  28849. * @param texture defines the render target texture to use
  28850. */
  28851. generateMipMapsForCubemap(texture: InternalTexture): void;
  28852. /**
  28853. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28854. */
  28855. flushFramebuffer(): void;
  28856. /**
  28857. * Unbind the current render target and bind the default framebuffer
  28858. */
  28859. restoreDefaultFramebuffer(): void;
  28860. /**
  28861. * Create an uniform buffer
  28862. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28863. * @param elements defines the content of the uniform buffer
  28864. * @returns the webGL uniform buffer
  28865. */
  28866. createUniformBuffer(elements: FloatArray): DataBuffer;
  28867. /**
  28868. * Create a dynamic uniform buffer
  28869. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28870. * @param elements defines the content of the uniform buffer
  28871. * @returns the webGL uniform buffer
  28872. */
  28873. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28874. /**
  28875. * Update an existing uniform buffer
  28876. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28877. * @param uniformBuffer defines the target uniform buffer
  28878. * @param elements defines the content to update
  28879. * @param offset defines the offset in the uniform buffer where update should start
  28880. * @param count defines the size of the data to update
  28881. */
  28882. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28883. private _resetVertexBufferBinding;
  28884. /**
  28885. * Creates a vertex buffer
  28886. * @param data the data for the vertex buffer
  28887. * @returns the new WebGL static buffer
  28888. */
  28889. createVertexBuffer(data: DataArray): DataBuffer;
  28890. /**
  28891. * Creates a dynamic vertex buffer
  28892. * @param data the data for the dynamic vertex buffer
  28893. * @returns the new WebGL dynamic buffer
  28894. */
  28895. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28896. /**
  28897. * Update a dynamic index buffer
  28898. * @param indexBuffer defines the target index buffer
  28899. * @param indices defines the data to update
  28900. * @param offset defines the offset in the target index buffer where update should start
  28901. */
  28902. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28903. /**
  28904. * Updates a dynamic vertex buffer.
  28905. * @param vertexBuffer the vertex buffer to update
  28906. * @param data the data used to update the vertex buffer
  28907. * @param byteOffset the byte offset of the data
  28908. * @param byteLength the byte length of the data
  28909. */
  28910. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28911. private _resetIndexBufferBinding;
  28912. /**
  28913. * Creates a new index buffer
  28914. * @param indices defines the content of the index buffer
  28915. * @param updatable defines if the index buffer must be updatable
  28916. * @returns a new webGL buffer
  28917. */
  28918. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28919. /**
  28920. * Bind a webGL buffer to the webGL context
  28921. * @param buffer defines the buffer to bind
  28922. */
  28923. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28924. /**
  28925. * Bind an uniform buffer to the current webGL context
  28926. * @param buffer defines the buffer to bind
  28927. */
  28928. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28929. /**
  28930. * Bind a buffer to the current webGL context at a given location
  28931. * @param buffer defines the buffer to bind
  28932. * @param location defines the index where to bind the buffer
  28933. */
  28934. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28935. /**
  28936. * Bind a specific block at a given index in a specific shader program
  28937. * @param pipelineContext defines the pipeline context to use
  28938. * @param blockName defines the block name
  28939. * @param index defines the index where to bind the block
  28940. */
  28941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28942. private bindIndexBuffer;
  28943. private bindBuffer;
  28944. /**
  28945. * update the bound buffer with the given data
  28946. * @param data defines the data to update
  28947. */
  28948. updateArrayBuffer(data: Float32Array): void;
  28949. private _vertexAttribPointer;
  28950. private _bindIndexBufferWithCache;
  28951. private _bindVertexBuffersAttributes;
  28952. /**
  28953. * Records a vertex array object
  28954. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28955. * @param vertexBuffers defines the list of vertex buffers to store
  28956. * @param indexBuffer defines the index buffer to store
  28957. * @param effect defines the effect to store
  28958. * @returns the new vertex array object
  28959. */
  28960. recordVertexArrayObject(vertexBuffers: {
  28961. [key: string]: VertexBuffer;
  28962. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28963. /**
  28964. * Bind a specific vertex array object
  28965. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28966. * @param vertexArrayObject defines the vertex array object to bind
  28967. * @param indexBuffer defines the index buffer to bind
  28968. */
  28969. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28970. /**
  28971. * Bind webGl buffers directly to the webGL context
  28972. * @param vertexBuffer defines the vertex buffer to bind
  28973. * @param indexBuffer defines the index buffer to bind
  28974. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28975. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28976. * @param effect defines the effect associated with the vertex buffer
  28977. */
  28978. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28979. private _unbindVertexArrayObject;
  28980. /**
  28981. * Bind a list of vertex buffers to the webGL context
  28982. * @param vertexBuffers defines the list of vertex buffers to bind
  28983. * @param indexBuffer defines the index buffer to bind
  28984. * @param effect defines the effect associated with the vertex buffers
  28985. */
  28986. bindBuffers(vertexBuffers: {
  28987. [key: string]: Nullable<VertexBuffer>;
  28988. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28989. /**
  28990. * Unbind all instance attributes
  28991. */
  28992. unbindInstanceAttributes(): void;
  28993. /**
  28994. * Release and free the memory of a vertex array object
  28995. * @param vao defines the vertex array object to delete
  28996. */
  28997. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28998. /** @hidden */
  28999. _releaseBuffer(buffer: DataBuffer): boolean;
  29000. /**
  29001. * Creates a webGL buffer to use with instanciation
  29002. * @param capacity defines the size of the buffer
  29003. * @returns the webGL buffer
  29004. */
  29005. createInstancesBuffer(capacity: number): DataBuffer;
  29006. /**
  29007. * Delete a webGL buffer used with instanciation
  29008. * @param buffer defines the webGL buffer to delete
  29009. */
  29010. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29011. /**
  29012. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29013. * @param instancesBuffer defines the webGL buffer to update and bind
  29014. * @param data defines the data to store in the buffer
  29015. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29016. */
  29017. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29018. /**
  29019. * Apply all cached states (depth, culling, stencil and alpha)
  29020. */
  29021. applyStates(): void;
  29022. /**
  29023. * Send a draw order
  29024. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29025. * @param indexStart defines the starting index
  29026. * @param indexCount defines the number of index to draw
  29027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29028. */
  29029. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29030. /**
  29031. * Draw a list of points
  29032. * @param verticesStart defines the index of first vertex to draw
  29033. * @param verticesCount defines the count of vertices to draw
  29034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29035. */
  29036. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29037. /**
  29038. * Draw a list of unindexed primitives
  29039. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29040. * @param verticesStart defines the index of first vertex to draw
  29041. * @param verticesCount defines the count of vertices to draw
  29042. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29043. */
  29044. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29045. /**
  29046. * Draw a list of indexed primitives
  29047. * @param fillMode defines the primitive to use
  29048. * @param indexStart defines the starting index
  29049. * @param indexCount defines the number of index to draw
  29050. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29051. */
  29052. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29053. /**
  29054. * Draw a list of unindexed primitives
  29055. * @param fillMode defines the primitive to use
  29056. * @param verticesStart defines the index of first vertex to draw
  29057. * @param verticesCount defines the count of vertices to draw
  29058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29059. */
  29060. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29061. private _drawMode;
  29062. /** @hidden */
  29063. _releaseEffect(effect: Effect): void;
  29064. /** @hidden */
  29065. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29066. /**
  29067. * Create a new effect (used to store vertex/fragment shaders)
  29068. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29069. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29070. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29071. * @param samplers defines an array of string used to represent textures
  29072. * @param defines defines the string containing the defines to use to compile the shaders
  29073. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29074. * @param onCompiled defines a function to call when the effect creation is successful
  29075. * @param onError defines a function to call when the effect creation has failed
  29076. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29077. * @returns the new Effect
  29078. */
  29079. 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;
  29080. private _compileShader;
  29081. private _compileRawShader;
  29082. /**
  29083. * Directly creates a webGL program
  29084. * @param pipelineContext defines the pipeline context to attach to
  29085. * @param vertexCode defines the vertex shader code to use
  29086. * @param fragmentCode defines the fragment shader code to use
  29087. * @param context defines the webGL context to use (if not set, the current one will be used)
  29088. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29089. * @returns the new webGL program
  29090. */
  29091. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29092. /**
  29093. * Creates a webGL program
  29094. * @param pipelineContext defines the pipeline context to attach to
  29095. * @param vertexCode defines the vertex shader code to use
  29096. * @param fragmentCode defines the fragment shader code to use
  29097. * @param defines defines the string containing the defines to use to compile the shaders
  29098. * @param context defines the webGL context to use (if not set, the current one will be used)
  29099. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29100. * @returns the new webGL program
  29101. */
  29102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29103. /**
  29104. * Creates a new pipeline context
  29105. * @returns the new pipeline
  29106. */
  29107. createPipelineContext(): WebGLPipelineContext;
  29108. private _createShaderProgram;
  29109. private _finalizePipelineContext;
  29110. /** @hidden */
  29111. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29112. /** @hidden */
  29113. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29114. /** @hidden */
  29115. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29116. /**
  29117. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29118. * @param pipelineContext defines the pipeline context to use
  29119. * @param uniformsNames defines the list of uniform names
  29120. * @returns an array of webGL uniform locations
  29121. */
  29122. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29123. /**
  29124. * Gets the lsit of active attributes for a given webGL program
  29125. * @param pipelineContext defines the pipeline context to use
  29126. * @param attributesNames defines the list of attribute names to get
  29127. * @returns an array of indices indicating the offset of each attribute
  29128. */
  29129. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29130. /**
  29131. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29132. * @param effect defines the effect to activate
  29133. */
  29134. enableEffect(effect: Nullable<Effect>): void;
  29135. /**
  29136. * Set the value of an uniform to an array of int32
  29137. * @param uniform defines the webGL uniform location where to store the value
  29138. * @param array defines the array of int32 to store
  29139. */
  29140. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29141. /**
  29142. * Set the value of an uniform to an array of int32 (stored as vec2)
  29143. * @param uniform defines the webGL uniform location where to store the value
  29144. * @param array defines the array of int32 to store
  29145. */
  29146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29147. /**
  29148. * Set the value of an uniform to an array of int32 (stored as vec3)
  29149. * @param uniform defines the webGL uniform location where to store the value
  29150. * @param array defines the array of int32 to store
  29151. */
  29152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29153. /**
  29154. * Set the value of an uniform to an array of int32 (stored as vec4)
  29155. * @param uniform defines the webGL uniform location where to store the value
  29156. * @param array defines the array of int32 to store
  29157. */
  29158. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29159. /**
  29160. * Set the value of an uniform to an array of float32
  29161. * @param uniform defines the webGL uniform location where to store the value
  29162. * @param array defines the array of float32 to store
  29163. */
  29164. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29165. /**
  29166. * Set the value of an uniform to an array of float32 (stored as vec2)
  29167. * @param uniform defines the webGL uniform location where to store the value
  29168. * @param array defines the array of float32 to store
  29169. */
  29170. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29171. /**
  29172. * Set the value of an uniform to an array of float32 (stored as vec3)
  29173. * @param uniform defines the webGL uniform location where to store the value
  29174. * @param array defines the array of float32 to store
  29175. */
  29176. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29177. /**
  29178. * Set the value of an uniform to an array of float32 (stored as vec4)
  29179. * @param uniform defines the webGL uniform location where to store the value
  29180. * @param array defines the array of float32 to store
  29181. */
  29182. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29183. /**
  29184. * Set the value of an uniform to an array of number
  29185. * @param uniform defines the webGL uniform location where to store the value
  29186. * @param array defines the array of number to store
  29187. */
  29188. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29189. /**
  29190. * Set the value of an uniform to an array of number (stored as vec2)
  29191. * @param uniform defines the webGL uniform location where to store the value
  29192. * @param array defines the array of number to store
  29193. */
  29194. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29195. /**
  29196. * Set the value of an uniform to an array of number (stored as vec3)
  29197. * @param uniform defines the webGL uniform location where to store the value
  29198. * @param array defines the array of number to store
  29199. */
  29200. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29201. /**
  29202. * Set the value of an uniform to an array of number (stored as vec4)
  29203. * @param uniform defines the webGL uniform location where to store the value
  29204. * @param array defines the array of number to store
  29205. */
  29206. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29207. /**
  29208. * Set the value of an uniform to an array of float32 (stored as matrices)
  29209. * @param uniform defines the webGL uniform location where to store the value
  29210. * @param matrices defines the array of float32 to store
  29211. */
  29212. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29213. /**
  29214. * Set the value of an uniform to a matrix
  29215. * @param uniform defines the webGL uniform location where to store the value
  29216. * @param matrix defines the matrix to store
  29217. */
  29218. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29219. /**
  29220. * Set the value of an uniform to a matrix (3x3)
  29221. * @param uniform defines the webGL uniform location where to store the value
  29222. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29223. */
  29224. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29225. /**
  29226. * Set the value of an uniform to a matrix (2x2)
  29227. * @param uniform defines the webGL uniform location where to store the value
  29228. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29229. */
  29230. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29231. /**
  29232. * Set the value of an uniform to a number (int)
  29233. * @param uniform defines the webGL uniform location where to store the value
  29234. * @param value defines the int number to store
  29235. */
  29236. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29237. /**
  29238. * Set the value of an uniform to a number (float)
  29239. * @param uniform defines the webGL uniform location where to store the value
  29240. * @param value defines the float number to store
  29241. */
  29242. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29243. /**
  29244. * Set the value of an uniform to a vec2
  29245. * @param uniform defines the webGL uniform location where to store the value
  29246. * @param x defines the 1st component of the value
  29247. * @param y defines the 2nd component of the value
  29248. */
  29249. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29250. /**
  29251. * Set the value of an uniform to a vec3
  29252. * @param uniform defines the webGL uniform location where to store the value
  29253. * @param x defines the 1st component of the value
  29254. * @param y defines the 2nd component of the value
  29255. * @param z defines the 3rd component of the value
  29256. */
  29257. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29258. /**
  29259. * Set the value of an uniform to a boolean
  29260. * @param uniform defines the webGL uniform location where to store the value
  29261. * @param bool defines the boolean to store
  29262. */
  29263. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29264. /**
  29265. * Set the value of an uniform to a vec4
  29266. * @param uniform defines the webGL uniform location where to store the value
  29267. * @param x defines the 1st component of the value
  29268. * @param y defines the 2nd component of the value
  29269. * @param z defines the 3rd component of the value
  29270. * @param w defines the 4th component of the value
  29271. */
  29272. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29273. /**
  29274. * Set the value of an uniform to a Color3
  29275. * @param uniform defines the webGL uniform location where to store the value
  29276. * @param color3 defines the color to store
  29277. */
  29278. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29279. /**
  29280. * Set the value of an uniform to a Color3 and an alpha value
  29281. * @param uniform defines the webGL uniform location where to store the value
  29282. * @param color3 defines the color to store
  29283. * @param alpha defines the alpha component to store
  29284. */
  29285. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29286. /**
  29287. * Sets a Color4 on a uniform variable
  29288. * @param uniform defines the uniform location
  29289. * @param color4 defines the value to be set
  29290. */
  29291. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29292. /**
  29293. * Set various states to the webGL context
  29294. * @param culling defines backface culling state
  29295. * @param zOffset defines the value to apply to zOffset (0 by default)
  29296. * @param force defines if states must be applied even if cache is up to date
  29297. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29298. */
  29299. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29300. /**
  29301. * Set the z offset to apply to current rendering
  29302. * @param value defines the offset to apply
  29303. */
  29304. setZOffset(value: number): void;
  29305. /**
  29306. * Gets the current value of the zOffset
  29307. * @returns the current zOffset state
  29308. */
  29309. getZOffset(): number;
  29310. /**
  29311. * Enable or disable depth buffering
  29312. * @param enable defines the state to set
  29313. */
  29314. setDepthBuffer(enable: boolean): void;
  29315. /**
  29316. * Gets a boolean indicating if depth writing is enabled
  29317. * @returns the current depth writing state
  29318. */
  29319. getDepthWrite(): boolean;
  29320. /**
  29321. * Enable or disable depth writing
  29322. * @param enable defines the state to set
  29323. */
  29324. setDepthWrite(enable: boolean): void;
  29325. /**
  29326. * Enable or disable color writing
  29327. * @param enable defines the state to set
  29328. */
  29329. setColorWrite(enable: boolean): void;
  29330. /**
  29331. * Gets a boolean indicating if color writing is enabled
  29332. * @returns the current color writing state
  29333. */
  29334. getColorWrite(): boolean;
  29335. /**
  29336. * Sets alpha constants used by some alpha blending modes
  29337. * @param r defines the red component
  29338. * @param g defines the green component
  29339. * @param b defines the blue component
  29340. * @param a defines the alpha component
  29341. */
  29342. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29343. /**
  29344. * Sets the current alpha mode
  29345. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29346. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29348. */
  29349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29350. /**
  29351. * Gets the current alpha mode
  29352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29353. * @returns the current alpha mode
  29354. */
  29355. getAlphaMode(): number;
  29356. /**
  29357. * Clears the list of texture accessible through engine.
  29358. * This can help preventing texture load conflict due to name collision.
  29359. */
  29360. clearInternalTexturesCache(): void;
  29361. /**
  29362. * Force the entire cache to be cleared
  29363. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29364. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29365. */
  29366. wipeCaches(bruteForce?: boolean): void;
  29367. /**
  29368. * Set the compressed texture format to use, based on the formats you have, and the formats
  29369. * supported by the hardware / browser.
  29370. *
  29371. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29372. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29373. * to API arguments needed to compressed textures. This puts the burden on the container
  29374. * generator to house the arcane code for determining these for current & future formats.
  29375. *
  29376. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29377. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29378. *
  29379. * Note: The result of this call is not taken into account when a texture is base64.
  29380. *
  29381. * @param formatsAvailable defines the list of those format families you have created
  29382. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29383. *
  29384. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29385. * @returns The extension selected.
  29386. */
  29387. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29388. /** @hidden */
  29389. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29390. min: number;
  29391. mag: number;
  29392. };
  29393. /** @hidden */
  29394. _createTexture(): WebGLTexture;
  29395. /**
  29396. * Usually called from Texture.ts.
  29397. * Passed information to create a WebGLTexture
  29398. * @param urlArg defines a value which contains one of the following:
  29399. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29400. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29401. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29402. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29403. * @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)
  29404. * @param scene needed for loading to the correct scene
  29405. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29406. * @param onLoad optional callback to be called upon successful completion
  29407. * @param onError optional callback to be called upon failure
  29408. * @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
  29409. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29410. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29411. * @param forcedExtension defines the extension to use to pick the right loader
  29412. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29413. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29414. */
  29415. 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;
  29416. private _rescaleTexture;
  29417. private _unpackFlipYCached;
  29418. /**
  29419. * In case you are sharing the context with other applications, it might
  29420. * be interested to not cache the unpack flip y state to ensure a consistent
  29421. * value would be set.
  29422. */
  29423. enableUnpackFlipYCached: boolean;
  29424. /** @hidden */
  29425. _unpackFlipY(value: boolean): void;
  29426. /** @hidden */
  29427. _getUnpackAlignement(): number;
  29428. /**
  29429. * Creates a dynamic texture
  29430. * @param width defines the width of the texture
  29431. * @param height defines the height of the texture
  29432. * @param generateMipMaps defines if the engine should generate the mip levels
  29433. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29434. * @returns the dynamic texture inside an InternalTexture
  29435. */
  29436. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29437. /**
  29438. * Update the sampling mode of a given texture
  29439. * @param samplingMode defines the required sampling mode
  29440. * @param texture defines the texture to update
  29441. */
  29442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29443. /**
  29444. * Update the content of a dynamic texture
  29445. * @param texture defines the texture to update
  29446. * @param canvas defines the canvas containing the source
  29447. * @param invertY defines if data must be stored with Y axis inverted
  29448. * @param premulAlpha defines if alpha is stored as premultiplied
  29449. * @param format defines the format of the data
  29450. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29451. */
  29452. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29453. /**
  29454. * Update a video texture
  29455. * @param texture defines the texture to update
  29456. * @param video defines the video element to use
  29457. * @param invertY defines if data must be stored with Y axis inverted
  29458. */
  29459. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29460. /**
  29461. * Updates a depth texture Comparison Mode and Function.
  29462. * If the comparison Function is equal to 0, the mode will be set to none.
  29463. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29464. * @param texture The texture to set the comparison function for
  29465. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29466. */
  29467. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29468. /** @hidden */
  29469. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29470. width: number;
  29471. height: number;
  29472. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29473. /**
  29474. * Creates a depth stencil texture.
  29475. * This is only available in WebGL 2 or with the depth texture extension available.
  29476. * @param size The size of face edge in the texture.
  29477. * @param options The options defining the texture.
  29478. * @returns The texture
  29479. */
  29480. createDepthStencilTexture(size: number | {
  29481. width: number;
  29482. height: number;
  29483. }, options: DepthTextureCreationOptions): InternalTexture;
  29484. /**
  29485. * Creates a depth stencil texture.
  29486. * This is only available in WebGL 2 or with the depth texture extension available.
  29487. * @param size The size of face edge in the texture.
  29488. * @param options The options defining the texture.
  29489. * @returns The texture
  29490. */
  29491. private _createDepthStencilTexture;
  29492. /**
  29493. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29494. * @param renderTarget The render target to set the frame buffer for
  29495. */
  29496. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29497. /**
  29498. * Creates a new render target texture
  29499. * @param size defines the size of the texture
  29500. * @param options defines the options used to create the texture
  29501. * @returns a new render target texture stored in an InternalTexture
  29502. */
  29503. createRenderTargetTexture(size: number | {
  29504. width: number;
  29505. height: number;
  29506. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29507. /** @hidden */
  29508. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29509. /**
  29510. * Updates the sample count of a render target texture
  29511. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29512. * @param texture defines the texture to update
  29513. * @param samples defines the sample count to set
  29514. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29515. */
  29516. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29517. /** @hidden */
  29518. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29519. /** @hidden */
  29520. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29521. /** @hidden */
  29522. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29525. /**
  29526. * @hidden
  29527. */
  29528. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29529. private _prepareWebGLTextureContinuation;
  29530. private _prepareWebGLTexture;
  29531. /** @hidden */
  29532. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29533. /** @hidden */
  29534. _releaseFramebufferObjects(texture: InternalTexture): void;
  29535. /** @hidden */
  29536. _releaseTexture(texture: InternalTexture): void;
  29537. private setProgram;
  29538. private _boundUniforms;
  29539. /**
  29540. * Binds an effect to the webGL context
  29541. * @param effect defines the effect to bind
  29542. */
  29543. bindSamplers(effect: Effect): void;
  29544. private _activateCurrentTexture;
  29545. /** @hidden */
  29546. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29547. /** @hidden */
  29548. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29549. /**
  29550. * Sets a texture to the webGL context from a postprocess
  29551. * @param channel defines the channel to use
  29552. * @param postProcess defines the source postprocess
  29553. */
  29554. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29555. /**
  29556. * Binds the output of the passed in post process to the texture channel specified
  29557. * @param channel The channel the texture should be bound to
  29558. * @param postProcess The post process which's output should be bound
  29559. */
  29560. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29561. /**
  29562. * Unbind all textures from the webGL context
  29563. */
  29564. unbindAllTextures(): void;
  29565. /**
  29566. * Sets a texture to the according uniform.
  29567. * @param channel The texture channel
  29568. * @param uniform The uniform to set
  29569. * @param texture The texture to apply
  29570. */
  29571. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29572. /**
  29573. * Sets a depth stencil texture from a render target to the according uniform.
  29574. * @param channel The texture channel
  29575. * @param uniform The uniform to set
  29576. * @param texture The render target texture containing the depth stencil texture to apply
  29577. */
  29578. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29579. private _bindSamplerUniformToChannel;
  29580. private _getTextureWrapMode;
  29581. private _setTexture;
  29582. /**
  29583. * Sets an array of texture to the webGL context
  29584. * @param channel defines the channel where the texture array must be set
  29585. * @param uniform defines the associated uniform location
  29586. * @param textures defines the array of textures to bind
  29587. */
  29588. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29589. /** @hidden */
  29590. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29591. private _setTextureParameterFloat;
  29592. private _setTextureParameterInteger;
  29593. /**
  29594. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29595. * @param x defines the x coordinate of the rectangle where pixels must be read
  29596. * @param y defines the y coordinate of the rectangle where pixels must be read
  29597. * @param width defines the width of the rectangle where pixels must be read
  29598. * @param height defines the height of the rectangle where pixels must be read
  29599. * @returns a Uint8Array containing RGBA colors
  29600. */
  29601. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29602. /**
  29603. * Add an externaly attached data from its key.
  29604. * This method call will fail and return false, if such key already exists.
  29605. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29606. * @param key the unique key that identifies the data
  29607. * @param data the data object to associate to the key for this Engine instance
  29608. * @return true if no such key were already present and the data was added successfully, false otherwise
  29609. */
  29610. addExternalData<T>(key: string, data: T): boolean;
  29611. /**
  29612. * Get an externaly attached data from its key
  29613. * @param key the unique key that identifies the data
  29614. * @return the associated data, if present (can be null), or undefined if not present
  29615. */
  29616. getExternalData<T>(key: string): T;
  29617. /**
  29618. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29619. * @param key the unique key that identifies the data
  29620. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29621. * @return the associated data, can be null if the factory returned null.
  29622. */
  29623. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29624. /**
  29625. * Remove an externaly attached data from the Engine instance
  29626. * @param key the unique key that identifies the data
  29627. * @return true if the data was successfully removed, false if it doesn't exist
  29628. */
  29629. removeExternalData(key: string): boolean;
  29630. /**
  29631. * Unbind all vertex attributes from the webGL context
  29632. */
  29633. unbindAllAttributes(): void;
  29634. /**
  29635. * 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
  29636. */
  29637. releaseEffects(): void;
  29638. /**
  29639. * Dispose and release all associated resources
  29640. */
  29641. dispose(): void;
  29642. /**
  29643. * Display the loading screen
  29644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29645. */
  29646. displayLoadingUI(): void;
  29647. /**
  29648. * Hide the loading screen
  29649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29650. */
  29651. hideLoadingUI(): void;
  29652. /**
  29653. * Gets the current loading screen object
  29654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29655. */
  29656. /**
  29657. * Sets the current loading screen object
  29658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29659. */
  29660. loadingScreen: ILoadingScreen;
  29661. /**
  29662. * Sets the current loading screen text
  29663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29664. */
  29665. loadingUIText: string;
  29666. /**
  29667. * Sets the current loading screen background color
  29668. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29669. */
  29670. loadingUIBackgroundColor: string;
  29671. /**
  29672. * Attach a new callback raised when context lost event is fired
  29673. * @param callback defines the callback to call
  29674. */
  29675. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29676. /**
  29677. * Attach a new callback raised when context restored event is fired
  29678. * @param callback defines the callback to call
  29679. */
  29680. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29681. /**
  29682. * Gets the source code of the vertex shader associated with a specific webGL program
  29683. * @param program defines the program to use
  29684. * @returns a string containing the source code of the vertex shader associated with the program
  29685. */
  29686. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29687. /**
  29688. * Gets the source code of the fragment shader associated with a specific webGL program
  29689. * @param program defines the program to use
  29690. * @returns a string containing the source code of the fragment shader associated with the program
  29691. */
  29692. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29693. /**
  29694. * Get the current error code of the webGL context
  29695. * @returns the error code
  29696. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29697. */
  29698. getError(): number;
  29699. /**
  29700. * Gets the current framerate
  29701. * @returns a number representing the framerate
  29702. */
  29703. getFps(): number;
  29704. /**
  29705. * Gets the time spent between current and previous frame
  29706. * @returns a number representing the delta time in ms
  29707. */
  29708. getDeltaTime(): number;
  29709. private _measureFps;
  29710. /** @hidden */
  29711. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29712. private _canRenderToFloatFramebuffer;
  29713. private _canRenderToHalfFloatFramebuffer;
  29714. private _canRenderToFramebuffer;
  29715. /** @hidden */
  29716. _getWebGLTextureType(type: number): number;
  29717. /** @hidden */
  29718. _getInternalFormat(format: number): number;
  29719. /** @hidden */
  29720. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29721. /** @hidden */
  29722. _getRGBAMultiSampleBufferFormat(type: number): number;
  29723. /** @hidden */
  29724. _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;
  29725. /** @hidden */
  29726. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29727. /**
  29728. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29729. * @returns true if the engine can be created
  29730. * @ignorenaming
  29731. */
  29732. static isSupported(): boolean;
  29733. }
  29734. }
  29735. declare module "babylonjs/Materials/effect" {
  29736. import { Observable } from "babylonjs/Misc/observable";
  29737. import { Nullable } from "babylonjs/types";
  29738. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29739. import { IDisposable } from "babylonjs/scene";
  29740. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29741. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29742. import { Engine } from "babylonjs/Engines/engine";
  29743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29746. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29748. /**
  29749. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29750. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29751. */
  29752. export class EffectFallbacks {
  29753. private _defines;
  29754. private _currentRank;
  29755. private _maxRank;
  29756. private _mesh;
  29757. /**
  29758. * Removes the fallback from the bound mesh.
  29759. */
  29760. unBindMesh(): void;
  29761. /**
  29762. * Adds a fallback on the specified property.
  29763. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29764. * @param define The name of the define in the shader
  29765. */
  29766. addFallback(rank: number, define: string): void;
  29767. /**
  29768. * Sets the mesh to use CPU skinning when needing to fallback.
  29769. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29770. * @param mesh The mesh to use the fallbacks.
  29771. */
  29772. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29773. /**
  29774. * Checks to see if more fallbacks are still availible.
  29775. */
  29776. readonly isMoreFallbacks: boolean;
  29777. /**
  29778. * Removes the defines that shoould be removed when falling back.
  29779. * @param currentDefines defines the current define statements for the shader.
  29780. * @param effect defines the current effect we try to compile
  29781. * @returns The resulting defines with defines of the current rank removed.
  29782. */
  29783. reduce(currentDefines: string, effect: Effect): string;
  29784. }
  29785. /**
  29786. * Options to be used when creating an effect.
  29787. */
  29788. export class EffectCreationOptions {
  29789. /**
  29790. * Atrributes that will be used in the shader.
  29791. */
  29792. attributes: string[];
  29793. /**
  29794. * Uniform varible names that will be set in the shader.
  29795. */
  29796. uniformsNames: string[];
  29797. /**
  29798. * Uniform buffer varible names that will be set in the shader.
  29799. */
  29800. uniformBuffersNames: string[];
  29801. /**
  29802. * Sampler texture variable names that will be set in the shader.
  29803. */
  29804. samplers: string[];
  29805. /**
  29806. * Define statements that will be set in the shader.
  29807. */
  29808. defines: any;
  29809. /**
  29810. * Possible fallbacks for this effect to improve performance when needed.
  29811. */
  29812. fallbacks: Nullable<EffectFallbacks>;
  29813. /**
  29814. * Callback that will be called when the shader is compiled.
  29815. */
  29816. onCompiled: Nullable<(effect: Effect) => void>;
  29817. /**
  29818. * Callback that will be called if an error occurs during shader compilation.
  29819. */
  29820. onError: Nullable<(effect: Effect, errors: string) => void>;
  29821. /**
  29822. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29823. */
  29824. indexParameters: any;
  29825. /**
  29826. * Max number of lights that can be used in the shader.
  29827. */
  29828. maxSimultaneousLights: number;
  29829. /**
  29830. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29831. */
  29832. transformFeedbackVaryings: Nullable<string[]>;
  29833. }
  29834. /**
  29835. * Effect containing vertex and fragment shader that can be executed on an object.
  29836. */
  29837. export class Effect implements IDisposable {
  29838. /**
  29839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29840. */
  29841. static ShadersRepository: string;
  29842. /**
  29843. * Name of the effect.
  29844. */
  29845. name: any;
  29846. /**
  29847. * String container all the define statements that should be set on the shader.
  29848. */
  29849. defines: string;
  29850. /**
  29851. * Callback that will be called when the shader is compiled.
  29852. */
  29853. onCompiled: Nullable<(effect: Effect) => void>;
  29854. /**
  29855. * Callback that will be called if an error occurs during shader compilation.
  29856. */
  29857. onError: Nullable<(effect: Effect, errors: string) => void>;
  29858. /**
  29859. * Callback that will be called when effect is bound.
  29860. */
  29861. onBind: Nullable<(effect: Effect) => void>;
  29862. /**
  29863. * Unique ID of the effect.
  29864. */
  29865. uniqueId: number;
  29866. /**
  29867. * Observable that will be called when the shader is compiled.
  29868. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29869. */
  29870. onCompileObservable: Observable<Effect>;
  29871. /**
  29872. * Observable that will be called if an error occurs during shader compilation.
  29873. */
  29874. onErrorObservable: Observable<Effect>;
  29875. /** @hidden */
  29876. _onBindObservable: Nullable<Observable<Effect>>;
  29877. /**
  29878. * Observable that will be called when effect is bound.
  29879. */
  29880. readonly onBindObservable: Observable<Effect>;
  29881. /** @hidden */
  29882. _bonesComputationForcedToCPU: boolean;
  29883. private static _uniqueIdSeed;
  29884. private _engine;
  29885. private _uniformBuffersNames;
  29886. private _uniformsNames;
  29887. private _samplerList;
  29888. private _samplers;
  29889. private _isReady;
  29890. private _compilationError;
  29891. private _attributesNames;
  29892. private _attributes;
  29893. private _uniforms;
  29894. /**
  29895. * Key for the effect.
  29896. * @hidden
  29897. */
  29898. _key: string;
  29899. private _indexParameters;
  29900. private _fallbacks;
  29901. private _vertexSourceCode;
  29902. private _fragmentSourceCode;
  29903. private _vertexSourceCodeOverride;
  29904. private _fragmentSourceCodeOverride;
  29905. private _transformFeedbackVaryings;
  29906. /**
  29907. * Compiled shader to webGL program.
  29908. * @hidden
  29909. */
  29910. _pipelineContext: Nullable<IPipelineContext>;
  29911. private _valueCache;
  29912. private static _baseCache;
  29913. /**
  29914. * Instantiates an effect.
  29915. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29916. * @param baseName Name of the effect.
  29917. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29918. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29919. * @param samplers List of sampler variables that will be passed to the shader.
  29920. * @param engine Engine to be used to render the effect
  29921. * @param defines Define statements to be added to the shader.
  29922. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29923. * @param onCompiled Callback that will be called when the shader is compiled.
  29924. * @param onError Callback that will be called if an error occurs during shader compilation.
  29925. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29926. */
  29927. 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);
  29928. /**
  29929. * Unique key for this effect
  29930. */
  29931. readonly key: string;
  29932. /**
  29933. * If the effect has been compiled and prepared.
  29934. * @returns if the effect is compiled and prepared.
  29935. */
  29936. isReady(): boolean;
  29937. /**
  29938. * The engine the effect was initialized with.
  29939. * @returns the engine.
  29940. */
  29941. getEngine(): Engine;
  29942. /**
  29943. * The pipeline context for this effect
  29944. * @returns the associated pipeline context
  29945. */
  29946. getPipelineContext(): Nullable<IPipelineContext>;
  29947. /**
  29948. * The set of names of attribute variables for the shader.
  29949. * @returns An array of attribute names.
  29950. */
  29951. getAttributesNames(): string[];
  29952. /**
  29953. * Returns the attribute at the given index.
  29954. * @param index The index of the attribute.
  29955. * @returns The location of the attribute.
  29956. */
  29957. getAttributeLocation(index: number): number;
  29958. /**
  29959. * Returns the attribute based on the name of the variable.
  29960. * @param name of the attribute to look up.
  29961. * @returns the attribute location.
  29962. */
  29963. getAttributeLocationByName(name: string): number;
  29964. /**
  29965. * The number of attributes.
  29966. * @returns the numnber of attributes.
  29967. */
  29968. getAttributesCount(): number;
  29969. /**
  29970. * Gets the index of a uniform variable.
  29971. * @param uniformName of the uniform to look up.
  29972. * @returns the index.
  29973. */
  29974. getUniformIndex(uniformName: string): number;
  29975. /**
  29976. * Returns the attribute based on the name of the variable.
  29977. * @param uniformName of the uniform to look up.
  29978. * @returns the location of the uniform.
  29979. */
  29980. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29981. /**
  29982. * Returns an array of sampler variable names
  29983. * @returns The array of sampler variable neames.
  29984. */
  29985. getSamplers(): string[];
  29986. /**
  29987. * The error from the last compilation.
  29988. * @returns the error string.
  29989. */
  29990. getCompilationError(): string;
  29991. /**
  29992. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29993. * @param func The callback to be used.
  29994. */
  29995. executeWhenCompiled(func: (effect: Effect) => void): void;
  29996. private _checkIsReady;
  29997. /** @hidden */
  29998. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29999. /** @hidden */
  30000. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30001. /** @hidden */
  30002. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30003. private _processShaderConversion;
  30004. private _processIncludes;
  30005. private _processPrecision;
  30006. /**
  30007. * Recompiles the webGL program
  30008. * @param vertexSourceCode The source code for the vertex shader.
  30009. * @param fragmentSourceCode The source code for the fragment shader.
  30010. * @param onCompiled Callback called when completed.
  30011. * @param onError Callback called on error.
  30012. * @hidden
  30013. */
  30014. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30015. /**
  30016. * Prepares the effect
  30017. * @hidden
  30018. */
  30019. _prepareEffect(): void;
  30020. /**
  30021. * Checks if the effect is supported. (Must be called after compilation)
  30022. */
  30023. readonly isSupported: boolean;
  30024. /**
  30025. * Binds a texture to the engine to be used as output of the shader.
  30026. * @param channel Name of the output variable.
  30027. * @param texture Texture to bind.
  30028. * @hidden
  30029. */
  30030. _bindTexture(channel: string, texture: InternalTexture): void;
  30031. /**
  30032. * Sets a texture on the engine to be used in the shader.
  30033. * @param channel Name of the sampler variable.
  30034. * @param texture Texture to set.
  30035. */
  30036. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30037. /**
  30038. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30039. * @param channel Name of the sampler variable.
  30040. * @param texture Texture to set.
  30041. */
  30042. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30043. /**
  30044. * Sets an array of textures on the engine to be used in the shader.
  30045. * @param channel Name of the variable.
  30046. * @param textures Textures to set.
  30047. */
  30048. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30049. /**
  30050. * 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)
  30051. * @param channel Name of the sampler variable.
  30052. * @param postProcess Post process to get the input texture from.
  30053. */
  30054. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30055. /**
  30056. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30057. * 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)
  30058. * @param channel Name of the sampler variable.
  30059. * @param postProcess Post process to get the output texture from.
  30060. */
  30061. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30062. /** @hidden */
  30063. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30064. /** @hidden */
  30065. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30066. /** @hidden */
  30067. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30068. /** @hidden */
  30069. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30070. /**
  30071. * Binds a buffer to a uniform.
  30072. * @param buffer Buffer to bind.
  30073. * @param name Name of the uniform variable to bind to.
  30074. */
  30075. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30076. /**
  30077. * Binds block to a uniform.
  30078. * @param blockName Name of the block to bind.
  30079. * @param index Index to bind.
  30080. */
  30081. bindUniformBlock(blockName: string, index: number): void;
  30082. /**
  30083. * Sets an interger value on a uniform variable.
  30084. * @param uniformName Name of the variable.
  30085. * @param value Value to be set.
  30086. * @returns this effect.
  30087. */
  30088. setInt(uniformName: string, value: number): Effect;
  30089. /**
  30090. * Sets an int array on a uniform variable.
  30091. * @param uniformName Name of the variable.
  30092. * @param array array to be set.
  30093. * @returns this effect.
  30094. */
  30095. setIntArray(uniformName: string, array: Int32Array): Effect;
  30096. /**
  30097. * 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)
  30098. * @param uniformName Name of the variable.
  30099. * @param array array to be set.
  30100. * @returns this effect.
  30101. */
  30102. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30103. /**
  30104. * 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)
  30105. * @param uniformName Name of the variable.
  30106. * @param array array to be set.
  30107. * @returns this effect.
  30108. */
  30109. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30110. /**
  30111. * 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)
  30112. * @param uniformName Name of the variable.
  30113. * @param array array to be set.
  30114. * @returns this effect.
  30115. */
  30116. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30117. /**
  30118. * Sets an float array on a uniform variable.
  30119. * @param uniformName Name of the variable.
  30120. * @param array array to be set.
  30121. * @returns this effect.
  30122. */
  30123. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30124. /**
  30125. * 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)
  30126. * @param uniformName Name of the variable.
  30127. * @param array array to be set.
  30128. * @returns this effect.
  30129. */
  30130. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30131. /**
  30132. * 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)
  30133. * @param uniformName Name of the variable.
  30134. * @param array array to be set.
  30135. * @returns this effect.
  30136. */
  30137. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30138. /**
  30139. * 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)
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30145. /**
  30146. * Sets an array on a uniform variable.
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setArray(uniformName: string, array: number[]): Effect;
  30152. /**
  30153. * 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)
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setArray2(uniformName: string, array: number[]): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setArray3(uniformName: string, array: number[]): Effect;
  30166. /**
  30167. * 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)
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setArray4(uniformName: string, array: number[]): Effect;
  30173. /**
  30174. * Sets matrices on a uniform variable.
  30175. * @param uniformName Name of the variable.
  30176. * @param matrices matrices to be set.
  30177. * @returns this effect.
  30178. */
  30179. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30180. /**
  30181. * Sets matrix on a uniform variable.
  30182. * @param uniformName Name of the variable.
  30183. * @param matrix matrix to be set.
  30184. * @returns this effect.
  30185. */
  30186. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param matrix matrix to be set.
  30191. * @returns this effect.
  30192. */
  30193. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30194. /**
  30195. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30196. * @param uniformName Name of the variable.
  30197. * @param matrix matrix to be set.
  30198. * @returns this effect.
  30199. */
  30200. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30201. /**
  30202. * Sets a float on a uniform variable.
  30203. * @param uniformName Name of the variable.
  30204. * @param value value to be set.
  30205. * @returns this effect.
  30206. */
  30207. setFloat(uniformName: string, value: number): Effect;
  30208. /**
  30209. * Sets a boolean on a uniform variable.
  30210. * @param uniformName Name of the variable.
  30211. * @param bool value to be set.
  30212. * @returns this effect.
  30213. */
  30214. setBool(uniformName: string, bool: boolean): Effect;
  30215. /**
  30216. * Sets a Vector2 on a uniform variable.
  30217. * @param uniformName Name of the variable.
  30218. * @param vector2 vector2 to be set.
  30219. * @returns this effect.
  30220. */
  30221. setVector2(uniformName: string, vector2: Vector2): Effect;
  30222. /**
  30223. * Sets a float2 on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param x First float in float2.
  30226. * @param y Second float in float2.
  30227. * @returns this effect.
  30228. */
  30229. setFloat2(uniformName: string, x: number, y: number): Effect;
  30230. /**
  30231. * Sets a Vector3 on a uniform variable.
  30232. * @param uniformName Name of the variable.
  30233. * @param vector3 Value to be set.
  30234. * @returns this effect.
  30235. */
  30236. setVector3(uniformName: string, vector3: Vector3): Effect;
  30237. /**
  30238. * Sets a float3 on a uniform variable.
  30239. * @param uniformName Name of the variable.
  30240. * @param x First float in float3.
  30241. * @param y Second float in float3.
  30242. * @param z Third float in float3.
  30243. * @returns this effect.
  30244. */
  30245. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30246. /**
  30247. * Sets a Vector4 on a uniform variable.
  30248. * @param uniformName Name of the variable.
  30249. * @param vector4 Value to be set.
  30250. * @returns this effect.
  30251. */
  30252. setVector4(uniformName: string, vector4: Vector4): Effect;
  30253. /**
  30254. * Sets a float4 on a uniform variable.
  30255. * @param uniformName Name of the variable.
  30256. * @param x First float in float4.
  30257. * @param y Second float in float4.
  30258. * @param z Third float in float4.
  30259. * @param w Fourth float in float4.
  30260. * @returns this effect.
  30261. */
  30262. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30263. /**
  30264. * Sets a Color3 on a uniform variable.
  30265. * @param uniformName Name of the variable.
  30266. * @param color3 Value to be set.
  30267. * @returns this effect.
  30268. */
  30269. setColor3(uniformName: string, color3: Color3): Effect;
  30270. /**
  30271. * Sets a Color4 on a uniform variable.
  30272. * @param uniformName Name of the variable.
  30273. * @param color3 Value to be set.
  30274. * @param alpha Alpha value to be set.
  30275. * @returns this effect.
  30276. */
  30277. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30278. /**
  30279. * Sets a Color4 on a uniform variable
  30280. * @param uniformName defines the name of the variable
  30281. * @param color4 defines the value to be set
  30282. * @returns this effect.
  30283. */
  30284. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30285. /** Release all associated resources */
  30286. dispose(): void;
  30287. /**
  30288. * This function will add a new shader to the shader store
  30289. * @param name the name of the shader
  30290. * @param pixelShader optional pixel shader content
  30291. * @param vertexShader optional vertex shader content
  30292. */
  30293. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30294. /**
  30295. * Store of each shader (The can be looked up using effect.key)
  30296. */
  30297. static ShadersStore: {
  30298. [key: string]: string;
  30299. };
  30300. /**
  30301. * Store of each included file for a shader (The can be looked up using effect.key)
  30302. */
  30303. static IncludesShadersStore: {
  30304. [key: string]: string;
  30305. };
  30306. /**
  30307. * Resets the cache of effects.
  30308. */
  30309. static ResetCache(): void;
  30310. }
  30311. }
  30312. declare module "babylonjs/Materials/colorCurves" {
  30313. import { Effect } from "babylonjs/Materials/effect";
  30314. /**
  30315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30317. * 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;
  30318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30319. */
  30320. export class ColorCurves {
  30321. private _dirty;
  30322. private _tempColor;
  30323. private _globalCurve;
  30324. private _highlightsCurve;
  30325. private _midtonesCurve;
  30326. private _shadowsCurve;
  30327. private _positiveCurve;
  30328. private _negativeCurve;
  30329. private _globalHue;
  30330. private _globalDensity;
  30331. private _globalSaturation;
  30332. private _globalExposure;
  30333. /**
  30334. * Gets the global Hue value.
  30335. * 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).
  30336. */
  30337. /**
  30338. * Sets 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. globalHue: number;
  30342. /**
  30343. * Gets the global Density value.
  30344. * 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.
  30345. * Values less than zero provide a filter of opposite hue.
  30346. */
  30347. /**
  30348. * Sets the global Density value.
  30349. * 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.
  30350. * Values less than zero provide a filter of opposite hue.
  30351. */
  30352. globalDensity: number;
  30353. /**
  30354. * Gets the global Saturation value.
  30355. * 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.
  30356. */
  30357. /**
  30358. * Sets 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. globalSaturation: number;
  30362. /**
  30363. * Gets the global Exposure value.
  30364. * 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.
  30365. */
  30366. /**
  30367. * Sets 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. globalExposure: number;
  30371. private _highlightsHue;
  30372. private _highlightsDensity;
  30373. private _highlightsSaturation;
  30374. private _highlightsExposure;
  30375. /**
  30376. * Gets the highlights Hue value.
  30377. * 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).
  30378. */
  30379. /**
  30380. * Sets 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. highlightsHue: number;
  30384. /**
  30385. * Gets the highlights Density value.
  30386. * 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.
  30387. * Values less than zero provide a filter of opposite hue.
  30388. */
  30389. /**
  30390. * Sets the highlights Density value.
  30391. * 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.
  30392. * Values less than zero provide a filter of opposite hue.
  30393. */
  30394. highlightsDensity: number;
  30395. /**
  30396. * Gets the highlights Saturation value.
  30397. * 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.
  30398. */
  30399. /**
  30400. * Sets 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. highlightsSaturation: number;
  30404. /**
  30405. * Gets the highlights Exposure value.
  30406. * 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.
  30407. */
  30408. /**
  30409. * Sets 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. highlightsExposure: number;
  30413. private _midtonesHue;
  30414. private _midtonesDensity;
  30415. private _midtonesSaturation;
  30416. private _midtonesExposure;
  30417. /**
  30418. * Gets the midtones Hue value.
  30419. * 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).
  30420. */
  30421. /**
  30422. * Sets 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. midtonesHue: number;
  30426. /**
  30427. * Gets the midtones Density value.
  30428. * 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.
  30429. * Values less than zero provide a filter of opposite hue.
  30430. */
  30431. /**
  30432. * Sets the midtones Density value.
  30433. * 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.
  30434. * Values less than zero provide a filter of opposite hue.
  30435. */
  30436. midtonesDensity: number;
  30437. /**
  30438. * Gets the midtones Saturation value.
  30439. * 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.
  30440. */
  30441. /**
  30442. * Sets 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. midtonesSaturation: number;
  30446. /**
  30447. * Gets the midtones Exposure value.
  30448. * 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.
  30449. */
  30450. /**
  30451. * Sets 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. midtonesExposure: number;
  30455. private _shadowsHue;
  30456. private _shadowsDensity;
  30457. private _shadowsSaturation;
  30458. private _shadowsExposure;
  30459. /**
  30460. * Gets the shadows Hue value.
  30461. * 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).
  30462. */
  30463. /**
  30464. * Sets 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. shadowsHue: number;
  30468. /**
  30469. * Gets the shadows Density value.
  30470. * 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.
  30471. * Values less than zero provide a filter of opposite hue.
  30472. */
  30473. /**
  30474. * Sets the shadows Density value.
  30475. * 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.
  30476. * Values less than zero provide a filter of opposite hue.
  30477. */
  30478. shadowsDensity: number;
  30479. /**
  30480. * Gets the shadows Saturation value.
  30481. * 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.
  30482. */
  30483. /**
  30484. * Sets 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. shadowsSaturation: number;
  30488. /**
  30489. * Gets the shadows Exposure value.
  30490. * 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.
  30491. */
  30492. /**
  30493. * Sets 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. shadowsExposure: number;
  30497. /**
  30498. * Returns the class name
  30499. * @returns The class name
  30500. */
  30501. getClassName(): string;
  30502. /**
  30503. * Binds the color curves to the shader.
  30504. * @param colorCurves The color curve to bind
  30505. * @param effect The effect to bind to
  30506. * @param positiveUniform The positive uniform shader parameter
  30507. * @param neutralUniform The neutral uniform shader parameter
  30508. * @param negativeUniform The negative uniform shader parameter
  30509. */
  30510. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30511. /**
  30512. * Prepare the list of uniforms associated with the ColorCurves effects.
  30513. * @param uniformsList The list of uniforms used in the effect
  30514. */
  30515. static PrepareUniforms(uniformsList: string[]): void;
  30516. /**
  30517. * Returns color grading data based on a hue, density, saturation and exposure value.
  30518. * @param filterHue The hue of the color filter.
  30519. * @param filterDensity The density of the color filter.
  30520. * @param saturation The saturation.
  30521. * @param exposure The exposure.
  30522. * @param result The result data container.
  30523. */
  30524. private getColorGradingDataToRef;
  30525. /**
  30526. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30527. * @param value The input slider value in range [-100,100].
  30528. * @returns Adjusted value.
  30529. */
  30530. private static applyColorGradingSliderNonlinear;
  30531. /**
  30532. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30533. * @param hue The hue (H) input.
  30534. * @param saturation The saturation (S) input.
  30535. * @param brightness The brightness (B) input.
  30536. * @result An RGBA color represented as Vector4.
  30537. */
  30538. private static fromHSBToRef;
  30539. /**
  30540. * Returns a value clamped between min and max
  30541. * @param value The value to clamp
  30542. * @param min The minimum of value
  30543. * @param max The maximum of value
  30544. * @returns The clamped value.
  30545. */
  30546. private static clamp;
  30547. /**
  30548. * Clones the current color curve instance.
  30549. * @return The cloned curves
  30550. */
  30551. clone(): ColorCurves;
  30552. /**
  30553. * Serializes the current color curve instance to a json representation.
  30554. * @return a JSON representation
  30555. */
  30556. serialize(): any;
  30557. /**
  30558. * Parses the color curve from a json representation.
  30559. * @param source the JSON source to parse
  30560. * @return The parsed curves
  30561. */
  30562. static Parse(source: any): ColorCurves;
  30563. }
  30564. }
  30565. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30566. import { Observable } from "babylonjs/Misc/observable";
  30567. import { Nullable } from "babylonjs/types";
  30568. import { Color4 } from "babylonjs/Maths/math";
  30569. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30570. import { Effect } from "babylonjs/Materials/effect";
  30571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30573. /**
  30574. * Interface to follow in your material defines to integrate easily the
  30575. * Image proccessing functions.
  30576. * @hidden
  30577. */
  30578. export interface IImageProcessingConfigurationDefines {
  30579. IMAGEPROCESSING: boolean;
  30580. VIGNETTE: boolean;
  30581. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30582. VIGNETTEBLENDMODEOPAQUE: boolean;
  30583. TONEMAPPING: boolean;
  30584. TONEMAPPING_ACES: boolean;
  30585. CONTRAST: boolean;
  30586. EXPOSURE: boolean;
  30587. COLORCURVES: boolean;
  30588. COLORGRADING: boolean;
  30589. COLORGRADING3D: boolean;
  30590. SAMPLER3DGREENDEPTH: boolean;
  30591. SAMPLER3DBGRMAP: boolean;
  30592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30593. }
  30594. /**
  30595. * @hidden
  30596. */
  30597. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30598. IMAGEPROCESSING: boolean;
  30599. VIGNETTE: boolean;
  30600. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30601. VIGNETTEBLENDMODEOPAQUE: boolean;
  30602. TONEMAPPING: boolean;
  30603. TONEMAPPING_ACES: boolean;
  30604. CONTRAST: boolean;
  30605. COLORCURVES: boolean;
  30606. COLORGRADING: boolean;
  30607. COLORGRADING3D: boolean;
  30608. SAMPLER3DGREENDEPTH: boolean;
  30609. SAMPLER3DBGRMAP: boolean;
  30610. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30611. EXPOSURE: boolean;
  30612. constructor();
  30613. }
  30614. /**
  30615. * This groups together the common properties used for image processing either in direct forward pass
  30616. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30617. * or not.
  30618. */
  30619. export class ImageProcessingConfiguration {
  30620. /**
  30621. * Default tone mapping applied in BabylonJS.
  30622. */
  30623. static readonly TONEMAPPING_STANDARD: number;
  30624. /**
  30625. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30626. * to other engines rendering to increase portability.
  30627. */
  30628. static readonly TONEMAPPING_ACES: number;
  30629. /**
  30630. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30631. */
  30632. colorCurves: Nullable<ColorCurves>;
  30633. private _colorCurvesEnabled;
  30634. /**
  30635. * Gets wether the color curves effect is enabled.
  30636. */
  30637. /**
  30638. * Sets wether the color curves effect is enabled.
  30639. */
  30640. colorCurvesEnabled: boolean;
  30641. private _colorGradingTexture;
  30642. /**
  30643. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30644. */
  30645. /**
  30646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30647. */
  30648. colorGradingTexture: Nullable<BaseTexture>;
  30649. private _colorGradingEnabled;
  30650. /**
  30651. * Gets wether the color grading effect is enabled.
  30652. */
  30653. /**
  30654. * Sets wether the color grading effect is enabled.
  30655. */
  30656. colorGradingEnabled: boolean;
  30657. private _colorGradingWithGreenDepth;
  30658. /**
  30659. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30660. */
  30661. /**
  30662. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30663. */
  30664. colorGradingWithGreenDepth: boolean;
  30665. private _colorGradingBGR;
  30666. /**
  30667. * Gets wether the color grading texture contains BGR values.
  30668. */
  30669. /**
  30670. * Sets wether the color grading texture contains BGR values.
  30671. */
  30672. colorGradingBGR: boolean;
  30673. /** @hidden */
  30674. _exposure: number;
  30675. /**
  30676. * Gets the Exposure used in the effect.
  30677. */
  30678. /**
  30679. * Sets the Exposure used in the effect.
  30680. */
  30681. exposure: number;
  30682. private _toneMappingEnabled;
  30683. /**
  30684. * Gets wether the tone mapping effect is enabled.
  30685. */
  30686. /**
  30687. * Sets wether the tone mapping effect is enabled.
  30688. */
  30689. toneMappingEnabled: boolean;
  30690. private _toneMappingType;
  30691. /**
  30692. * Gets the type of tone mapping effect.
  30693. */
  30694. /**
  30695. * Sets the type of tone mapping effect used in BabylonJS.
  30696. */
  30697. toneMappingType: number;
  30698. protected _contrast: number;
  30699. /**
  30700. * Gets the contrast used in the effect.
  30701. */
  30702. /**
  30703. * Sets the contrast used in the effect.
  30704. */
  30705. contrast: number;
  30706. /**
  30707. * Vignette stretch size.
  30708. */
  30709. vignetteStretch: number;
  30710. /**
  30711. * Vignette centre X Offset.
  30712. */
  30713. vignetteCentreX: number;
  30714. /**
  30715. * Vignette centre Y Offset.
  30716. */
  30717. vignetteCentreY: number;
  30718. /**
  30719. * Vignette weight or intensity of the vignette effect.
  30720. */
  30721. vignetteWeight: number;
  30722. /**
  30723. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30724. * if vignetteEnabled is set to true.
  30725. */
  30726. vignetteColor: Color4;
  30727. /**
  30728. * Camera field of view used by the Vignette effect.
  30729. */
  30730. vignetteCameraFov: number;
  30731. private _vignetteBlendMode;
  30732. /**
  30733. * Gets the vignette blend mode allowing different kind of effect.
  30734. */
  30735. /**
  30736. * Sets the vignette blend mode allowing different kind of effect.
  30737. */
  30738. vignetteBlendMode: number;
  30739. private _vignetteEnabled;
  30740. /**
  30741. * Gets wether the vignette effect is enabled.
  30742. */
  30743. /**
  30744. * Sets wether the vignette effect is enabled.
  30745. */
  30746. vignetteEnabled: boolean;
  30747. private _applyByPostProcess;
  30748. /**
  30749. * Gets wether the image processing is applied through a post process or not.
  30750. */
  30751. /**
  30752. * Sets wether the image processing is applied through a post process or not.
  30753. */
  30754. applyByPostProcess: boolean;
  30755. private _isEnabled;
  30756. /**
  30757. * Gets wether the image processing is enabled or not.
  30758. */
  30759. /**
  30760. * Sets wether the image processing is enabled or not.
  30761. */
  30762. isEnabled: boolean;
  30763. /**
  30764. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30765. */
  30766. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30767. /**
  30768. * Method called each time the image processing information changes requires to recompile the effect.
  30769. */
  30770. protected _updateParameters(): void;
  30771. /**
  30772. * Gets the current class name.
  30773. * @return "ImageProcessingConfiguration"
  30774. */
  30775. getClassName(): string;
  30776. /**
  30777. * Prepare the list of uniforms associated with the Image Processing effects.
  30778. * @param uniforms The list of uniforms used in the effect
  30779. * @param defines the list of defines currently in use
  30780. */
  30781. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30782. /**
  30783. * Prepare the list of samplers associated with the Image Processing effects.
  30784. * @param samplersList The list of uniforms used in the effect
  30785. * @param defines the list of defines currently in use
  30786. */
  30787. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30788. /**
  30789. * Prepare the list of defines associated to the shader.
  30790. * @param defines the list of defines to complete
  30791. * @param forPostProcess Define if we are currently in post process mode or not
  30792. */
  30793. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30794. /**
  30795. * Returns true if all the image processing information are ready.
  30796. * @returns True if ready, otherwise, false
  30797. */
  30798. isReady(): boolean;
  30799. /**
  30800. * Binds the image processing to the shader.
  30801. * @param effect The effect to bind to
  30802. * @param aspectRatio Define the current aspect ratio of the effect
  30803. */
  30804. bind(effect: Effect, aspectRatio?: number): void;
  30805. /**
  30806. * Clones the current image processing instance.
  30807. * @return The cloned image processing
  30808. */
  30809. clone(): ImageProcessingConfiguration;
  30810. /**
  30811. * Serializes the current image processing instance to a json representation.
  30812. * @return a JSON representation
  30813. */
  30814. serialize(): any;
  30815. /**
  30816. * Parses the image processing from a json representation.
  30817. * @param source the JSON source to parse
  30818. * @return The parsed image processing
  30819. */
  30820. static Parse(source: any): ImageProcessingConfiguration;
  30821. private static _VIGNETTEMODE_MULTIPLY;
  30822. private static _VIGNETTEMODE_OPAQUE;
  30823. /**
  30824. * Used to apply the vignette as a mix with the pixel color.
  30825. */
  30826. static readonly VIGNETTEMODE_MULTIPLY: number;
  30827. /**
  30828. * Used to apply the vignette as a replacement of the pixel color.
  30829. */
  30830. static readonly VIGNETTEMODE_OPAQUE: number;
  30831. }
  30832. }
  30833. declare module "babylonjs/Materials/fresnelParameters" {
  30834. import { Color3 } from "babylonjs/Maths/math";
  30835. /**
  30836. * This represents all the required information to add a fresnel effect on a material:
  30837. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30838. */
  30839. export class FresnelParameters {
  30840. private _isEnabled;
  30841. /**
  30842. * Define if the fresnel effect is enable or not.
  30843. */
  30844. isEnabled: boolean;
  30845. /**
  30846. * Define the color used on edges (grazing angle)
  30847. */
  30848. leftColor: Color3;
  30849. /**
  30850. * Define the color used on center
  30851. */
  30852. rightColor: Color3;
  30853. /**
  30854. * Define bias applied to computed fresnel term
  30855. */
  30856. bias: number;
  30857. /**
  30858. * Defined the power exponent applied to fresnel term
  30859. */
  30860. power: number;
  30861. /**
  30862. * Clones the current fresnel and its valuues
  30863. * @returns a clone fresnel configuration
  30864. */
  30865. clone(): FresnelParameters;
  30866. /**
  30867. * Serializes the current fresnel parameters to a JSON representation.
  30868. * @return the JSON serialization
  30869. */
  30870. serialize(): any;
  30871. /**
  30872. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30873. * @param parsedFresnelParameters Define the JSON representation
  30874. * @returns the parsed parameters
  30875. */
  30876. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30877. }
  30878. }
  30879. declare module "babylonjs/Misc/decorators" {
  30880. import { Nullable } from "babylonjs/types";
  30881. import { Scene } from "babylonjs/scene";
  30882. import { IAnimatable } from "babylonjs/Misc/tools";
  30883. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30884. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30885. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30886. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. /**
  30897. * Decorator used to define property that can be serialized as reference to a camera
  30898. * @param sourceName defines the name of the property to decorate
  30899. */
  30900. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30901. /**
  30902. * Class used to help serialization objects
  30903. */
  30904. export class SerializationHelper {
  30905. /** hidden */
  30906. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30907. /** hidden */
  30908. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30909. /** hidden */
  30910. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30911. /** hidden */
  30912. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30913. /**
  30914. * Appends the serialized animations from the source animations
  30915. * @param source Source containing the animations
  30916. * @param destination Target to store the animations
  30917. */
  30918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30919. /**
  30920. * Static function used to serialized a specific entity
  30921. * @param entity defines the entity to serialize
  30922. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30923. * @returns a JSON compatible object representing the serialization of the entity
  30924. */
  30925. static Serialize<T>(entity: T, serializationObject?: any): any;
  30926. /**
  30927. * Creates a new entity from a serialization data object
  30928. * @param creationFunction defines a function used to instanciated the new entity
  30929. * @param source defines the source serialization data
  30930. * @param scene defines the hosting scene
  30931. * @param rootUrl defines the root url for resources
  30932. * @returns a new entity
  30933. */
  30934. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30935. /**
  30936. * Clones an object
  30937. * @param creationFunction defines the function used to instanciate the new object
  30938. * @param source defines the source object
  30939. * @returns the cloned object
  30940. */
  30941. static Clone<T>(creationFunction: () => T, source: T): T;
  30942. /**
  30943. * Instanciates a new object based on a source one (some data will be shared between both object)
  30944. * @param creationFunction defines the function used to instanciate the new object
  30945. * @param source defines the source object
  30946. * @returns the new object
  30947. */
  30948. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30949. }
  30950. }
  30951. declare module "babylonjs/Cameras/camera" {
  30952. import { SmartArray } from "babylonjs/Misc/smartArray";
  30953. import { Observable } from "babylonjs/Misc/observable";
  30954. import { Nullable } from "babylonjs/types";
  30955. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30956. import { Scene } from "babylonjs/scene";
  30957. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30958. import { Node } from "babylonjs/node";
  30959. import { Mesh } from "babylonjs/Meshes/mesh";
  30960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30961. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30962. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30965. import { Ray } from "babylonjs/Culling/ray";
  30966. /**
  30967. * This is the base class of all the camera used in the application.
  30968. * @see http://doc.babylonjs.com/features/cameras
  30969. */
  30970. export class Camera extends Node {
  30971. /** @hidden */
  30972. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30973. /**
  30974. * This is the default projection mode used by the cameras.
  30975. * It helps recreating a feeling of perspective and better appreciate depth.
  30976. * This is the best way to simulate real life cameras.
  30977. */
  30978. static readonly PERSPECTIVE_CAMERA: number;
  30979. /**
  30980. * This helps creating camera with an orthographic mode.
  30981. * 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.
  30982. */
  30983. static readonly ORTHOGRAPHIC_CAMERA: number;
  30984. /**
  30985. * This is the default FOV mode for perspective cameras.
  30986. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30987. */
  30988. static readonly FOVMODE_VERTICAL_FIXED: number;
  30989. /**
  30990. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30991. */
  30992. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30993. /**
  30994. * This specifies ther is no need for a camera rig.
  30995. * Basically only one eye is rendered corresponding to the camera.
  30996. */
  30997. static readonly RIG_MODE_NONE: number;
  30998. /**
  30999. * Simulates a camera Rig with one blue eye and one red eye.
  31000. * This can be use with 3d blue and red glasses.
  31001. */
  31002. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31003. /**
  31004. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31005. */
  31006. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31007. /**
  31008. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31009. */
  31010. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31011. /**
  31012. * Defines that both eyes of the camera will be rendered over under each other.
  31013. */
  31014. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31015. /**
  31016. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31017. */
  31018. static readonly RIG_MODE_VR: number;
  31019. /**
  31020. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31021. */
  31022. static readonly RIG_MODE_WEBVR: number;
  31023. /**
  31024. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31025. */
  31026. static readonly RIG_MODE_CUSTOM: number;
  31027. /**
  31028. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31029. */
  31030. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31031. /**
  31032. * Define the input manager associated with the camera.
  31033. */
  31034. inputs: CameraInputsManager<Camera>;
  31035. /** @hidden */
  31036. _position: Vector3;
  31037. /**
  31038. * Define the current local position of the camera in the scene
  31039. */
  31040. position: Vector3;
  31041. /**
  31042. * The vector the camera should consider as up.
  31043. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31044. */
  31045. upVector: Vector3;
  31046. /**
  31047. * Define the current limit on the left side for an orthographic camera
  31048. * In scene unit
  31049. */
  31050. orthoLeft: Nullable<number>;
  31051. /**
  31052. * Define the current limit on the right side for an orthographic camera
  31053. * In scene unit
  31054. */
  31055. orthoRight: Nullable<number>;
  31056. /**
  31057. * Define the current limit on the bottom side for an orthographic camera
  31058. * In scene unit
  31059. */
  31060. orthoBottom: Nullable<number>;
  31061. /**
  31062. * Define the current limit on the top side for an orthographic camera
  31063. * In scene unit
  31064. */
  31065. orthoTop: Nullable<number>;
  31066. /**
  31067. * Field Of View is set in Radians. (default is 0.8)
  31068. */
  31069. fov: number;
  31070. /**
  31071. * Define the minimum distance the camera can see from.
  31072. * This is important to note that the depth buffer are not infinite and the closer it starts
  31073. * the more your scene might encounter depth fighting issue.
  31074. */
  31075. minZ: number;
  31076. /**
  31077. * Define the maximum distance the camera can see to.
  31078. * This is important to note that the depth buffer are not infinite and the further it end
  31079. * the more your scene might encounter depth fighting issue.
  31080. */
  31081. maxZ: number;
  31082. /**
  31083. * Define the default inertia of the camera.
  31084. * This helps giving a smooth feeling to the camera movement.
  31085. */
  31086. inertia: number;
  31087. /**
  31088. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31089. */
  31090. mode: number;
  31091. /**
  31092. * Define wether the camera is intermediate.
  31093. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31094. */
  31095. isIntermediate: boolean;
  31096. /**
  31097. * Define the viewport of the camera.
  31098. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31099. */
  31100. viewport: Viewport;
  31101. /**
  31102. * Restricts the camera to viewing objects with the same layerMask.
  31103. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31104. */
  31105. layerMask: number;
  31106. /**
  31107. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31108. */
  31109. fovMode: number;
  31110. /**
  31111. * Rig mode of the camera.
  31112. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31113. * This is normally controlled byt the camera themselves as internal use.
  31114. */
  31115. cameraRigMode: number;
  31116. /**
  31117. * Defines the distance between both "eyes" in case of a RIG
  31118. */
  31119. interaxialDistance: number;
  31120. /**
  31121. * Defines if stereoscopic rendering is done side by side or over under.
  31122. */
  31123. isStereoscopicSideBySide: boolean;
  31124. /**
  31125. * 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
  31126. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31127. * else in the scene.
  31128. */
  31129. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31130. /**
  31131. * When set, the camera will render to this render target instead of the default canvas
  31132. */
  31133. outputRenderTarget: Nullable<RenderTargetTexture>;
  31134. /**
  31135. * Observable triggered when the camera view matrix has changed.
  31136. */
  31137. onViewMatrixChangedObservable: Observable<Camera>;
  31138. /**
  31139. * Observable triggered when the camera Projection matrix has changed.
  31140. */
  31141. onProjectionMatrixChangedObservable: Observable<Camera>;
  31142. /**
  31143. * Observable triggered when the inputs have been processed.
  31144. */
  31145. onAfterCheckInputsObservable: Observable<Camera>;
  31146. /**
  31147. * Observable triggered when reset has been called and applied to the camera.
  31148. */
  31149. onRestoreStateObservable: Observable<Camera>;
  31150. /** @hidden */
  31151. _cameraRigParams: any;
  31152. /** @hidden */
  31153. _rigCameras: Camera[];
  31154. /** @hidden */
  31155. _rigPostProcess: Nullable<PostProcess>;
  31156. protected _webvrViewMatrix: Matrix;
  31157. /** @hidden */
  31158. _skipRendering: boolean;
  31159. /** @hidden */
  31160. _projectionMatrix: Matrix;
  31161. /** @hidden */
  31162. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31163. /** @hidden */
  31164. _activeMeshes: SmartArray<AbstractMesh>;
  31165. protected _globalPosition: Vector3;
  31166. /** hidden */
  31167. _computedViewMatrix: Matrix;
  31168. private _doNotComputeProjectionMatrix;
  31169. private _transformMatrix;
  31170. private _frustumPlanes;
  31171. private _refreshFrustumPlanes;
  31172. private _storedFov;
  31173. private _stateStored;
  31174. /**
  31175. * Instantiates a new camera object.
  31176. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31177. * @see http://doc.babylonjs.com/features/cameras
  31178. * @param name Defines the name of the camera in the scene
  31179. * @param position Defines the position of the camera
  31180. * @param scene Defines the scene the camera belongs too
  31181. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31182. */
  31183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31184. /**
  31185. * Store current camera state (fov, position, etc..)
  31186. * @returns the camera
  31187. */
  31188. storeState(): Camera;
  31189. /**
  31190. * Restores the camera state values if it has been stored. You must call storeState() first
  31191. */
  31192. protected _restoreStateValues(): boolean;
  31193. /**
  31194. * Restored camera state. You must call storeState() first.
  31195. * @returns true if restored and false otherwise
  31196. */
  31197. restoreState(): boolean;
  31198. /**
  31199. * Gets the class name of the camera.
  31200. * @returns the class name
  31201. */
  31202. getClassName(): string;
  31203. /** @hidden */
  31204. readonly _isCamera: boolean;
  31205. /**
  31206. * Gets a string representation of the camera useful for debug purpose.
  31207. * @param fullDetails Defines that a more verboe level of logging is required
  31208. * @returns the string representation
  31209. */
  31210. toString(fullDetails?: boolean): string;
  31211. /**
  31212. * Gets the current world space position of the camera.
  31213. */
  31214. readonly globalPosition: Vector3;
  31215. /**
  31216. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31217. * @returns the active meshe list
  31218. */
  31219. getActiveMeshes(): SmartArray<AbstractMesh>;
  31220. /**
  31221. * Check wether a mesh is part of the current active mesh list of the camera
  31222. * @param mesh Defines the mesh to check
  31223. * @returns true if active, false otherwise
  31224. */
  31225. isActiveMesh(mesh: Mesh): boolean;
  31226. /**
  31227. * Is this camera ready to be used/rendered
  31228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31229. * @return true if the camera is ready
  31230. */
  31231. isReady(completeCheck?: boolean): boolean;
  31232. /** @hidden */
  31233. _initCache(): void;
  31234. /** @hidden */
  31235. _updateCache(ignoreParentClass?: boolean): void;
  31236. /** @hidden */
  31237. _isSynchronized(): boolean;
  31238. /** @hidden */
  31239. _isSynchronizedViewMatrix(): boolean;
  31240. /** @hidden */
  31241. _isSynchronizedProjectionMatrix(): boolean;
  31242. /**
  31243. * Attach the input controls to a specific dom element to get the input from.
  31244. * @param element Defines the element the controls should be listened from
  31245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31246. */
  31247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31248. /**
  31249. * Detach the current controls from the specified dom element.
  31250. * @param element Defines the element to stop listening the inputs from
  31251. */
  31252. detachControl(element: HTMLElement): void;
  31253. /**
  31254. * Update the camera state according to the different inputs gathered during the frame.
  31255. */
  31256. update(): void;
  31257. /** @hidden */
  31258. _checkInputs(): void;
  31259. /** @hidden */
  31260. readonly rigCameras: Camera[];
  31261. /**
  31262. * Gets the post process used by the rig cameras
  31263. */
  31264. readonly rigPostProcess: Nullable<PostProcess>;
  31265. /**
  31266. * Internal, gets the first post proces.
  31267. * @returns the first post process to be run on this camera.
  31268. */
  31269. _getFirstPostProcess(): Nullable<PostProcess>;
  31270. private _cascadePostProcessesToRigCams;
  31271. /**
  31272. * Attach a post process to the camera.
  31273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31274. * @param postProcess The post process to attach to the camera
  31275. * @param insertAt The position of the post process in case several of them are in use in the scene
  31276. * @returns the position the post process has been inserted at
  31277. */
  31278. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31279. /**
  31280. * Detach a post process to the camera.
  31281. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31282. * @param postProcess The post process to detach from the camera
  31283. */
  31284. detachPostProcess(postProcess: PostProcess): void;
  31285. /**
  31286. * Gets the current world matrix of the camera
  31287. */
  31288. getWorldMatrix(): Matrix;
  31289. /** @hidden */
  31290. _getViewMatrix(): Matrix;
  31291. /**
  31292. * Gets the current view matrix of the camera.
  31293. * @param force forces the camera to recompute the matrix without looking at the cached state
  31294. * @returns the view matrix
  31295. */
  31296. getViewMatrix(force?: boolean): Matrix;
  31297. /**
  31298. * Freeze the projection matrix.
  31299. * It will prevent the cache check of the camera projection compute and can speed up perf
  31300. * if no parameter of the camera are meant to change
  31301. * @param projection Defines manually a projection if necessary
  31302. */
  31303. freezeProjectionMatrix(projection?: Matrix): void;
  31304. /**
  31305. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31306. */
  31307. unfreezeProjectionMatrix(): void;
  31308. /**
  31309. * Gets the current projection matrix of the camera.
  31310. * @param force forces the camera to recompute the matrix without looking at the cached state
  31311. * @returns the projection matrix
  31312. */
  31313. getProjectionMatrix(force?: boolean): Matrix;
  31314. /**
  31315. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31316. * @returns a Matrix
  31317. */
  31318. getTransformationMatrix(): Matrix;
  31319. private _updateFrustumPlanes;
  31320. /**
  31321. * Checks if a cullable object (mesh...) is in the camera frustum
  31322. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31323. * @param target The object to check
  31324. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31325. * @returns true if the object is in frustum otherwise false
  31326. */
  31327. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31328. /**
  31329. * Checks if a cullable object (mesh...) is in the camera frustum
  31330. * Unlike isInFrustum this cheks the full bounding box
  31331. * @param target The object to check
  31332. * @returns true if the object is in frustum otherwise false
  31333. */
  31334. isCompletelyInFrustum(target: ICullable): boolean;
  31335. /**
  31336. * Gets a ray in the forward direction from the camera.
  31337. * @param length Defines the length of the ray to create
  31338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31339. * @param origin Defines the start point of the ray which defaults to the camera position
  31340. * @returns the forward ray
  31341. */
  31342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31343. /**
  31344. * Releases resources associated with this node.
  31345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31347. */
  31348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31349. /** @hidden */
  31350. _isLeftCamera: boolean;
  31351. /**
  31352. * Gets the left camera of a rig setup in case of Rigged Camera
  31353. */
  31354. readonly isLeftCamera: boolean;
  31355. /** @hidden */
  31356. _isRightCamera: boolean;
  31357. /**
  31358. * Gets the right camera of a rig setup in case of Rigged Camera
  31359. */
  31360. readonly isRightCamera: boolean;
  31361. /**
  31362. * Gets the left camera of a rig setup in case of Rigged Camera
  31363. */
  31364. readonly leftCamera: Nullable<FreeCamera>;
  31365. /**
  31366. * Gets the right camera of a rig setup in case of Rigged Camera
  31367. */
  31368. readonly rightCamera: Nullable<FreeCamera>;
  31369. /**
  31370. * Gets the left camera target of a rig setup in case of Rigged Camera
  31371. * @returns the target position
  31372. */
  31373. getLeftTarget(): Nullable<Vector3>;
  31374. /**
  31375. * Gets the right camera target of a rig setup in case of Rigged Camera
  31376. * @returns the target position
  31377. */
  31378. getRightTarget(): Nullable<Vector3>;
  31379. /**
  31380. * @hidden
  31381. */
  31382. setCameraRigMode(mode: number, rigParams: any): void;
  31383. /** @hidden */
  31384. static _setStereoscopicRigMode(camera: Camera): void;
  31385. /** @hidden */
  31386. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31387. /** @hidden */
  31388. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31389. /** @hidden */
  31390. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31391. /** @hidden */
  31392. _getVRProjectionMatrix(): Matrix;
  31393. protected _updateCameraRotationMatrix(): void;
  31394. protected _updateWebVRCameraRotationMatrix(): void;
  31395. /**
  31396. * This function MUST be overwritten by the different WebVR cameras available.
  31397. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31398. * @hidden
  31399. */
  31400. _getWebVRProjectionMatrix(): Matrix;
  31401. /**
  31402. * This function MUST be overwritten by the different WebVR cameras available.
  31403. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31404. * @hidden
  31405. */
  31406. _getWebVRViewMatrix(): Matrix;
  31407. /** @hidden */
  31408. setCameraRigParameter(name: string, value: any): void;
  31409. /**
  31410. * needs to be overridden by children so sub has required properties to be copied
  31411. * @hidden
  31412. */
  31413. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31414. /**
  31415. * May need to be overridden by children
  31416. * @hidden
  31417. */
  31418. _updateRigCameras(): void;
  31419. /** @hidden */
  31420. _setupInputs(): void;
  31421. /**
  31422. * Serialiaze the camera setup to a json represention
  31423. * @returns the JSON representation
  31424. */
  31425. serialize(): any;
  31426. /**
  31427. * Clones the current camera.
  31428. * @param name The cloned camera name
  31429. * @returns the cloned camera
  31430. */
  31431. clone(name: string): Camera;
  31432. /**
  31433. * Gets the direction of the camera relative to a given local axis.
  31434. * @param localAxis Defines the reference axis to provide a relative direction.
  31435. * @return the direction
  31436. */
  31437. getDirection(localAxis: Vector3): Vector3;
  31438. /**
  31439. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31440. * @param localAxis Defines the reference axis to provide a relative direction.
  31441. * @param result Defines the vector to store the result in
  31442. */
  31443. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31444. /**
  31445. * Gets a camera constructor for a given camera type
  31446. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31447. * @param name The name of the camera the result will be able to instantiate
  31448. * @param scene The scene the result will construct the camera in
  31449. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31450. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31451. * @returns a factory method to construc the camera
  31452. */
  31453. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31454. /**
  31455. * Compute the world matrix of the camera.
  31456. * @returns the camera workd matrix
  31457. */
  31458. computeWorldMatrix(): Matrix;
  31459. /**
  31460. * Parse a JSON and creates the camera from the parsed information
  31461. * @param parsedCamera The JSON to parse
  31462. * @param scene The scene to instantiate the camera in
  31463. * @returns the newly constructed camera
  31464. */
  31465. static Parse(parsedCamera: any, scene: Scene): Camera;
  31466. }
  31467. }
  31468. declare module "babylonjs/Misc/tools" {
  31469. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31470. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31471. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31472. import { Observable } from "babylonjs/Misc/observable";
  31473. import { DomManagement } from "babylonjs/Misc/domManagement";
  31474. import { WebRequest } from "babylonjs/Misc/webRequest";
  31475. import { Camera } from "babylonjs/Cameras/camera";
  31476. import { Engine } from "babylonjs/Engines/engine";
  31477. import { Animation } from "babylonjs/Animations/animation";
  31478. /**
  31479. * Interface for any object that can request an animation frame
  31480. */
  31481. export interface ICustomAnimationFrameRequester {
  31482. /**
  31483. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31484. */
  31485. renderFunction?: Function;
  31486. /**
  31487. * Called to request the next frame to render to
  31488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31489. */
  31490. requestAnimationFrame: Function;
  31491. /**
  31492. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31493. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31494. */
  31495. requestID?: number;
  31496. }
  31497. /**
  31498. * Interface containing an array of animations
  31499. */
  31500. export interface IAnimatable {
  31501. /**
  31502. * Array of animations
  31503. */
  31504. animations: Nullable<Array<Animation>>;
  31505. }
  31506. /** Interface used by value gradients (color, factor, ...) */
  31507. export interface IValueGradient {
  31508. /**
  31509. * Gets or sets the gradient value (between 0 and 1)
  31510. */
  31511. gradient: number;
  31512. }
  31513. /** Class used to store color4 gradient */
  31514. export class ColorGradient implements IValueGradient {
  31515. /**
  31516. * Gets or sets the gradient value (between 0 and 1)
  31517. */
  31518. gradient: number;
  31519. /**
  31520. * Gets or sets first associated color
  31521. */
  31522. color1: Color4;
  31523. /**
  31524. * Gets or sets second associated color
  31525. */
  31526. color2?: Color4;
  31527. /**
  31528. * Will get a color picked randomly between color1 and color2.
  31529. * If color2 is undefined then color1 will be used
  31530. * @param result defines the target Color4 to store the result in
  31531. */
  31532. getColorToRef(result: Color4): void;
  31533. }
  31534. /** Class used to store color 3 gradient */
  31535. export class Color3Gradient implements IValueGradient {
  31536. /**
  31537. * Gets or sets the gradient value (between 0 and 1)
  31538. */
  31539. gradient: number;
  31540. /**
  31541. * Gets or sets the associated color
  31542. */
  31543. color: Color3;
  31544. }
  31545. /** Class used to store factor gradient */
  31546. export class FactorGradient implements IValueGradient {
  31547. /**
  31548. * Gets or sets the gradient value (between 0 and 1)
  31549. */
  31550. gradient: number;
  31551. /**
  31552. * Gets or sets first associated factor
  31553. */
  31554. factor1: number;
  31555. /**
  31556. * Gets or sets second associated factor
  31557. */
  31558. factor2?: number;
  31559. /**
  31560. * Will get a number picked randomly between factor1 and factor2.
  31561. * If factor2 is undefined then factor1 will be used
  31562. * @returns the picked number
  31563. */
  31564. getFactor(): number;
  31565. }
  31566. /**
  31567. * @ignore
  31568. * Application error to support additional information when loading a file
  31569. */
  31570. export class LoadFileError extends Error {
  31571. /** defines the optional web request */
  31572. request?: WebRequest | undefined;
  31573. private static _setPrototypeOf;
  31574. /**
  31575. * Creates a new LoadFileError
  31576. * @param message defines the message of the error
  31577. * @param request defines the optional web request
  31578. */
  31579. constructor(message: string,
  31580. /** defines the optional web request */
  31581. request?: WebRequest | undefined);
  31582. }
  31583. /**
  31584. * Class used to define a retry strategy when error happens while loading assets
  31585. */
  31586. export class RetryStrategy {
  31587. /**
  31588. * Function used to defines an exponential back off strategy
  31589. * @param maxRetries defines the maximum number of retries (3 by default)
  31590. * @param baseInterval defines the interval between retries
  31591. * @returns the strategy function to use
  31592. */
  31593. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31594. }
  31595. /**
  31596. * File request interface
  31597. */
  31598. export interface IFileRequest {
  31599. /**
  31600. * Raised when the request is complete (success or error).
  31601. */
  31602. onCompleteObservable: Observable<IFileRequest>;
  31603. /**
  31604. * Aborts the request for a file.
  31605. */
  31606. abort: () => void;
  31607. }
  31608. /**
  31609. * Class containing a set of static utilities functions
  31610. */
  31611. export class Tools {
  31612. /**
  31613. * Gets or sets the base URL to use to load assets
  31614. */
  31615. static BaseUrl: string;
  31616. /**
  31617. * Enable/Disable Custom HTTP Request Headers globally.
  31618. * default = false
  31619. * @see CustomRequestHeaders
  31620. */
  31621. static UseCustomRequestHeaders: boolean;
  31622. /**
  31623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31624. * i.e. when loading files, where the server/service expects an Authorization header
  31625. */
  31626. static CustomRequestHeaders: {
  31627. [key: string]: string;
  31628. };
  31629. /**
  31630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31631. */
  31632. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31633. /**
  31634. * Default behaviour for cors in the application.
  31635. * It can be a string if the expected behavior is identical in the entire app.
  31636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31637. */
  31638. static CorsBehavior: string | ((url: string | string[]) => string);
  31639. /**
  31640. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31641. * @ignorenaming
  31642. */
  31643. static UseFallbackTexture: boolean;
  31644. /**
  31645. * Use this object to register external classes like custom textures or material
  31646. * to allow the laoders to instantiate them
  31647. */
  31648. static RegisteredExternalClasses: {
  31649. [key: string]: Object;
  31650. };
  31651. /**
  31652. * Texture content used if a texture cannot loaded
  31653. * @ignorenaming
  31654. */
  31655. static fallbackTexture: string;
  31656. /**
  31657. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31658. * @param u defines the coordinate on X axis
  31659. * @param v defines the coordinate on Y axis
  31660. * @param width defines the width of the source data
  31661. * @param height defines the height of the source data
  31662. * @param pixels defines the source byte array
  31663. * @param color defines the output color
  31664. */
  31665. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31666. /**
  31667. * Interpolates between a and b via alpha
  31668. * @param a The lower value (returned when alpha = 0)
  31669. * @param b The upper value (returned when alpha = 1)
  31670. * @param alpha The interpolation-factor
  31671. * @return The mixed value
  31672. */
  31673. static Mix(a: number, b: number, alpha: number): number;
  31674. /**
  31675. * Tries to instantiate a new object from a given class name
  31676. * @param className defines the class name to instantiate
  31677. * @returns the new object or null if the system was not able to do the instantiation
  31678. */
  31679. static Instantiate(className: string): any;
  31680. /**
  31681. * Provides a slice function that will work even on IE
  31682. * @param data defines the array to slice
  31683. * @param start defines the start of the data (optional)
  31684. * @param end defines the end of the data (optional)
  31685. * @returns the new sliced array
  31686. */
  31687. static Slice<T>(data: T, start?: number, end?: number): T;
  31688. /**
  31689. * Polyfill for setImmediate
  31690. * @param action defines the action to execute after the current execution block
  31691. */
  31692. static SetImmediate(action: () => void): void;
  31693. /**
  31694. * Function indicating if a number is an exponent of 2
  31695. * @param value defines the value to test
  31696. * @returns true if the value is an exponent of 2
  31697. */
  31698. static IsExponentOfTwo(value: number): boolean;
  31699. private static _tmpFloatArray;
  31700. /**
  31701. * Returns the nearest 32-bit single precision float representation of a Number
  31702. * @param value A Number. If the parameter is of a different type, it will get converted
  31703. * to a number or to NaN if it cannot be converted
  31704. * @returns number
  31705. */
  31706. static FloatRound(value: number): number;
  31707. /**
  31708. * Find the next highest power of two.
  31709. * @param x Number to start search from.
  31710. * @return Next highest power of two.
  31711. */
  31712. static CeilingPOT(x: number): number;
  31713. /**
  31714. * Find the next lowest power of two.
  31715. * @param x Number to start search from.
  31716. * @return Next lowest power of two.
  31717. */
  31718. static FloorPOT(x: number): number;
  31719. /**
  31720. * Find the nearest power of two.
  31721. * @param x Number to start search from.
  31722. * @return Next nearest power of two.
  31723. */
  31724. static NearestPOT(x: number): number;
  31725. /**
  31726. * Get the closest exponent of two
  31727. * @param value defines the value to approximate
  31728. * @param max defines the maximum value to return
  31729. * @param mode defines how to define the closest value
  31730. * @returns closest exponent of two of the given value
  31731. */
  31732. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31733. /**
  31734. * Extracts the filename from a path
  31735. * @param path defines the path to use
  31736. * @returns the filename
  31737. */
  31738. static GetFilename(path: string): string;
  31739. /**
  31740. * Extracts the "folder" part of a path (everything before the filename).
  31741. * @param uri The URI to extract the info from
  31742. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31743. * @returns The "folder" part of the path
  31744. */
  31745. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31746. /**
  31747. * Extracts text content from a DOM element hierarchy
  31748. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31749. */
  31750. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31751. /**
  31752. * Convert an angle in radians to degrees
  31753. * @param angle defines the angle to convert
  31754. * @returns the angle in degrees
  31755. */
  31756. static ToDegrees(angle: number): number;
  31757. /**
  31758. * Convert an angle in degrees to radians
  31759. * @param angle defines the angle to convert
  31760. * @returns the angle in radians
  31761. */
  31762. static ToRadians(angle: number): number;
  31763. /**
  31764. * Encode a buffer to a base64 string
  31765. * @param buffer defines the buffer to encode
  31766. * @returns the encoded string
  31767. */
  31768. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31769. /**
  31770. * Extracts minimum and maximum values from a list of indexed positions
  31771. * @param positions defines the positions to use
  31772. * @param indices defines the indices to the positions
  31773. * @param indexStart defines the start index
  31774. * @param indexCount defines the end index
  31775. * @param bias defines bias value to add to the result
  31776. * @return minimum and maximum values
  31777. */
  31778. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31779. minimum: Vector3;
  31780. maximum: Vector3;
  31781. };
  31782. /**
  31783. * Extracts minimum and maximum values from a list of positions
  31784. * @param positions defines the positions to use
  31785. * @param start defines the start index in the positions array
  31786. * @param count defines the number of positions to handle
  31787. * @param bias defines bias value to add to the result
  31788. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31789. * @return minimum and maximum values
  31790. */
  31791. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31792. minimum: Vector3;
  31793. maximum: Vector3;
  31794. };
  31795. /**
  31796. * Returns an array if obj is not an array
  31797. * @param obj defines the object to evaluate as an array
  31798. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31799. * @returns either obj directly if obj is an array or a new array containing obj
  31800. */
  31801. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31802. /**
  31803. * Gets the pointer prefix to use
  31804. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31805. */
  31806. static GetPointerPrefix(): string;
  31807. /**
  31808. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31809. * @param func - the function to be called
  31810. * @param requester - the object that will request the next frame. Falls back to window.
  31811. * @returns frame number
  31812. */
  31813. static QueueNewFrame(func: () => void, requester?: any): number;
  31814. /**
  31815. * Ask the browser to promote the current element to fullscreen rendering mode
  31816. * @param element defines the DOM element to promote
  31817. */
  31818. static RequestFullscreen(element: HTMLElement): void;
  31819. /**
  31820. * Asks the browser to exit fullscreen mode
  31821. */
  31822. static ExitFullscreen(): void;
  31823. /**
  31824. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31825. * @param url define the url we are trying
  31826. * @param element define the dom element where to configure the cors policy
  31827. */
  31828. static SetCorsBehavior(url: string | string[], element: {
  31829. crossOrigin: string | null;
  31830. }): void;
  31831. /**
  31832. * Removes unwanted characters from an url
  31833. * @param url defines the url to clean
  31834. * @returns the cleaned url
  31835. */
  31836. static CleanUrl(url: string): string;
  31837. /**
  31838. * Gets or sets a function used to pre-process url before using them to load assets
  31839. */
  31840. static PreprocessUrl: (url: string) => string;
  31841. /**
  31842. * Loads an image as an HTMLImageElement.
  31843. * @param input url string, ArrayBuffer, or Blob to load
  31844. * @param onLoad callback called when the image successfully loads
  31845. * @param onError callback called when the image fails to load
  31846. * @param offlineProvider offline provider for caching
  31847. * @returns the HTMLImageElement of the loaded image
  31848. */
  31849. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31850. /**
  31851. * Loads a file
  31852. * @param url url string, ArrayBuffer, or Blob to load
  31853. * @param onSuccess callback called when the file successfully loads
  31854. * @param onProgress callback called while file is loading (if the server supports this mode)
  31855. * @param offlineProvider defines the offline provider for caching
  31856. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31857. * @param onError callback called when the file fails to load
  31858. * @returns a file request object
  31859. */
  31860. 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;
  31861. /**
  31862. * Load a script (identified by an url). When the url returns, the
  31863. * content of this file is added into a new script element, attached to the DOM (body element)
  31864. * @param scriptUrl defines the url of the script to laod
  31865. * @param onSuccess defines the callback called when the script is loaded
  31866. * @param onError defines the callback to call if an error occurs
  31867. * @param scriptId defines the id of the script element
  31868. */
  31869. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31870. /**
  31871. * Load an asynchronous script (identified by an url). When the url returns, the
  31872. * content of this file is added into a new script element, attached to the DOM (body element)
  31873. * @param scriptUrl defines the url of the script to laod
  31874. * @param scriptId defines the id of the script element
  31875. * @returns a promise request object
  31876. */
  31877. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31878. /**
  31879. * Loads a file from a blob
  31880. * @param fileToLoad defines the blob to use
  31881. * @param callback defines the callback to call when data is loaded
  31882. * @param progressCallback defines the callback to call during loading process
  31883. * @returns a file request object
  31884. */
  31885. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31886. /**
  31887. * Loads a file
  31888. * @param fileToLoad defines the file to load
  31889. * @param callback defines the callback to call when data is loaded
  31890. * @param progressCallBack defines the callback to call during loading process
  31891. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31892. * @returns a file request object
  31893. */
  31894. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31895. /**
  31896. * Creates a data url from a given string content
  31897. * @param content defines the content to convert
  31898. * @returns the new data url link
  31899. */
  31900. static FileAsURL(content: string): string;
  31901. /**
  31902. * Format the given number to a specific decimal format
  31903. * @param value defines the number to format
  31904. * @param decimals defines the number of decimals to use
  31905. * @returns the formatted string
  31906. */
  31907. static Format(value: number, decimals?: number): string;
  31908. /**
  31909. * Checks if a given vector is inside a specific range
  31910. * @param v defines the vector to test
  31911. * @param min defines the minimum range
  31912. * @param max defines the maximum range
  31913. */
  31914. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31915. /**
  31916. * Tries to copy an object by duplicating every property
  31917. * @param source defines the source object
  31918. * @param destination defines the target object
  31919. * @param doNotCopyList defines a list of properties to avoid
  31920. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31921. */
  31922. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31923. /**
  31924. * Gets a boolean indicating if the given object has no own property
  31925. * @param obj defines the object to test
  31926. * @returns true if object has no own property
  31927. */
  31928. static IsEmpty(obj: any): boolean;
  31929. /**
  31930. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31931. * @param str Source string
  31932. * @param suffix Suffix to search for in the source string
  31933. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31934. */
  31935. static EndsWith(str: string, suffix: string): boolean;
  31936. /**
  31937. * Function used to register events at window level
  31938. * @param events defines the events to register
  31939. */
  31940. static RegisterTopRootEvents(events: {
  31941. name: string;
  31942. handler: Nullable<(e: FocusEvent) => any>;
  31943. }[]): void;
  31944. /**
  31945. * Function used to unregister events from window level
  31946. * @param events defines the events to unregister
  31947. */
  31948. static UnregisterTopRootEvents(events: {
  31949. name: string;
  31950. handler: Nullable<(e: FocusEvent) => any>;
  31951. }[]): void;
  31952. /**
  31953. * @ignore
  31954. */
  31955. static _ScreenshotCanvas: HTMLCanvasElement;
  31956. /**
  31957. * Dumps the current bound framebuffer
  31958. * @param width defines the rendering width
  31959. * @param height defines the rendering height
  31960. * @param engine defines the hosting engine
  31961. * @param successCallback defines the callback triggered once the data are available
  31962. * @param mimeType defines the mime type of the result
  31963. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31964. */
  31965. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31966. /**
  31967. * Converts the canvas data to blob.
  31968. * This acts as a polyfill for browsers not supporting the to blob function.
  31969. * @param canvas Defines the canvas to extract the data from
  31970. * @param successCallback Defines the callback triggered once the data are available
  31971. * @param mimeType Defines the mime type of the result
  31972. */
  31973. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31974. /**
  31975. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31976. * @param successCallback defines the callback triggered once the data are available
  31977. * @param mimeType defines the mime type of the result
  31978. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31979. */
  31980. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31981. /**
  31982. * Downloads a blob in the browser
  31983. * @param blob defines the blob to download
  31984. * @param fileName defines the name of the downloaded file
  31985. */
  31986. static Download(blob: Blob, fileName: string): void;
  31987. /**
  31988. * Captures a screenshot of the current rendering
  31989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31990. * @param engine defines the rendering engine
  31991. * @param camera defines the source camera
  31992. * @param size This parameter can be set to a single number or to an object with the
  31993. * following (optional) properties: precision, width, height. If a single number is passed,
  31994. * it will be used for both width and height. If an object is passed, the screenshot size
  31995. * will be derived from the parameters. The precision property is a multiplier allowing
  31996. * rendering at a higher or lower resolution
  31997. * @param successCallback defines the callback receives a single parameter which contains the
  31998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31999. * src parameter of an <img> to display it
  32000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32001. * Check your browser for supported MIME types
  32002. */
  32003. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32004. /**
  32005. * Generates an image screenshot from the specified camera.
  32006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32007. * @param engine The engine to use for rendering
  32008. * @param camera The camera to use for rendering
  32009. * @param size This parameter can be set to a single number or to an object with the
  32010. * following (optional) properties: precision, width, height. If a single number is passed,
  32011. * it will be used for both width and height. If an object is passed, the screenshot size
  32012. * will be derived from the parameters. The precision property is a multiplier allowing
  32013. * rendering at a higher or lower resolution
  32014. * @param successCallback The callback receives a single parameter which contains the
  32015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32016. * src parameter of an <img> to display it
  32017. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32018. * Check your browser for supported MIME types
  32019. * @param samples Texture samples (default: 1)
  32020. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32021. * @param fileName A name for for the downloaded file.
  32022. */
  32023. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32024. /**
  32025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32026. * Be aware Math.random() could cause collisions, but:
  32027. * "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"
  32028. * @returns a pseudo random id
  32029. */
  32030. static RandomId(): string;
  32031. /**
  32032. * Test if the given uri is a base64 string
  32033. * @param uri The uri to test
  32034. * @return True if the uri is a base64 string or false otherwise
  32035. */
  32036. static IsBase64(uri: string): boolean;
  32037. /**
  32038. * Decode the given base64 uri.
  32039. * @param uri The uri to decode
  32040. * @return The decoded base64 data.
  32041. */
  32042. static DecodeBase64(uri: string): ArrayBuffer;
  32043. /**
  32044. * Gets the absolute url.
  32045. * @param url the input url
  32046. * @return the absolute url
  32047. */
  32048. static GetAbsoluteUrl(url: string): string;
  32049. /**
  32050. * No log
  32051. */
  32052. static readonly NoneLogLevel: number;
  32053. /**
  32054. * Only message logs
  32055. */
  32056. static readonly MessageLogLevel: number;
  32057. /**
  32058. * Only warning logs
  32059. */
  32060. static readonly WarningLogLevel: number;
  32061. /**
  32062. * Only error logs
  32063. */
  32064. static readonly ErrorLogLevel: number;
  32065. /**
  32066. * All logs
  32067. */
  32068. static readonly AllLogLevel: number;
  32069. /**
  32070. * Gets a value indicating the number of loading errors
  32071. * @ignorenaming
  32072. */
  32073. static readonly errorsCount: number;
  32074. /**
  32075. * Callback called when a new log is added
  32076. */
  32077. static OnNewCacheEntry: (entry: string) => void;
  32078. /**
  32079. * Log a message to the console
  32080. * @param message defines the message to log
  32081. */
  32082. static Log(message: string): void;
  32083. /**
  32084. * Write a warning message to the console
  32085. * @param message defines the message to log
  32086. */
  32087. static Warn(message: string): void;
  32088. /**
  32089. * Write an error message to the console
  32090. * @param message defines the message to log
  32091. */
  32092. static Error(message: string): void;
  32093. /**
  32094. * Gets current log cache (list of logs)
  32095. */
  32096. static readonly LogCache: string;
  32097. /**
  32098. * Clears the log cache
  32099. */
  32100. static ClearLogCache(): void;
  32101. /**
  32102. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32103. */
  32104. static LogLevels: number;
  32105. /**
  32106. * Checks if the loaded document was accessed via `file:`-Protocol.
  32107. * @returns boolean
  32108. */
  32109. static IsFileURL(): boolean;
  32110. /**
  32111. * Checks if the window object exists
  32112. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32113. */
  32114. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32115. /**
  32116. * No performance log
  32117. */
  32118. static readonly PerformanceNoneLogLevel: number;
  32119. /**
  32120. * Use user marks to log performance
  32121. */
  32122. static readonly PerformanceUserMarkLogLevel: number;
  32123. /**
  32124. * Log performance to the console
  32125. */
  32126. static readonly PerformanceConsoleLogLevel: number;
  32127. private static _performance;
  32128. /**
  32129. * Sets the current performance log level
  32130. */
  32131. static PerformanceLogLevel: number;
  32132. private static _StartPerformanceCounterDisabled;
  32133. private static _EndPerformanceCounterDisabled;
  32134. private static _StartUserMark;
  32135. private static _EndUserMark;
  32136. private static _StartPerformanceConsole;
  32137. private static _EndPerformanceConsole;
  32138. /**
  32139. * Starts a performance counter
  32140. */
  32141. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32142. /**
  32143. * Ends a specific performance coutner
  32144. */
  32145. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32146. /**
  32147. * Gets either window.performance.now() if supported or Date.now() else
  32148. */
  32149. static readonly Now: number;
  32150. /**
  32151. * This method will return the name of the class used to create the instance of the given object.
  32152. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32153. * @param object the object to get the class name from
  32154. * @param isType defines if the object is actually a type
  32155. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32156. */
  32157. static GetClassName(object: any, isType?: boolean): string;
  32158. /**
  32159. * Gets the first element of an array satisfying a given predicate
  32160. * @param array defines the array to browse
  32161. * @param predicate defines the predicate to use
  32162. * @returns null if not found or the element
  32163. */
  32164. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32165. /**
  32166. * This method will return the name of the full name of the class, including its owning module (if any).
  32167. * 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).
  32168. * @param object the object to get the class name from
  32169. * @param isType defines if the object is actually a type
  32170. * @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.
  32171. * @ignorenaming
  32172. */
  32173. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32174. /**
  32175. * Returns a promise that resolves after the given amount of time.
  32176. * @param delay Number of milliseconds to delay
  32177. * @returns Promise that resolves after the given amount of time
  32178. */
  32179. static DelayAsync(delay: number): Promise<void>;
  32180. /**
  32181. * Gets the current gradient from an array of IValueGradient
  32182. * @param ratio defines the current ratio to get
  32183. * @param gradients defines the array of IValueGradient
  32184. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32185. */
  32186. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32187. }
  32188. /**
  32189. * This class is used to track a performance counter which is number based.
  32190. * The user has access to many properties which give statistics of different nature.
  32191. *
  32192. * The implementer can track two kinds of Performance Counter: time and count.
  32193. * 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.
  32194. * 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.
  32195. */
  32196. export class PerfCounter {
  32197. /**
  32198. * Gets or sets a global boolean to turn on and off all the counters
  32199. */
  32200. static Enabled: boolean;
  32201. /**
  32202. * Returns the smallest value ever
  32203. */
  32204. readonly min: number;
  32205. /**
  32206. * Returns the biggest value ever
  32207. */
  32208. readonly max: number;
  32209. /**
  32210. * Returns the average value since the performance counter is running
  32211. */
  32212. readonly average: number;
  32213. /**
  32214. * Returns the average value of the last second the counter was monitored
  32215. */
  32216. readonly lastSecAverage: number;
  32217. /**
  32218. * Returns the current value
  32219. */
  32220. readonly current: number;
  32221. /**
  32222. * Gets the accumulated total
  32223. */
  32224. readonly total: number;
  32225. /**
  32226. * Gets the total value count
  32227. */
  32228. readonly count: number;
  32229. /**
  32230. * Creates a new counter
  32231. */
  32232. constructor();
  32233. /**
  32234. * Call this method to start monitoring a new frame.
  32235. * 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.
  32236. */
  32237. fetchNewFrame(): void;
  32238. /**
  32239. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32240. * @param newCount the count value to add to the monitored count
  32241. * @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.
  32242. */
  32243. addCount(newCount: number, fetchResult: boolean): void;
  32244. /**
  32245. * Start monitoring this performance counter
  32246. */
  32247. beginMonitoring(): void;
  32248. /**
  32249. * Compute the time lapsed since the previous beginMonitoring() call.
  32250. * @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
  32251. */
  32252. endMonitoring(newFrame?: boolean): void;
  32253. private _fetchResult;
  32254. private _startMonitoringTime;
  32255. private _min;
  32256. private _max;
  32257. private _average;
  32258. private _current;
  32259. private _totalValueCount;
  32260. private _totalAccumulated;
  32261. private _lastSecAverage;
  32262. private _lastSecAccumulated;
  32263. private _lastSecTime;
  32264. private _lastSecValueCount;
  32265. }
  32266. /**
  32267. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32268. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32269. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32270. * @param name The name of the class, case should be preserved
  32271. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32272. */
  32273. export function className(name: string, module?: string): (target: Object) => void;
  32274. /**
  32275. * An implementation of a loop for asynchronous functions.
  32276. */
  32277. export class AsyncLoop {
  32278. /**
  32279. * Defines the number of iterations for the loop
  32280. */
  32281. iterations: number;
  32282. /**
  32283. * Defines the current index of the loop.
  32284. */
  32285. index: number;
  32286. private _done;
  32287. private _fn;
  32288. private _successCallback;
  32289. /**
  32290. * Constructor.
  32291. * @param iterations the number of iterations.
  32292. * @param func the function to run each iteration
  32293. * @param successCallback the callback that will be called upon succesful execution
  32294. * @param offset starting offset.
  32295. */
  32296. constructor(
  32297. /**
  32298. * Defines the number of iterations for the loop
  32299. */
  32300. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32301. /**
  32302. * Execute the next iteration. Must be called after the last iteration was finished.
  32303. */
  32304. executeNext(): void;
  32305. /**
  32306. * Break the loop and run the success callback.
  32307. */
  32308. breakLoop(): void;
  32309. /**
  32310. * Create and run an async loop.
  32311. * @param iterations the number of iterations.
  32312. * @param fn the function to run each iteration
  32313. * @param successCallback the callback that will be called upon succesful execution
  32314. * @param offset starting offset.
  32315. * @returns the created async loop object
  32316. */
  32317. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32318. /**
  32319. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32320. * @param iterations total number of iterations
  32321. * @param syncedIterations number of synchronous iterations in each async iteration.
  32322. * @param fn the function to call each iteration.
  32323. * @param callback a success call back that will be called when iterating stops.
  32324. * @param breakFunction a break condition (optional)
  32325. * @param timeout timeout settings for the setTimeout function. default - 0.
  32326. * @returns the created async loop object
  32327. */
  32328. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32329. }
  32330. }
  32331. declare module "babylonjs/Collisions/collisionCoordinator" {
  32332. import { Nullable } from "babylonjs/types";
  32333. import { Scene } from "babylonjs/scene";
  32334. import { Vector3 } from "babylonjs/Maths/math";
  32335. import { Collider } from "babylonjs/Collisions/collider";
  32336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32337. /** @hidden */
  32338. export interface ICollisionCoordinator {
  32339. createCollider(): Collider;
  32340. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32341. init(scene: Scene): void;
  32342. }
  32343. /** @hidden */
  32344. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32345. private _scene;
  32346. private _scaledPosition;
  32347. private _scaledVelocity;
  32348. private _finalPosition;
  32349. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32350. createCollider(): Collider;
  32351. init(scene: Scene): void;
  32352. private _collideWithWorld;
  32353. }
  32354. }
  32355. declare module "babylonjs/Inputs/scene.inputManager" {
  32356. import { Nullable } from "babylonjs/types";
  32357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32358. import { Vector2 } from "babylonjs/Maths/math";
  32359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32360. import { Scene } from "babylonjs/scene";
  32361. /**
  32362. * Class used to manage all inputs for the scene.
  32363. */
  32364. export class InputManager {
  32365. /** The distance in pixel that you have to move to prevent some events */
  32366. static DragMovementThreshold: number;
  32367. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32368. static LongPressDelay: number;
  32369. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32370. static DoubleClickDelay: number;
  32371. /** If you need to check double click without raising a single click at first click, enable this flag */
  32372. static ExclusiveDoubleClickMode: boolean;
  32373. private _wheelEventName;
  32374. private _onPointerMove;
  32375. private _onPointerDown;
  32376. private _onPointerUp;
  32377. private _initClickEvent;
  32378. private _initActionManager;
  32379. private _delayedSimpleClick;
  32380. private _delayedSimpleClickTimeout;
  32381. private _previousDelayedSimpleClickTimeout;
  32382. private _meshPickProceed;
  32383. private _previousButtonPressed;
  32384. private _currentPickResult;
  32385. private _previousPickResult;
  32386. private _totalPointersPressed;
  32387. private _doubleClickOccured;
  32388. private _pointerOverMesh;
  32389. private _pickedDownMesh;
  32390. private _pickedUpMesh;
  32391. private _pointerX;
  32392. private _pointerY;
  32393. private _unTranslatedPointerX;
  32394. private _unTranslatedPointerY;
  32395. private _startingPointerPosition;
  32396. private _previousStartingPointerPosition;
  32397. private _startingPointerTime;
  32398. private _previousStartingPointerTime;
  32399. private _pointerCaptures;
  32400. private _onKeyDown;
  32401. private _onKeyUp;
  32402. private _onCanvasFocusObserver;
  32403. private _onCanvasBlurObserver;
  32404. private _scene;
  32405. /**
  32406. * Creates a new InputManager
  32407. * @param scene defines the hosting scene
  32408. */
  32409. constructor(scene: Scene);
  32410. /**
  32411. * Gets the mesh that is currently under the pointer
  32412. */
  32413. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32414. /**
  32415. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32416. */
  32417. readonly unTranslatedPointer: Vector2;
  32418. /**
  32419. * Gets or sets the current on-screen X position of the pointer
  32420. */
  32421. pointerX: number;
  32422. /**
  32423. * Gets or sets the current on-screen Y position of the pointer
  32424. */
  32425. pointerY: number;
  32426. private _updatePointerPosition;
  32427. private _processPointerMove;
  32428. private _setRayOnPointerInfo;
  32429. private _checkPrePointerObservable;
  32430. /**
  32431. * Use this method to simulate a pointer move on a mesh
  32432. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32433. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32434. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32435. */
  32436. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32437. /**
  32438. * Use this method to simulate a pointer down on a mesh
  32439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32442. */
  32443. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32444. private _processPointerDown;
  32445. /** @hidden */
  32446. _isPointerSwiping(): boolean;
  32447. /**
  32448. * Use this method to simulate a pointer up on a mesh
  32449. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32450. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32451. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32452. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32453. */
  32454. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32455. private _processPointerUp;
  32456. /**
  32457. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32458. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32459. * @returns true if the pointer was captured
  32460. */
  32461. isPointerCaptured(pointerId?: number): boolean;
  32462. /**
  32463. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32464. * @param attachUp defines if you want to attach events to pointerup
  32465. * @param attachDown defines if you want to attach events to pointerdown
  32466. * @param attachMove defines if you want to attach events to pointermove
  32467. */
  32468. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32469. /**
  32470. * Detaches all event handlers
  32471. */
  32472. detachControl(): void;
  32473. /**
  32474. * Force the value of meshUnderPointer
  32475. * @param mesh defines the mesh to use
  32476. */
  32477. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32478. /**
  32479. * Gets the mesh under the pointer
  32480. * @returns a Mesh or null if no mesh is under the pointer
  32481. */
  32482. getPointerOverMesh(): Nullable<AbstractMesh>;
  32483. }
  32484. }
  32485. declare module "babylonjs/Animations/animationGroup" {
  32486. import { Animatable } from "babylonjs/Animations/animatable";
  32487. import { Animation } from "babylonjs/Animations/animation";
  32488. import { Scene, IDisposable } from "babylonjs/scene";
  32489. import { Observable } from "babylonjs/Misc/observable";
  32490. import { Nullable } from "babylonjs/types";
  32491. /**
  32492. * This class defines the direct association between an animation and a target
  32493. */
  32494. export class TargetedAnimation {
  32495. /**
  32496. * Animation to perform
  32497. */
  32498. animation: Animation;
  32499. /**
  32500. * Target to animate
  32501. */
  32502. target: any;
  32503. }
  32504. /**
  32505. * Use this class to create coordinated animations on multiple targets
  32506. */
  32507. export class AnimationGroup implements IDisposable {
  32508. /** The name of the animation group */
  32509. name: string;
  32510. private _scene;
  32511. private _targetedAnimations;
  32512. private _animatables;
  32513. private _from;
  32514. private _to;
  32515. private _isStarted;
  32516. private _isPaused;
  32517. private _speedRatio;
  32518. /**
  32519. * Gets or sets the unique id of the node
  32520. */
  32521. uniqueId: number;
  32522. /**
  32523. * This observable will notify when one animation have ended
  32524. */
  32525. onAnimationEndObservable: Observable<TargetedAnimation>;
  32526. /**
  32527. * Observer raised when one animation loops
  32528. */
  32529. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32530. /**
  32531. * This observable will notify when all animations have ended.
  32532. */
  32533. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32534. /**
  32535. * This observable will notify when all animations have paused.
  32536. */
  32537. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32538. /**
  32539. * This observable will notify when all animations are playing.
  32540. */
  32541. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32542. /**
  32543. * Gets the first frame
  32544. */
  32545. readonly from: number;
  32546. /**
  32547. * Gets the last frame
  32548. */
  32549. readonly to: number;
  32550. /**
  32551. * Define if the animations are started
  32552. */
  32553. readonly isStarted: boolean;
  32554. /**
  32555. * Gets a value indicating that the current group is playing
  32556. */
  32557. readonly isPlaying: boolean;
  32558. /**
  32559. * Gets or sets the speed ratio to use for all animations
  32560. */
  32561. /**
  32562. * Gets or sets the speed ratio to use for all animations
  32563. */
  32564. speedRatio: number;
  32565. /**
  32566. * Gets the targeted animations for this animation group
  32567. */
  32568. readonly targetedAnimations: Array<TargetedAnimation>;
  32569. /**
  32570. * returning the list of animatables controlled by this animation group.
  32571. */
  32572. readonly animatables: Array<Animatable>;
  32573. /**
  32574. * Instantiates a new Animation Group.
  32575. * This helps managing several animations at once.
  32576. * @see http://doc.babylonjs.com/how_to/group
  32577. * @param name Defines the name of the group
  32578. * @param scene Defines the scene the group belongs to
  32579. */
  32580. constructor(
  32581. /** The name of the animation group */
  32582. name: string, scene?: Nullable<Scene>);
  32583. /**
  32584. * Add an animation (with its target) in the group
  32585. * @param animation defines the animation we want to add
  32586. * @param target defines the target of the animation
  32587. * @returns the TargetedAnimation object
  32588. */
  32589. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32590. /**
  32591. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32592. * It can add constant keys at begin or end
  32593. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32594. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32595. * @returns the animation group
  32596. */
  32597. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32598. /**
  32599. * Start all animations on given targets
  32600. * @param loop defines if animations must loop
  32601. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32602. * @param from defines the from key (optional)
  32603. * @param to defines the to key (optional)
  32604. * @returns the current animation group
  32605. */
  32606. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32607. /**
  32608. * Pause all animations
  32609. * @returns the animation group
  32610. */
  32611. pause(): AnimationGroup;
  32612. /**
  32613. * Play all animations to initial state
  32614. * This function will start() the animations if they were not started or will restart() them if they were paused
  32615. * @param loop defines if animations must loop
  32616. * @returns the animation group
  32617. */
  32618. play(loop?: boolean): AnimationGroup;
  32619. /**
  32620. * Reset all animations to initial state
  32621. * @returns the animation group
  32622. */
  32623. reset(): AnimationGroup;
  32624. /**
  32625. * Restart animations from key 0
  32626. * @returns the animation group
  32627. */
  32628. restart(): AnimationGroup;
  32629. /**
  32630. * Stop all animations
  32631. * @returns the animation group
  32632. */
  32633. stop(): AnimationGroup;
  32634. /**
  32635. * Set animation weight for all animatables
  32636. * @param weight defines the weight to use
  32637. * @return the animationGroup
  32638. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32639. */
  32640. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32641. /**
  32642. * Synchronize and normalize all animatables with a source animatable
  32643. * @param root defines the root animatable to synchronize with
  32644. * @return the animationGroup
  32645. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32646. */
  32647. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32648. /**
  32649. * Goes to a specific frame in this animation group
  32650. * @param frame the frame number to go to
  32651. * @return the animationGroup
  32652. */
  32653. goToFrame(frame: number): AnimationGroup;
  32654. /**
  32655. * Dispose all associated resources
  32656. */
  32657. dispose(): void;
  32658. private _checkAnimationGroupEnded;
  32659. /**
  32660. * Clone the current animation group and returns a copy
  32661. * @param newName defines the name of the new group
  32662. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32663. * @returns the new aniamtion group
  32664. */
  32665. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32666. /**
  32667. * Returns a new AnimationGroup object parsed from the source provided.
  32668. * @param parsedAnimationGroup defines the source
  32669. * @param scene defines the scene that will receive the animationGroup
  32670. * @returns a new AnimationGroup
  32671. */
  32672. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32673. /**
  32674. * Returns the string "AnimationGroup"
  32675. * @returns "AnimationGroup"
  32676. */
  32677. getClassName(): string;
  32678. /**
  32679. * Creates a detailled string about the object
  32680. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32681. * @returns a string representing the object
  32682. */
  32683. toString(fullDetails?: boolean): string;
  32684. }
  32685. }
  32686. declare module "babylonjs/scene" {
  32687. import { Nullable } from "babylonjs/types";
  32688. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32689. import { Observable } from "babylonjs/Misc/observable";
  32690. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32691. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32692. import { Geometry } from "babylonjs/Meshes/geometry";
  32693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32696. import { Mesh } from "babylonjs/Meshes/mesh";
  32697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32698. import { Bone } from "babylonjs/Bones/bone";
  32699. import { Skeleton } from "babylonjs/Bones/skeleton";
  32700. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32701. import { Camera } from "babylonjs/Cameras/camera";
  32702. import { AbstractScene } from "babylonjs/abstractScene";
  32703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32705. import { Material } from "babylonjs/Materials/material";
  32706. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32707. import { Effect } from "babylonjs/Materials/effect";
  32708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32709. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32710. import { Light } from "babylonjs/Lights/light";
  32711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32712. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32713. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32714. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32716. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32717. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32718. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32719. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32720. import { Engine } from "babylonjs/Engines/engine";
  32721. import { Node } from "babylonjs/node";
  32722. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32723. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32724. import { WebRequest } from "babylonjs/Misc/webRequest";
  32725. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32726. import { Ray } from "babylonjs/Culling/ray";
  32727. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32728. import { Animation } from "babylonjs/Animations/animation";
  32729. import { Animatable } from "babylonjs/Animations/animatable";
  32730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32731. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32732. import { Collider } from "babylonjs/Collisions/collider";
  32733. /**
  32734. * Define an interface for all classes that will hold resources
  32735. */
  32736. export interface IDisposable {
  32737. /**
  32738. * Releases all held resources
  32739. */
  32740. dispose(): void;
  32741. }
  32742. /** Interface defining initialization parameters for Scene class */
  32743. export interface SceneOptions {
  32744. /**
  32745. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32746. * It will improve performance when the number of geometries becomes important.
  32747. */
  32748. useGeometryUniqueIdsMap?: boolean;
  32749. /**
  32750. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32751. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32752. */
  32753. useMaterialMeshMap?: boolean;
  32754. /**
  32755. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32756. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32757. */
  32758. useClonedMeshhMap?: boolean;
  32759. }
  32760. /**
  32761. * Represents a scene to be rendered by the engine.
  32762. * @see http://doc.babylonjs.com/features/scene
  32763. */
  32764. export class Scene extends AbstractScene implements IAnimatable {
  32765. private static _uniqueIdCounter;
  32766. /** The fog is deactivated */
  32767. static readonly FOGMODE_NONE: number;
  32768. /** The fog density is following an exponential function */
  32769. static readonly FOGMODE_EXP: number;
  32770. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32771. static readonly FOGMODE_EXP2: number;
  32772. /** The fog density is following a linear function. */
  32773. static readonly FOGMODE_LINEAR: number;
  32774. /**
  32775. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32776. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32777. */
  32778. static MinDeltaTime: number;
  32779. /**
  32780. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32782. */
  32783. static MaxDeltaTime: number;
  32784. /**
  32785. * Factory used to create the default material.
  32786. * @param name The name of the material to create
  32787. * @param scene The scene to create the material for
  32788. * @returns The default material
  32789. */
  32790. static DefaultMaterialFactory(scene: Scene): Material;
  32791. /**
  32792. * Factory used to create the a collision coordinator.
  32793. * @returns The collision coordinator
  32794. */
  32795. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32796. /** @hidden */
  32797. _inputManager: InputManager;
  32798. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32799. cameraToUseForPointers: Nullable<Camera>;
  32800. /** @hidden */
  32801. readonly _isScene: boolean;
  32802. /**
  32803. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32804. */
  32805. autoClear: boolean;
  32806. /**
  32807. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32808. */
  32809. autoClearDepthAndStencil: boolean;
  32810. /**
  32811. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32812. */
  32813. clearColor: Color4;
  32814. /**
  32815. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32816. */
  32817. ambientColor: Color3;
  32818. /**
  32819. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32820. * It should only be one of the following (if not the default embedded one):
  32821. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32822. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32823. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32824. * The material properties need to be setup according to the type of texture in use.
  32825. */
  32826. environmentBRDFTexture: BaseTexture;
  32827. /** @hidden */
  32828. protected _environmentTexture: Nullable<BaseTexture>;
  32829. /**
  32830. * Texture used in all pbr material as the reflection texture.
  32831. * As in the majority of the scene they are the same (exception for multi room and so on),
  32832. * this is easier to reference from here than from all the materials.
  32833. */
  32834. /**
  32835. * Texture used in all pbr material as the reflection texture.
  32836. * As in the majority of the scene they are the same (exception for multi room and so on),
  32837. * this is easier to set here than in all the materials.
  32838. */
  32839. environmentTexture: Nullable<BaseTexture>;
  32840. /** @hidden */
  32841. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32842. /**
  32843. * Default image processing configuration used either in the rendering
  32844. * Forward main pass or through the imageProcessingPostProcess if present.
  32845. * As in the majority of the scene they are the same (exception for multi camera),
  32846. * this is easier to reference from here than from all the materials and post process.
  32847. *
  32848. * No setter as we it is a shared configuration, you can set the values instead.
  32849. */
  32850. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32851. private _forceWireframe;
  32852. /**
  32853. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32854. */
  32855. forceWireframe: boolean;
  32856. private _forcePointsCloud;
  32857. /**
  32858. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32859. */
  32860. forcePointsCloud: boolean;
  32861. /**
  32862. * Gets or sets the active clipplane 1
  32863. */
  32864. clipPlane: Nullable<Plane>;
  32865. /**
  32866. * Gets or sets the active clipplane 2
  32867. */
  32868. clipPlane2: Nullable<Plane>;
  32869. /**
  32870. * Gets or sets the active clipplane 3
  32871. */
  32872. clipPlane3: Nullable<Plane>;
  32873. /**
  32874. * Gets or sets the active clipplane 4
  32875. */
  32876. clipPlane4: Nullable<Plane>;
  32877. /**
  32878. * Gets or sets a boolean indicating if animations are enabled
  32879. */
  32880. animationsEnabled: boolean;
  32881. private _animationPropertiesOverride;
  32882. /**
  32883. * Gets or sets the animation properties override
  32884. */
  32885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32886. /**
  32887. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32888. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32889. */
  32890. useConstantAnimationDeltaTime: boolean;
  32891. /**
  32892. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32893. * Please note that it requires to run a ray cast through the scene on every frame
  32894. */
  32895. constantlyUpdateMeshUnderPointer: boolean;
  32896. /**
  32897. * Defines the HTML cursor to use when hovering over interactive elements
  32898. */
  32899. hoverCursor: string;
  32900. /**
  32901. * Defines the HTML default cursor to use (empty by default)
  32902. */
  32903. defaultCursor: string;
  32904. /**
  32905. * This is used to call preventDefault() on pointer down
  32906. * in order to block unwanted artifacts like system double clicks
  32907. */
  32908. preventDefaultOnPointerDown: boolean;
  32909. /**
  32910. * This is used to call preventDefault() on pointer up
  32911. * in order to block unwanted artifacts like system double clicks
  32912. */
  32913. preventDefaultOnPointerUp: boolean;
  32914. /**
  32915. * Gets or sets user defined metadata
  32916. */
  32917. metadata: any;
  32918. /**
  32919. * For internal use only. Please do not use.
  32920. */
  32921. reservedDataStore: any;
  32922. /**
  32923. * Gets the name of the plugin used to load this scene (null by default)
  32924. */
  32925. loadingPluginName: string;
  32926. /**
  32927. * Use this array to add regular expressions used to disable offline support for specific urls
  32928. */
  32929. disableOfflineSupportExceptionRules: RegExp[];
  32930. /**
  32931. * An event triggered when the scene is disposed.
  32932. */
  32933. onDisposeObservable: Observable<Scene>;
  32934. private _onDisposeObserver;
  32935. /** Sets a function to be executed when this scene is disposed. */
  32936. onDispose: () => void;
  32937. /**
  32938. * An event triggered before rendering the scene (right after animations and physics)
  32939. */
  32940. onBeforeRenderObservable: Observable<Scene>;
  32941. private _onBeforeRenderObserver;
  32942. /** Sets a function to be executed before rendering this scene */
  32943. beforeRender: Nullable<() => void>;
  32944. /**
  32945. * An event triggered after rendering the scene
  32946. */
  32947. onAfterRenderObservable: Observable<Scene>;
  32948. private _onAfterRenderObserver;
  32949. /** Sets a function to be executed after rendering this scene */
  32950. afterRender: Nullable<() => void>;
  32951. /**
  32952. * An event triggered before animating the scene
  32953. */
  32954. onBeforeAnimationsObservable: Observable<Scene>;
  32955. /**
  32956. * An event triggered after animations processing
  32957. */
  32958. onAfterAnimationsObservable: Observable<Scene>;
  32959. /**
  32960. * An event triggered before draw calls are ready to be sent
  32961. */
  32962. onBeforeDrawPhaseObservable: Observable<Scene>;
  32963. /**
  32964. * An event triggered after draw calls have been sent
  32965. */
  32966. onAfterDrawPhaseObservable: Observable<Scene>;
  32967. /**
  32968. * An event triggered when the scene is ready
  32969. */
  32970. onReadyObservable: Observable<Scene>;
  32971. /**
  32972. * An event triggered before rendering a camera
  32973. */
  32974. onBeforeCameraRenderObservable: Observable<Camera>;
  32975. private _onBeforeCameraRenderObserver;
  32976. /** Sets a function to be executed before rendering a camera*/
  32977. beforeCameraRender: () => void;
  32978. /**
  32979. * An event triggered after rendering a camera
  32980. */
  32981. onAfterCameraRenderObservable: Observable<Camera>;
  32982. private _onAfterCameraRenderObserver;
  32983. /** Sets a function to be executed after rendering a camera*/
  32984. afterCameraRender: () => void;
  32985. /**
  32986. * An event triggered when active meshes evaluation is about to start
  32987. */
  32988. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32989. /**
  32990. * An event triggered when active meshes evaluation is done
  32991. */
  32992. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32993. /**
  32994. * An event triggered when particles rendering is about to start
  32995. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32996. */
  32997. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32998. /**
  32999. * An event triggered when particles rendering is done
  33000. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33001. */
  33002. onAfterParticlesRenderingObservable: Observable<Scene>;
  33003. /**
  33004. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33005. */
  33006. onDataLoadedObservable: Observable<Scene>;
  33007. /**
  33008. * An event triggered when a camera is created
  33009. */
  33010. onNewCameraAddedObservable: Observable<Camera>;
  33011. /**
  33012. * An event triggered when a camera is removed
  33013. */
  33014. onCameraRemovedObservable: Observable<Camera>;
  33015. /**
  33016. * An event triggered when a light is created
  33017. */
  33018. onNewLightAddedObservable: Observable<Light>;
  33019. /**
  33020. * An event triggered when a light is removed
  33021. */
  33022. onLightRemovedObservable: Observable<Light>;
  33023. /**
  33024. * An event triggered when a geometry is created
  33025. */
  33026. onNewGeometryAddedObservable: Observable<Geometry>;
  33027. /**
  33028. * An event triggered when a geometry is removed
  33029. */
  33030. onGeometryRemovedObservable: Observable<Geometry>;
  33031. /**
  33032. * An event triggered when a transform node is created
  33033. */
  33034. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33035. /**
  33036. * An event triggered when a transform node is removed
  33037. */
  33038. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33039. /**
  33040. * An event triggered when a mesh is created
  33041. */
  33042. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33043. /**
  33044. * An event triggered when a mesh is removed
  33045. */
  33046. onMeshRemovedObservable: Observable<AbstractMesh>;
  33047. /**
  33048. * An event triggered when a skeleton is created
  33049. */
  33050. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33051. /**
  33052. * An event triggered when a skeleton is removed
  33053. */
  33054. onSkeletonRemovedObservable: Observable<Skeleton>;
  33055. /**
  33056. * An event triggered when a material is created
  33057. */
  33058. onNewMaterialAddedObservable: Observable<Material>;
  33059. /**
  33060. * An event triggered when a material is removed
  33061. */
  33062. onMaterialRemovedObservable: Observable<Material>;
  33063. /**
  33064. * An event triggered when a texture is created
  33065. */
  33066. onNewTextureAddedObservable: Observable<BaseTexture>;
  33067. /**
  33068. * An event triggered when a texture is removed
  33069. */
  33070. onTextureRemovedObservable: Observable<BaseTexture>;
  33071. /**
  33072. * An event triggered when render targets are about to be rendered
  33073. * Can happen multiple times per frame.
  33074. */
  33075. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33076. /**
  33077. * An event triggered when render targets were rendered.
  33078. * Can happen multiple times per frame.
  33079. */
  33080. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33081. /**
  33082. * An event triggered before calculating deterministic simulation step
  33083. */
  33084. onBeforeStepObservable: Observable<Scene>;
  33085. /**
  33086. * An event triggered after calculating deterministic simulation step
  33087. */
  33088. onAfterStepObservable: Observable<Scene>;
  33089. /**
  33090. * An event triggered when the activeCamera property is updated
  33091. */
  33092. onActiveCameraChanged: Observable<Scene>;
  33093. /**
  33094. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33095. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33096. * 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)
  33097. */
  33098. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33099. /**
  33100. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33102. * 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)
  33103. */
  33104. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33105. /**
  33106. * This Observable will when a mesh has been imported into the scene.
  33107. */
  33108. onMeshImportedObservable: Observable<AbstractMesh>;
  33109. /**
  33110. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33111. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33112. */
  33113. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33114. /** @hidden */
  33115. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33116. /**
  33117. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33118. */
  33119. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33120. /**
  33121. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33122. */
  33123. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33124. /**
  33125. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33126. */
  33127. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33128. /** Callback called when a pointer move is detected */
  33129. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33130. /** Callback called when a pointer down is detected */
  33131. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33132. /** Callback called when a pointer up is detected */
  33133. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33134. /** Callback called when a pointer pick is detected */
  33135. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33136. /**
  33137. * 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).
  33138. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33139. */
  33140. onPrePointerObservable: Observable<PointerInfoPre>;
  33141. /**
  33142. * Observable event triggered each time an input event is received from the rendering canvas
  33143. */
  33144. onPointerObservable: Observable<PointerInfo>;
  33145. /**
  33146. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33147. */
  33148. readonly unTranslatedPointer: Vector2;
  33149. /**
  33150. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33151. */
  33152. static DragMovementThreshold: number;
  33153. /**
  33154. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33155. */
  33156. static LongPressDelay: number;
  33157. /**
  33158. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33159. */
  33160. static DoubleClickDelay: number;
  33161. /** If you need to check double click without raising a single click at first click, enable this flag */
  33162. static ExclusiveDoubleClickMode: boolean;
  33163. /** @hidden */
  33164. _mirroredCameraPosition: Nullable<Vector3>;
  33165. /**
  33166. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33167. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33168. */
  33169. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33170. /**
  33171. * Observable event triggered each time an keyboard event is received from the hosting window
  33172. */
  33173. onKeyboardObservable: Observable<KeyboardInfo>;
  33174. private _useRightHandedSystem;
  33175. /**
  33176. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33177. */
  33178. useRightHandedSystem: boolean;
  33179. private _timeAccumulator;
  33180. private _currentStepId;
  33181. private _currentInternalStep;
  33182. /**
  33183. * Sets the step Id used by deterministic lock step
  33184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33185. * @param newStepId defines the step Id
  33186. */
  33187. setStepId(newStepId: number): void;
  33188. /**
  33189. * Gets the step Id used by deterministic lock step
  33190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33191. * @returns the step Id
  33192. */
  33193. getStepId(): number;
  33194. /**
  33195. * Gets the internal step used by deterministic lock step
  33196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33197. * @returns the internal step
  33198. */
  33199. getInternalStep(): number;
  33200. private _fogEnabled;
  33201. /**
  33202. * Gets or sets a boolean indicating if fog is enabled on this scene
  33203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33204. * (Default is true)
  33205. */
  33206. fogEnabled: boolean;
  33207. private _fogMode;
  33208. /**
  33209. * Gets or sets the fog mode to use
  33210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33211. * | mode | value |
  33212. * | --- | --- |
  33213. * | FOGMODE_NONE | 0 |
  33214. * | FOGMODE_EXP | 1 |
  33215. * | FOGMODE_EXP2 | 2 |
  33216. * | FOGMODE_LINEAR | 3 |
  33217. */
  33218. fogMode: number;
  33219. /**
  33220. * Gets or sets the fog color to use
  33221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33222. * (Default is Color3(0.2, 0.2, 0.3))
  33223. */
  33224. fogColor: Color3;
  33225. /**
  33226. * Gets or sets the fog density to use
  33227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33228. * (Default is 0.1)
  33229. */
  33230. fogDensity: number;
  33231. /**
  33232. * Gets or sets the fog start distance to use
  33233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33234. * (Default is 0)
  33235. */
  33236. fogStart: number;
  33237. /**
  33238. * Gets or sets the fog end distance to use
  33239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33240. * (Default is 1000)
  33241. */
  33242. fogEnd: number;
  33243. private _shadowsEnabled;
  33244. /**
  33245. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33246. */
  33247. shadowsEnabled: boolean;
  33248. private _lightsEnabled;
  33249. /**
  33250. * Gets or sets a boolean indicating if lights are enabled on this scene
  33251. */
  33252. lightsEnabled: boolean;
  33253. /** All of the active cameras added to this scene. */
  33254. activeCameras: Camera[];
  33255. /** @hidden */
  33256. _activeCamera: Nullable<Camera>;
  33257. /** Gets or sets the current active camera */
  33258. activeCamera: Nullable<Camera>;
  33259. private _defaultMaterial;
  33260. /** The default material used on meshes when no material is affected */
  33261. /** The default material used on meshes when no material is affected */
  33262. defaultMaterial: Material;
  33263. private _texturesEnabled;
  33264. /**
  33265. * Gets or sets a boolean indicating if textures are enabled on this scene
  33266. */
  33267. texturesEnabled: boolean;
  33268. /**
  33269. * Gets or sets a boolean indicating if particles are enabled on this scene
  33270. */
  33271. particlesEnabled: boolean;
  33272. /**
  33273. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33274. */
  33275. spritesEnabled: boolean;
  33276. private _skeletonsEnabled;
  33277. /**
  33278. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33279. */
  33280. skeletonsEnabled: boolean;
  33281. /**
  33282. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33283. */
  33284. lensFlaresEnabled: boolean;
  33285. /**
  33286. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33288. */
  33289. collisionsEnabled: boolean;
  33290. private _collisionCoordinator;
  33291. /** @hidden */
  33292. readonly collisionCoordinator: ICollisionCoordinator;
  33293. /**
  33294. * Defines the gravity applied to this scene (used only for collisions)
  33295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33296. */
  33297. gravity: Vector3;
  33298. /**
  33299. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33300. */
  33301. postProcessesEnabled: boolean;
  33302. /**
  33303. * The list of postprocesses added to the scene
  33304. */
  33305. postProcesses: PostProcess[];
  33306. /**
  33307. * Gets the current postprocess manager
  33308. */
  33309. postProcessManager: PostProcessManager;
  33310. /**
  33311. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33312. */
  33313. renderTargetsEnabled: boolean;
  33314. /**
  33315. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33316. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33317. */
  33318. dumpNextRenderTargets: boolean;
  33319. /**
  33320. * The list of user defined render targets added to the scene
  33321. */
  33322. customRenderTargets: RenderTargetTexture[];
  33323. /**
  33324. * Defines if texture loading must be delayed
  33325. * If true, textures will only be loaded when they need to be rendered
  33326. */
  33327. useDelayedTextureLoading: boolean;
  33328. /**
  33329. * Gets the list of meshes imported to the scene through SceneLoader
  33330. */
  33331. importedMeshesFiles: String[];
  33332. /**
  33333. * Gets or sets a boolean indicating if probes are enabled on this scene
  33334. */
  33335. probesEnabled: boolean;
  33336. /**
  33337. * Gets or sets the current offline provider to use to store scene data
  33338. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33339. */
  33340. offlineProvider: IOfflineProvider;
  33341. /**
  33342. * Gets or sets the action manager associated with the scene
  33343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33344. */
  33345. actionManager: AbstractActionManager;
  33346. private _meshesForIntersections;
  33347. /**
  33348. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33349. */
  33350. proceduralTexturesEnabled: boolean;
  33351. private _engine;
  33352. private _totalVertices;
  33353. /** @hidden */
  33354. _activeIndices: PerfCounter;
  33355. /** @hidden */
  33356. _activeParticles: PerfCounter;
  33357. /** @hidden */
  33358. _activeBones: PerfCounter;
  33359. private _animationRatio;
  33360. /** @hidden */
  33361. _animationTimeLast: number;
  33362. /** @hidden */
  33363. _animationTime: number;
  33364. /**
  33365. * Gets or sets a general scale for animation speed
  33366. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33367. */
  33368. animationTimeScale: number;
  33369. /** @hidden */
  33370. _cachedMaterial: Nullable<Material>;
  33371. /** @hidden */
  33372. _cachedEffect: Nullable<Effect>;
  33373. /** @hidden */
  33374. _cachedVisibility: Nullable<number>;
  33375. private _renderId;
  33376. private _frameId;
  33377. private _executeWhenReadyTimeoutId;
  33378. private _intermediateRendering;
  33379. private _viewUpdateFlag;
  33380. private _projectionUpdateFlag;
  33381. /** @hidden */
  33382. _toBeDisposed: Nullable<IDisposable>[];
  33383. private _activeRequests;
  33384. /** @hidden */
  33385. _pendingData: any[];
  33386. private _isDisposed;
  33387. /**
  33388. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33389. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33390. */
  33391. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33392. private _activeMeshes;
  33393. private _processedMaterials;
  33394. private _renderTargets;
  33395. /** @hidden */
  33396. _activeParticleSystems: SmartArray<IParticleSystem>;
  33397. private _activeSkeletons;
  33398. private _softwareSkinnedMeshes;
  33399. private _renderingManager;
  33400. /** @hidden */
  33401. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33402. private _transformMatrix;
  33403. private _sceneUbo;
  33404. /** @hidden */
  33405. _viewMatrix: Matrix;
  33406. private _projectionMatrix;
  33407. /** @hidden */
  33408. _forcedViewPosition: Nullable<Vector3>;
  33409. /** @hidden */
  33410. _frustumPlanes: Plane[];
  33411. /**
  33412. * Gets the list of frustum planes (built from the active camera)
  33413. */
  33414. readonly frustumPlanes: Plane[];
  33415. /**
  33416. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33417. * This is useful if there are more lights that the maximum simulteanous authorized
  33418. */
  33419. requireLightSorting: boolean;
  33420. /** @hidden */
  33421. readonly useMaterialMeshMap: boolean;
  33422. /** @hidden */
  33423. readonly useClonedMeshhMap: boolean;
  33424. private _externalData;
  33425. private _uid;
  33426. /**
  33427. * @hidden
  33428. * Backing store of defined scene components.
  33429. */
  33430. _components: ISceneComponent[];
  33431. /**
  33432. * @hidden
  33433. * Backing store of defined scene components.
  33434. */
  33435. _serializableComponents: ISceneSerializableComponent[];
  33436. /**
  33437. * List of components to register on the next registration step.
  33438. */
  33439. private _transientComponents;
  33440. /**
  33441. * Registers the transient components if needed.
  33442. */
  33443. private _registerTransientComponents;
  33444. /**
  33445. * @hidden
  33446. * Add a component to the scene.
  33447. * Note that the ccomponent could be registered on th next frame if this is called after
  33448. * the register component stage.
  33449. * @param component Defines the component to add to the scene
  33450. */
  33451. _addComponent(component: ISceneComponent): void;
  33452. /**
  33453. * @hidden
  33454. * Gets a component from the scene.
  33455. * @param name defines the name of the component to retrieve
  33456. * @returns the component or null if not present
  33457. */
  33458. _getComponent(name: string): Nullable<ISceneComponent>;
  33459. /**
  33460. * @hidden
  33461. * Defines the actions happening before camera updates.
  33462. */
  33463. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33464. /**
  33465. * @hidden
  33466. * Defines the actions happening before clear the canvas.
  33467. */
  33468. _beforeClearStage: Stage<SimpleStageAction>;
  33469. /**
  33470. * @hidden
  33471. * Defines the actions when collecting render targets for the frame.
  33472. */
  33473. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33474. /**
  33475. * @hidden
  33476. * Defines the actions happening for one camera in the frame.
  33477. */
  33478. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33479. /**
  33480. * @hidden
  33481. * Defines the actions happening during the per mesh ready checks.
  33482. */
  33483. _isReadyForMeshStage: Stage<MeshStageAction>;
  33484. /**
  33485. * @hidden
  33486. * Defines the actions happening before evaluate active mesh checks.
  33487. */
  33488. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33489. /**
  33490. * @hidden
  33491. * Defines the actions happening during the evaluate sub mesh checks.
  33492. */
  33493. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33494. /**
  33495. * @hidden
  33496. * Defines the actions happening during the active mesh stage.
  33497. */
  33498. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33499. /**
  33500. * @hidden
  33501. * Defines the actions happening during the per camera render target step.
  33502. */
  33503. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33504. /**
  33505. * @hidden
  33506. * Defines the actions happening just before the active camera is drawing.
  33507. */
  33508. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33509. /**
  33510. * @hidden
  33511. * Defines the actions happening just before a render target is drawing.
  33512. */
  33513. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33514. /**
  33515. * @hidden
  33516. * Defines the actions happening just before a rendering group is drawing.
  33517. */
  33518. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33519. /**
  33520. * @hidden
  33521. * Defines the actions happening just before a mesh is drawing.
  33522. */
  33523. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33524. /**
  33525. * @hidden
  33526. * Defines the actions happening just after a mesh has been drawn.
  33527. */
  33528. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33529. /**
  33530. * @hidden
  33531. * Defines the actions happening just after a rendering group has been drawn.
  33532. */
  33533. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33534. /**
  33535. * @hidden
  33536. * Defines the actions happening just after the active camera has been drawn.
  33537. */
  33538. _afterCameraDrawStage: Stage<CameraStageAction>;
  33539. /**
  33540. * @hidden
  33541. * Defines the actions happening just after a render target has been drawn.
  33542. */
  33543. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33544. /**
  33545. * @hidden
  33546. * Defines the actions happening just after rendering all cameras and computing intersections.
  33547. */
  33548. _afterRenderStage: Stage<SimpleStageAction>;
  33549. /**
  33550. * @hidden
  33551. * Defines the actions happening when a pointer move event happens.
  33552. */
  33553. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33554. /**
  33555. * @hidden
  33556. * Defines the actions happening when a pointer down event happens.
  33557. */
  33558. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33559. /**
  33560. * @hidden
  33561. * Defines the actions happening when a pointer up event happens.
  33562. */
  33563. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33564. /**
  33565. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33566. */
  33567. private geometriesByUniqueId;
  33568. /**
  33569. * Creates a new Scene
  33570. * @param engine defines the engine to use to render this scene
  33571. * @param options defines the scene options
  33572. */
  33573. constructor(engine: Engine, options?: SceneOptions);
  33574. /**
  33575. * Gets a string idenfifying the name of the class
  33576. * @returns "Scene" string
  33577. */
  33578. getClassName(): string;
  33579. private _defaultMeshCandidates;
  33580. /**
  33581. * @hidden
  33582. */
  33583. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33584. private _defaultSubMeshCandidates;
  33585. /**
  33586. * @hidden
  33587. */
  33588. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33589. /**
  33590. * Sets the default candidate providers for the scene.
  33591. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33592. * and getCollidingSubMeshCandidates to their default function
  33593. */
  33594. setDefaultCandidateProviders(): void;
  33595. /**
  33596. * Gets the mesh that is currently under the pointer
  33597. */
  33598. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33599. /**
  33600. * Gets or sets the current on-screen X position of the pointer
  33601. */
  33602. pointerX: number;
  33603. /**
  33604. * Gets or sets the current on-screen Y position of the pointer
  33605. */
  33606. pointerY: number;
  33607. /**
  33608. * Gets the cached material (ie. the latest rendered one)
  33609. * @returns the cached material
  33610. */
  33611. getCachedMaterial(): Nullable<Material>;
  33612. /**
  33613. * Gets the cached effect (ie. the latest rendered one)
  33614. * @returns the cached effect
  33615. */
  33616. getCachedEffect(): Nullable<Effect>;
  33617. /**
  33618. * Gets the cached visibility state (ie. the latest rendered one)
  33619. * @returns the cached visibility state
  33620. */
  33621. getCachedVisibility(): Nullable<number>;
  33622. /**
  33623. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33624. * @param material defines the current material
  33625. * @param effect defines the current effect
  33626. * @param visibility defines the current visibility state
  33627. * @returns true if one parameter is not cached
  33628. */
  33629. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33630. /**
  33631. * Gets the engine associated with the scene
  33632. * @returns an Engine
  33633. */
  33634. getEngine(): Engine;
  33635. /**
  33636. * Gets the total number of vertices rendered per frame
  33637. * @returns the total number of vertices rendered per frame
  33638. */
  33639. getTotalVertices(): number;
  33640. /**
  33641. * Gets the performance counter for total vertices
  33642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33643. */
  33644. readonly totalVerticesPerfCounter: PerfCounter;
  33645. /**
  33646. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33647. * @returns the total number of active indices rendered per frame
  33648. */
  33649. getActiveIndices(): number;
  33650. /**
  33651. * Gets the performance counter for active indices
  33652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33653. */
  33654. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33655. /**
  33656. * Gets the total number of active particles rendered per frame
  33657. * @returns the total number of active particles rendered per frame
  33658. */
  33659. getActiveParticles(): number;
  33660. /**
  33661. * Gets the performance counter for active particles
  33662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33663. */
  33664. readonly activeParticlesPerfCounter: PerfCounter;
  33665. /**
  33666. * Gets the total number of active bones rendered per frame
  33667. * @returns the total number of active bones rendered per frame
  33668. */
  33669. getActiveBones(): number;
  33670. /**
  33671. * Gets the performance counter for active bones
  33672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33673. */
  33674. readonly activeBonesPerfCounter: PerfCounter;
  33675. /**
  33676. * Gets the array of active meshes
  33677. * @returns an array of AbstractMesh
  33678. */
  33679. getActiveMeshes(): SmartArray<AbstractMesh>;
  33680. /**
  33681. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33682. * @returns a number
  33683. */
  33684. getAnimationRatio(): number;
  33685. /**
  33686. * Gets an unique Id for the current render phase
  33687. * @returns a number
  33688. */
  33689. getRenderId(): number;
  33690. /**
  33691. * Gets an unique Id for the current frame
  33692. * @returns a number
  33693. */
  33694. getFrameId(): number;
  33695. /** Call this function if you want to manually increment the render Id*/
  33696. incrementRenderId(): void;
  33697. private _createUbo;
  33698. /**
  33699. * Use this method to simulate a pointer move on a mesh
  33700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33703. * @returns the current scene
  33704. */
  33705. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33706. /**
  33707. * Use this method to simulate a pointer down on a mesh
  33708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33711. * @returns the current scene
  33712. */
  33713. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33714. /**
  33715. * Use this method to simulate a pointer up on a mesh
  33716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33719. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33720. * @returns the current scene
  33721. */
  33722. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33723. /**
  33724. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33725. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33726. * @returns true if the pointer was captured
  33727. */
  33728. isPointerCaptured(pointerId?: number): boolean;
  33729. /**
  33730. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33731. * @param attachUp defines if you want to attach events to pointerup
  33732. * @param attachDown defines if you want to attach events to pointerdown
  33733. * @param attachMove defines if you want to attach events to pointermove
  33734. */
  33735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33736. /** Detaches all event handlers*/
  33737. detachControl(): void;
  33738. /**
  33739. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33740. * Delay loaded resources are not taking in account
  33741. * @return true if all required resources are ready
  33742. */
  33743. isReady(): boolean;
  33744. /** Resets all cached information relative to material (including effect and visibility) */
  33745. resetCachedMaterial(): void;
  33746. /**
  33747. * Registers a function to be called before every frame render
  33748. * @param func defines the function to register
  33749. */
  33750. registerBeforeRender(func: () => void): void;
  33751. /**
  33752. * Unregisters a function called before every frame render
  33753. * @param func defines the function to unregister
  33754. */
  33755. unregisterBeforeRender(func: () => void): void;
  33756. /**
  33757. * Registers a function to be called after every frame render
  33758. * @param func defines the function to register
  33759. */
  33760. registerAfterRender(func: () => void): void;
  33761. /**
  33762. * Unregisters a function called after every frame render
  33763. * @param func defines the function to unregister
  33764. */
  33765. unregisterAfterRender(func: () => void): void;
  33766. private _executeOnceBeforeRender;
  33767. /**
  33768. * The provided function will run before render once and will be disposed afterwards.
  33769. * A timeout delay can be provided so that the function will be executed in N ms.
  33770. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33771. * @param func The function to be executed.
  33772. * @param timeout optional delay in ms
  33773. */
  33774. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33775. /** @hidden */
  33776. _addPendingData(data: any): void;
  33777. /** @hidden */
  33778. _removePendingData(data: any): void;
  33779. /**
  33780. * Returns the number of items waiting to be loaded
  33781. * @returns the number of items waiting to be loaded
  33782. */
  33783. getWaitingItemsCount(): number;
  33784. /**
  33785. * Returns a boolean indicating if the scene is still loading data
  33786. */
  33787. readonly isLoading: boolean;
  33788. /**
  33789. * Registers a function to be executed when the scene is ready
  33790. * @param {Function} func - the function to be executed
  33791. */
  33792. executeWhenReady(func: () => void): void;
  33793. /**
  33794. * Returns a promise that resolves when the scene is ready
  33795. * @returns A promise that resolves when the scene is ready
  33796. */
  33797. whenReadyAsync(): Promise<void>;
  33798. /** @hidden */
  33799. _checkIsReady(): void;
  33800. /**
  33801. * Gets all animatable attached to the scene
  33802. */
  33803. readonly animatables: Animatable[];
  33804. /**
  33805. * Resets the last animation time frame.
  33806. * Useful to override when animations start running when loading a scene for the first time.
  33807. */
  33808. resetLastAnimationTimeFrame(): void;
  33809. /**
  33810. * Gets the current view matrix
  33811. * @returns a Matrix
  33812. */
  33813. getViewMatrix(): Matrix;
  33814. /**
  33815. * Gets the current projection matrix
  33816. * @returns a Matrix
  33817. */
  33818. getProjectionMatrix(): Matrix;
  33819. /**
  33820. * Gets the current transform matrix
  33821. * @returns a Matrix made of View * Projection
  33822. */
  33823. getTransformMatrix(): Matrix;
  33824. /**
  33825. * Sets the current transform matrix
  33826. * @param viewL defines the View matrix to use
  33827. * @param projectionL defines the Projection matrix to use
  33828. * @param viewR defines the right View matrix to use (if provided)
  33829. * @param projectionR defines the right Projection matrix to use (if provided)
  33830. */
  33831. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33832. /**
  33833. * Gets the uniform buffer used to store scene data
  33834. * @returns a UniformBuffer
  33835. */
  33836. getSceneUniformBuffer(): UniformBuffer;
  33837. /**
  33838. * Gets an unique (relatively to the current scene) Id
  33839. * @returns an unique number for the scene
  33840. */
  33841. getUniqueId(): number;
  33842. /**
  33843. * Add a mesh to the list of scene's meshes
  33844. * @param newMesh defines the mesh to add
  33845. * @param recursive if all child meshes should also be added to the scene
  33846. */
  33847. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33848. /**
  33849. * Remove a mesh for the list of scene's meshes
  33850. * @param toRemove defines the mesh to remove
  33851. * @param recursive if all child meshes should also be removed from the scene
  33852. * @returns the index where the mesh was in the mesh list
  33853. */
  33854. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33855. /**
  33856. * Add a transform node to the list of scene's transform nodes
  33857. * @param newTransformNode defines the transform node to add
  33858. */
  33859. addTransformNode(newTransformNode: TransformNode): void;
  33860. /**
  33861. * Remove a transform node for the list of scene's transform nodes
  33862. * @param toRemove defines the transform node to remove
  33863. * @returns the index where the transform node was in the transform node list
  33864. */
  33865. removeTransformNode(toRemove: TransformNode): number;
  33866. /**
  33867. * Remove a skeleton for the list of scene's skeletons
  33868. * @param toRemove defines the skeleton to remove
  33869. * @returns the index where the skeleton was in the skeleton list
  33870. */
  33871. removeSkeleton(toRemove: Skeleton): number;
  33872. /**
  33873. * Remove a morph target for the list of scene's morph targets
  33874. * @param toRemove defines the morph target to remove
  33875. * @returns the index where the morph target was in the morph target list
  33876. */
  33877. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33878. /**
  33879. * Remove a light for the list of scene's lights
  33880. * @param toRemove defines the light to remove
  33881. * @returns the index where the light was in the light list
  33882. */
  33883. removeLight(toRemove: Light): number;
  33884. /**
  33885. * Remove a camera for the list of scene's cameras
  33886. * @param toRemove defines the camera to remove
  33887. * @returns the index where the camera was in the camera list
  33888. */
  33889. removeCamera(toRemove: Camera): number;
  33890. /**
  33891. * Remove a particle system for the list of scene's particle systems
  33892. * @param toRemove defines the particle system to remove
  33893. * @returns the index where the particle system was in the particle system list
  33894. */
  33895. removeParticleSystem(toRemove: IParticleSystem): number;
  33896. /**
  33897. * Remove a animation for the list of scene's animations
  33898. * @param toRemove defines the animation to remove
  33899. * @returns the index where the animation was in the animation list
  33900. */
  33901. removeAnimation(toRemove: Animation): number;
  33902. /**
  33903. * Will stop the animation of the given target
  33904. * @param target - the target
  33905. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33906. * @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)
  33907. */
  33908. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33909. /**
  33910. * Removes the given animation group from this scene.
  33911. * @param toRemove The animation group to remove
  33912. * @returns The index of the removed animation group
  33913. */
  33914. removeAnimationGroup(toRemove: AnimationGroup): number;
  33915. /**
  33916. * Removes the given multi-material from this scene.
  33917. * @param toRemove The multi-material to remove
  33918. * @returns The index of the removed multi-material
  33919. */
  33920. removeMultiMaterial(toRemove: MultiMaterial): number;
  33921. /**
  33922. * Removes the given material from this scene.
  33923. * @param toRemove The material to remove
  33924. * @returns The index of the removed material
  33925. */
  33926. removeMaterial(toRemove: Material): number;
  33927. /**
  33928. * Removes the given action manager from this scene.
  33929. * @param toRemove The action manager to remove
  33930. * @returns The index of the removed action manager
  33931. */
  33932. removeActionManager(toRemove: AbstractActionManager): number;
  33933. /**
  33934. * Removes the given texture from this scene.
  33935. * @param toRemove The texture to remove
  33936. * @returns The index of the removed texture
  33937. */
  33938. removeTexture(toRemove: BaseTexture): number;
  33939. /**
  33940. * Adds the given light to this scene
  33941. * @param newLight The light to add
  33942. */
  33943. addLight(newLight: Light): void;
  33944. /**
  33945. * Sorts the list list based on light priorities
  33946. */
  33947. sortLightsByPriority(): void;
  33948. /**
  33949. * Adds the given camera to this scene
  33950. * @param newCamera The camera to add
  33951. */
  33952. addCamera(newCamera: Camera): void;
  33953. /**
  33954. * Adds the given skeleton to this scene
  33955. * @param newSkeleton The skeleton to add
  33956. */
  33957. addSkeleton(newSkeleton: Skeleton): void;
  33958. /**
  33959. * Adds the given particle system to this scene
  33960. * @param newParticleSystem The particle system to add
  33961. */
  33962. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33963. /**
  33964. * Adds the given animation to this scene
  33965. * @param newAnimation The animation to add
  33966. */
  33967. addAnimation(newAnimation: Animation): void;
  33968. /**
  33969. * Adds the given animation group to this scene.
  33970. * @param newAnimationGroup The animation group to add
  33971. */
  33972. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33973. /**
  33974. * Adds the given multi-material to this scene
  33975. * @param newMultiMaterial The multi-material to add
  33976. */
  33977. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33978. /**
  33979. * Adds the given material to this scene
  33980. * @param newMaterial The material to add
  33981. */
  33982. addMaterial(newMaterial: Material): void;
  33983. /**
  33984. * Adds the given morph target to this scene
  33985. * @param newMorphTargetManager The morph target to add
  33986. */
  33987. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33988. /**
  33989. * Adds the given geometry to this scene
  33990. * @param newGeometry The geometry to add
  33991. */
  33992. addGeometry(newGeometry: Geometry): void;
  33993. /**
  33994. * Adds the given action manager to this scene
  33995. * @param newActionManager The action manager to add
  33996. */
  33997. addActionManager(newActionManager: AbstractActionManager): void;
  33998. /**
  33999. * Adds the given texture to this scene.
  34000. * @param newTexture The texture to add
  34001. */
  34002. addTexture(newTexture: BaseTexture): void;
  34003. /**
  34004. * Switch active camera
  34005. * @param newCamera defines the new active camera
  34006. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34007. */
  34008. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34009. /**
  34010. * sets the active camera of the scene using its ID
  34011. * @param id defines the camera's ID
  34012. * @return the new active camera or null if none found.
  34013. */
  34014. setActiveCameraByID(id: string): Nullable<Camera>;
  34015. /**
  34016. * sets the active camera of the scene using its name
  34017. * @param name defines the camera's name
  34018. * @returns the new active camera or null if none found.
  34019. */
  34020. setActiveCameraByName(name: string): Nullable<Camera>;
  34021. /**
  34022. * get an animation group using its name
  34023. * @param name defines the material's name
  34024. * @return the animation group or null if none found.
  34025. */
  34026. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34027. /**
  34028. * Get a material using its unique id
  34029. * @param uniqueId defines the material's unique id
  34030. * @return the material or null if none found.
  34031. */
  34032. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34033. /**
  34034. * get a material using its id
  34035. * @param id defines the material's ID
  34036. * @return the material or null if none found.
  34037. */
  34038. getMaterialByID(id: string): Nullable<Material>;
  34039. /**
  34040. * Gets a material using its name
  34041. * @param name defines the material's name
  34042. * @return the material or null if none found.
  34043. */
  34044. getMaterialByName(name: string): Nullable<Material>;
  34045. /**
  34046. * Gets a camera using its id
  34047. * @param id defines the id to look for
  34048. * @returns the camera or null if not found
  34049. */
  34050. getCameraByID(id: string): Nullable<Camera>;
  34051. /**
  34052. * Gets a camera using its unique id
  34053. * @param uniqueId defines the unique id to look for
  34054. * @returns the camera or null if not found
  34055. */
  34056. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34057. /**
  34058. * Gets a camera using its name
  34059. * @param name defines the camera's name
  34060. * @return the camera or null if none found.
  34061. */
  34062. getCameraByName(name: string): Nullable<Camera>;
  34063. /**
  34064. * Gets a bone using its id
  34065. * @param id defines the bone's id
  34066. * @return the bone or null if not found
  34067. */
  34068. getBoneByID(id: string): Nullable<Bone>;
  34069. /**
  34070. * Gets a bone using its id
  34071. * @param name defines the bone's name
  34072. * @return the bone or null if not found
  34073. */
  34074. getBoneByName(name: string): Nullable<Bone>;
  34075. /**
  34076. * Gets a light node using its name
  34077. * @param name defines the the light's name
  34078. * @return the light or null if none found.
  34079. */
  34080. getLightByName(name: string): Nullable<Light>;
  34081. /**
  34082. * Gets a light node using its id
  34083. * @param id defines the light's id
  34084. * @return the light or null if none found.
  34085. */
  34086. getLightByID(id: string): Nullable<Light>;
  34087. /**
  34088. * Gets a light node using its scene-generated unique ID
  34089. * @param uniqueId defines the light's unique id
  34090. * @return the light or null if none found.
  34091. */
  34092. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34093. /**
  34094. * Gets a particle system by id
  34095. * @param id defines the particle system id
  34096. * @return the corresponding system or null if none found
  34097. */
  34098. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34099. /**
  34100. * Gets a geometry using its ID
  34101. * @param id defines the geometry's id
  34102. * @return the geometry or null if none found.
  34103. */
  34104. getGeometryByID(id: string): Nullable<Geometry>;
  34105. private _getGeometryByUniqueID;
  34106. /**
  34107. * Add a new geometry to this scene
  34108. * @param geometry defines the geometry to be added to the scene.
  34109. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34110. * @return a boolean defining if the geometry was added or not
  34111. */
  34112. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34113. /**
  34114. * Removes an existing geometry
  34115. * @param geometry defines the geometry to be removed from the scene
  34116. * @return a boolean defining if the geometry was removed or not
  34117. */
  34118. removeGeometry(geometry: Geometry): boolean;
  34119. /**
  34120. * Gets the list of geometries attached to the scene
  34121. * @returns an array of Geometry
  34122. */
  34123. getGeometries(): Geometry[];
  34124. /**
  34125. * Gets the first added mesh found of a given ID
  34126. * @param id defines the id to search for
  34127. * @return the mesh found or null if not found at all
  34128. */
  34129. getMeshByID(id: string): Nullable<AbstractMesh>;
  34130. /**
  34131. * Gets a list of meshes using their id
  34132. * @param id defines the id to search for
  34133. * @returns a list of meshes
  34134. */
  34135. getMeshesByID(id: string): Array<AbstractMesh>;
  34136. /**
  34137. * Gets the first added transform node found of a given ID
  34138. * @param id defines the id to search for
  34139. * @return the found transform node or null if not found at all.
  34140. */
  34141. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34142. /**
  34143. * Gets a transform node with its auto-generated unique id
  34144. * @param uniqueId efines the unique id to search for
  34145. * @return the found transform node or null if not found at all.
  34146. */
  34147. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34148. /**
  34149. * Gets a list of transform nodes using their id
  34150. * @param id defines the id to search for
  34151. * @returns a list of transform nodes
  34152. */
  34153. getTransformNodesByID(id: string): Array<TransformNode>;
  34154. /**
  34155. * Gets a mesh with its auto-generated unique id
  34156. * @param uniqueId defines the unique id to search for
  34157. * @return the found mesh or null if not found at all.
  34158. */
  34159. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34160. /**
  34161. * Gets a the last added mesh using a given id
  34162. * @param id defines the id to search for
  34163. * @return the found mesh or null if not found at all.
  34164. */
  34165. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34166. /**
  34167. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34168. * @param id defines the id to search for
  34169. * @return the found node or null if not found at all
  34170. */
  34171. getLastEntryByID(id: string): Nullable<Node>;
  34172. /**
  34173. * Gets a node (Mesh, Camera, Light) using a given id
  34174. * @param id defines the id to search for
  34175. * @return the found node or null if not found at all
  34176. */
  34177. getNodeByID(id: string): Nullable<Node>;
  34178. /**
  34179. * Gets a node (Mesh, Camera, Light) using a given name
  34180. * @param name defines the name to search for
  34181. * @return the found node or null if not found at all.
  34182. */
  34183. getNodeByName(name: string): Nullable<Node>;
  34184. /**
  34185. * Gets a mesh using a given name
  34186. * @param name defines the name to search for
  34187. * @return the found mesh or null if not found at all.
  34188. */
  34189. getMeshByName(name: string): Nullable<AbstractMesh>;
  34190. /**
  34191. * Gets a transform node using a given name
  34192. * @param name defines the name to search for
  34193. * @return the found transform node or null if not found at all.
  34194. */
  34195. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34196. /**
  34197. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34198. * @param id defines the id to search for
  34199. * @return the found skeleton or null if not found at all.
  34200. */
  34201. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34202. /**
  34203. * Gets a skeleton using a given auto generated unique id
  34204. * @param uniqueId defines the unique id to search for
  34205. * @return the found skeleton or null if not found at all.
  34206. */
  34207. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34208. /**
  34209. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34210. * @param id defines the id to search for
  34211. * @return the found skeleton or null if not found at all.
  34212. */
  34213. getSkeletonById(id: string): Nullable<Skeleton>;
  34214. /**
  34215. * Gets a skeleton using a given name
  34216. * @param name defines the name to search for
  34217. * @return the found skeleton or null if not found at all.
  34218. */
  34219. getSkeletonByName(name: string): Nullable<Skeleton>;
  34220. /**
  34221. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34222. * @param id defines the id to search for
  34223. * @return the found morph target manager or null if not found at all.
  34224. */
  34225. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34226. /**
  34227. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34228. * @param id defines the id to search for
  34229. * @return the found morph target or null if not found at all.
  34230. */
  34231. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34232. /**
  34233. * Gets a boolean indicating if the given mesh is active
  34234. * @param mesh defines the mesh to look for
  34235. * @returns true if the mesh is in the active list
  34236. */
  34237. isActiveMesh(mesh: AbstractMesh): boolean;
  34238. /**
  34239. * Return a unique id as a string which can serve as an identifier for the scene
  34240. */
  34241. readonly uid: string;
  34242. /**
  34243. * Add an externaly attached data from its key.
  34244. * This method call will fail and return false, if such key already exists.
  34245. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34246. * @param key the unique key that identifies the data
  34247. * @param data the data object to associate to the key for this Engine instance
  34248. * @return true if no such key were already present and the data was added successfully, false otherwise
  34249. */
  34250. addExternalData<T>(key: string, data: T): boolean;
  34251. /**
  34252. * Get an externaly attached data from its key
  34253. * @param key the unique key that identifies the data
  34254. * @return the associated data, if present (can be null), or undefined if not present
  34255. */
  34256. getExternalData<T>(key: string): Nullable<T>;
  34257. /**
  34258. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34259. * @param key the unique key that identifies the data
  34260. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34261. * @return the associated data, can be null if the factory returned null.
  34262. */
  34263. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34264. /**
  34265. * Remove an externaly attached data from the Engine instance
  34266. * @param key the unique key that identifies the data
  34267. * @return true if the data was successfully removed, false if it doesn't exist
  34268. */
  34269. removeExternalData(key: string): boolean;
  34270. private _evaluateSubMesh;
  34271. /**
  34272. * Clear the processed materials smart array preventing retention point in material dispose.
  34273. */
  34274. freeProcessedMaterials(): void;
  34275. private _preventFreeActiveMeshesAndRenderingGroups;
  34276. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34277. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34278. * when disposing several meshes in a row or a hierarchy of meshes.
  34279. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34280. */
  34281. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34282. /**
  34283. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34284. */
  34285. freeActiveMeshes(): void;
  34286. /**
  34287. * Clear the info related to rendering groups preventing retention points during dispose.
  34288. */
  34289. freeRenderingGroups(): void;
  34290. /** @hidden */
  34291. _isInIntermediateRendering(): boolean;
  34292. /**
  34293. * Lambda returning the list of potentially active meshes.
  34294. */
  34295. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34296. /**
  34297. * Lambda returning the list of potentially active sub meshes.
  34298. */
  34299. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34300. /**
  34301. * Lambda returning the list of potentially intersecting sub meshes.
  34302. */
  34303. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34304. /**
  34305. * Lambda returning the list of potentially colliding sub meshes.
  34306. */
  34307. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34308. private _activeMeshesFrozen;
  34309. /**
  34310. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34311. * @returns the current scene
  34312. */
  34313. freezeActiveMeshes(): Scene;
  34314. /**
  34315. * Use this function to restart evaluating active meshes on every frame
  34316. * @returns the current scene
  34317. */
  34318. unfreezeActiveMeshes(): Scene;
  34319. private _evaluateActiveMeshes;
  34320. private _activeMesh;
  34321. /**
  34322. * Update the transform matrix to update from the current active camera
  34323. * @param force defines a boolean used to force the update even if cache is up to date
  34324. */
  34325. updateTransformMatrix(force?: boolean): void;
  34326. private _bindFrameBuffer;
  34327. /** @hidden */
  34328. _allowPostProcessClearColor: boolean;
  34329. /** @hidden */
  34330. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34331. private _processSubCameras;
  34332. private _checkIntersections;
  34333. /** @hidden */
  34334. _advancePhysicsEngineStep(step: number): void;
  34335. /**
  34336. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34337. */
  34338. getDeterministicFrameTime: () => number;
  34339. /** @hidden */
  34340. _animate(): void;
  34341. /** Execute all animations (for a frame) */
  34342. animate(): void;
  34343. /**
  34344. * Render the scene
  34345. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34346. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34347. */
  34348. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34349. /**
  34350. * Freeze all materials
  34351. * A frozen material will not be updatable but should be faster to render
  34352. */
  34353. freezeMaterials(): void;
  34354. /**
  34355. * Unfreeze all materials
  34356. * A frozen material will not be updatable but should be faster to render
  34357. */
  34358. unfreezeMaterials(): void;
  34359. /**
  34360. * Releases all held ressources
  34361. */
  34362. dispose(): void;
  34363. /**
  34364. * Gets if the scene is already disposed
  34365. */
  34366. readonly isDisposed: boolean;
  34367. /**
  34368. * Call this function to reduce memory footprint of the scene.
  34369. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34370. */
  34371. clearCachedVertexData(): void;
  34372. /**
  34373. * This function will remove the local cached buffer data from texture.
  34374. * It will save memory but will prevent the texture from being rebuilt
  34375. */
  34376. cleanCachedTextureBuffer(): void;
  34377. /**
  34378. * Get the world extend vectors with an optional filter
  34379. *
  34380. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34381. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34382. */
  34383. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34384. min: Vector3;
  34385. max: Vector3;
  34386. };
  34387. /**
  34388. * Creates a ray that can be used to pick in the scene
  34389. * @param x defines the x coordinate of the origin (on-screen)
  34390. * @param y defines the y coordinate of the origin (on-screen)
  34391. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34392. * @param camera defines the camera to use for the picking
  34393. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34394. * @returns a Ray
  34395. */
  34396. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34397. /**
  34398. * Creates a ray that can be used to pick in the scene
  34399. * @param x defines the x coordinate of the origin (on-screen)
  34400. * @param y defines the y coordinate of the origin (on-screen)
  34401. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34402. * @param result defines the ray where to store the picking ray
  34403. * @param camera defines the camera to use for the picking
  34404. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34405. * @returns the current scene
  34406. */
  34407. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34408. /**
  34409. * Creates a ray that can be used to pick in the scene
  34410. * @param x defines the x coordinate of the origin (on-screen)
  34411. * @param y defines the y coordinate of the origin (on-screen)
  34412. * @param camera defines the camera to use for the picking
  34413. * @returns a Ray
  34414. */
  34415. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34416. /**
  34417. * Creates a ray that can be used to pick in the scene
  34418. * @param x defines the x coordinate of the origin (on-screen)
  34419. * @param y defines the y coordinate of the origin (on-screen)
  34420. * @param result defines the ray where to store the picking ray
  34421. * @param camera defines the camera to use for the picking
  34422. * @returns the current scene
  34423. */
  34424. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34425. /** Launch a ray to try to pick a mesh in the scene
  34426. * @param x position on screen
  34427. * @param y position on screen
  34428. * @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
  34429. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34430. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34431. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34432. * @returns a PickingInfo
  34433. */
  34434. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34435. /** Use the given ray to pick a mesh in the scene
  34436. * @param ray The ray to use to pick meshes
  34437. * @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
  34438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34439. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34440. * @returns a PickingInfo
  34441. */
  34442. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34443. /**
  34444. * Launch a ray to try to pick a mesh in the scene
  34445. * @param x X position on screen
  34446. * @param y Y position on screen
  34447. * @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
  34448. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34450. * @returns an array of PickingInfo
  34451. */
  34452. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34453. /**
  34454. * Launch a ray to try to pick a mesh in the scene
  34455. * @param ray Ray to use
  34456. * @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
  34457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34458. * @returns an array of PickingInfo
  34459. */
  34460. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34461. /**
  34462. * Force the value of meshUnderPointer
  34463. * @param mesh defines the mesh to use
  34464. */
  34465. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34466. /**
  34467. * Gets the mesh under the pointer
  34468. * @returns a Mesh or null if no mesh is under the pointer
  34469. */
  34470. getPointerOverMesh(): Nullable<AbstractMesh>;
  34471. /** @hidden */
  34472. _rebuildGeometries(): void;
  34473. /** @hidden */
  34474. _rebuildTextures(): void;
  34475. private _getByTags;
  34476. /**
  34477. * Get a list of meshes by tags
  34478. * @param tagsQuery defines the tags query to use
  34479. * @param forEach defines a predicate used to filter results
  34480. * @returns an array of Mesh
  34481. */
  34482. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34483. /**
  34484. * Get a list of cameras by tags
  34485. * @param tagsQuery defines the tags query to use
  34486. * @param forEach defines a predicate used to filter results
  34487. * @returns an array of Camera
  34488. */
  34489. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34490. /**
  34491. * Get a list of lights by tags
  34492. * @param tagsQuery defines the tags query to use
  34493. * @param forEach defines a predicate used to filter results
  34494. * @returns an array of Light
  34495. */
  34496. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34497. /**
  34498. * Get a list of materials by tags
  34499. * @param tagsQuery defines the tags query to use
  34500. * @param forEach defines a predicate used to filter results
  34501. * @returns an array of Material
  34502. */
  34503. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34504. /**
  34505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34506. * This allowed control for front to back rendering or reversly depending of the special needs.
  34507. *
  34508. * @param renderingGroupId The rendering group id corresponding to its index
  34509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34512. */
  34513. 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;
  34514. /**
  34515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34516. *
  34517. * @param renderingGroupId The rendering group id corresponding to its index
  34518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34521. */
  34522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34523. /**
  34524. * Gets the current auto clear configuration for one rendering group of the rendering
  34525. * manager.
  34526. * @param index the rendering group index to get the information for
  34527. * @returns The auto clear setup for the requested rendering group
  34528. */
  34529. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34530. private _blockMaterialDirtyMechanism;
  34531. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34532. blockMaterialDirtyMechanism: boolean;
  34533. /**
  34534. * Will flag all materials as dirty to trigger new shader compilation
  34535. * @param flag defines the flag used to specify which material part must be marked as dirty
  34536. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34537. */
  34538. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34539. /** @hidden */
  34540. _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;
  34541. /** @hidden */
  34542. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34543. }
  34544. }
  34545. declare module "babylonjs/assetContainer" {
  34546. import { AbstractScene } from "babylonjs/abstractScene";
  34547. import { Scene } from "babylonjs/scene";
  34548. import { Mesh } from "babylonjs/Meshes/mesh";
  34549. /**
  34550. * Set of assets to keep when moving a scene into an asset container.
  34551. */
  34552. export class KeepAssets extends AbstractScene {
  34553. }
  34554. /**
  34555. * Container with a set of assets that can be added or removed from a scene.
  34556. */
  34557. export class AssetContainer extends AbstractScene {
  34558. /**
  34559. * The scene the AssetContainer belongs to.
  34560. */
  34561. scene: Scene;
  34562. /**
  34563. * Instantiates an AssetContainer.
  34564. * @param scene The scene the AssetContainer belongs to.
  34565. */
  34566. constructor(scene: Scene);
  34567. /**
  34568. * Adds all the assets from the container to the scene.
  34569. */
  34570. addAllToScene(): void;
  34571. /**
  34572. * Removes all the assets in the container from the scene
  34573. */
  34574. removeAllFromScene(): void;
  34575. /**
  34576. * Disposes all the assets in the container
  34577. */
  34578. dispose(): void;
  34579. private _moveAssets;
  34580. /**
  34581. * Removes all the assets contained in the scene and adds them to the container.
  34582. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34583. */
  34584. moveAllFromScene(keepAssets?: KeepAssets): void;
  34585. /**
  34586. * 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.
  34587. * @returns the root mesh
  34588. */
  34589. createRootMesh(): Mesh;
  34590. }
  34591. }
  34592. declare module "babylonjs/abstractScene" {
  34593. import { Scene } from "babylonjs/scene";
  34594. import { Nullable } from "babylonjs/types";
  34595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34597. import { Geometry } from "babylonjs/Meshes/geometry";
  34598. import { Skeleton } from "babylonjs/Bones/skeleton";
  34599. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34600. import { AssetContainer } from "babylonjs/assetContainer";
  34601. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34602. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34604. import { Material } from "babylonjs/Materials/material";
  34605. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34606. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34607. import { Camera } from "babylonjs/Cameras/camera";
  34608. import { Light } from "babylonjs/Lights/light";
  34609. import { Node } from "babylonjs/node";
  34610. import { Animation } from "babylonjs/Animations/animation";
  34611. /**
  34612. * Defines how the parser contract is defined.
  34613. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34614. */
  34615. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34616. /**
  34617. * Defines how the individual parser contract is defined.
  34618. * These parser can parse an individual asset
  34619. */
  34620. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34621. /**
  34622. * Base class of the scene acting as a container for the different elements composing a scene.
  34623. * This class is dynamically extended by the different components of the scene increasing
  34624. * flexibility and reducing coupling
  34625. */
  34626. export abstract class AbstractScene {
  34627. /**
  34628. * Stores the list of available parsers in the application.
  34629. */
  34630. private static _BabylonFileParsers;
  34631. /**
  34632. * Stores the list of available individual parsers in the application.
  34633. */
  34634. private static _IndividualBabylonFileParsers;
  34635. /**
  34636. * Adds a parser in the list of available ones
  34637. * @param name Defines the name of the parser
  34638. * @param parser Defines the parser to add
  34639. */
  34640. static AddParser(name: string, parser: BabylonFileParser): void;
  34641. /**
  34642. * Gets a general parser from the list of avaialble ones
  34643. * @param name Defines the name of the parser
  34644. * @returns the requested parser or null
  34645. */
  34646. static GetParser(name: string): Nullable<BabylonFileParser>;
  34647. /**
  34648. * Adds n individual parser in the list of available ones
  34649. * @param name Defines the name of the parser
  34650. * @param parser Defines the parser to add
  34651. */
  34652. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34653. /**
  34654. * Gets an individual parser from the list of avaialble ones
  34655. * @param name Defines the name of the parser
  34656. * @returns the requested parser or null
  34657. */
  34658. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34659. /**
  34660. * Parser json data and populate both a scene and its associated container object
  34661. * @param jsonData Defines the data to parse
  34662. * @param scene Defines the scene to parse the data for
  34663. * @param container Defines the container attached to the parsing sequence
  34664. * @param rootUrl Defines the root url of the data
  34665. */
  34666. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34667. /**
  34668. * Gets the list of root nodes (ie. nodes with no parent)
  34669. */
  34670. rootNodes: Node[];
  34671. /** All of the cameras added to this scene
  34672. * @see http://doc.babylonjs.com/babylon101/cameras
  34673. */
  34674. cameras: Camera[];
  34675. /**
  34676. * All of the lights added to this scene
  34677. * @see http://doc.babylonjs.com/babylon101/lights
  34678. */
  34679. lights: Light[];
  34680. /**
  34681. * All of the (abstract) meshes added to this scene
  34682. */
  34683. meshes: AbstractMesh[];
  34684. /**
  34685. * The list of skeletons added to the scene
  34686. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34687. */
  34688. skeletons: Skeleton[];
  34689. /**
  34690. * All of the particle systems added to this scene
  34691. * @see http://doc.babylonjs.com/babylon101/particles
  34692. */
  34693. particleSystems: IParticleSystem[];
  34694. /**
  34695. * Gets a list of Animations associated with the scene
  34696. */
  34697. animations: Animation[];
  34698. /**
  34699. * All of the animation groups added to this scene
  34700. * @see http://doc.babylonjs.com/how_to/group
  34701. */
  34702. animationGroups: AnimationGroup[];
  34703. /**
  34704. * All of the multi-materials added to this scene
  34705. * @see http://doc.babylonjs.com/how_to/multi_materials
  34706. */
  34707. multiMaterials: MultiMaterial[];
  34708. /**
  34709. * All of the materials added to this scene
  34710. * In the context of a Scene, it is not supposed to be modified manually.
  34711. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34712. * Note also that the order of the Material wihin the array is not significant and might change.
  34713. * @see http://doc.babylonjs.com/babylon101/materials
  34714. */
  34715. materials: Material[];
  34716. /**
  34717. * The list of morph target managers added to the scene
  34718. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34719. */
  34720. morphTargetManagers: MorphTargetManager[];
  34721. /**
  34722. * The list of geometries used in the scene.
  34723. */
  34724. geometries: Geometry[];
  34725. /**
  34726. * All of the tranform nodes added to this scene
  34727. * In the context of a Scene, it is not supposed to be modified manually.
  34728. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34729. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34730. * @see http://doc.babylonjs.com/how_to/transformnode
  34731. */
  34732. transformNodes: TransformNode[];
  34733. /**
  34734. * ActionManagers available on the scene.
  34735. */
  34736. actionManagers: AbstractActionManager[];
  34737. /**
  34738. * Textures to keep.
  34739. */
  34740. textures: BaseTexture[];
  34741. /**
  34742. * Environment texture for the scene
  34743. */
  34744. environmentTexture: Nullable<BaseTexture>;
  34745. }
  34746. }
  34747. declare module "babylonjs/Audio/sound" {
  34748. import { Observable } from "babylonjs/Misc/observable";
  34749. import { Vector3 } from "babylonjs/Maths/math";
  34750. import { Nullable } from "babylonjs/types";
  34751. import { Scene } from "babylonjs/scene";
  34752. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34753. /**
  34754. * Defines a sound that can be played in the application.
  34755. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34757. */
  34758. export class Sound {
  34759. /**
  34760. * The name of the sound in the scene.
  34761. */
  34762. name: string;
  34763. /**
  34764. * Does the sound autoplay once loaded.
  34765. */
  34766. autoplay: boolean;
  34767. /**
  34768. * Does the sound loop after it finishes playing once.
  34769. */
  34770. loop: boolean;
  34771. /**
  34772. * Does the sound use a custom attenuation curve to simulate the falloff
  34773. * happening when the source gets further away from the camera.
  34774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34775. */
  34776. useCustomAttenuation: boolean;
  34777. /**
  34778. * The sound track id this sound belongs to.
  34779. */
  34780. soundTrackId: number;
  34781. /**
  34782. * Is this sound currently played.
  34783. */
  34784. isPlaying: boolean;
  34785. /**
  34786. * Is this sound currently paused.
  34787. */
  34788. isPaused: boolean;
  34789. /**
  34790. * Does this sound enables spatial sound.
  34791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34792. */
  34793. spatialSound: boolean;
  34794. /**
  34795. * Define the reference distance the sound should be heard perfectly.
  34796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34797. */
  34798. refDistance: number;
  34799. /**
  34800. * Define the roll off factor of spatial sounds.
  34801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34802. */
  34803. rolloffFactor: number;
  34804. /**
  34805. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34807. */
  34808. maxDistance: number;
  34809. /**
  34810. * Define the distance attenuation model the sound will follow.
  34811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34812. */
  34813. distanceModel: string;
  34814. /**
  34815. * @hidden
  34816. * Back Compat
  34817. **/
  34818. onended: () => any;
  34819. /**
  34820. * Observable event when the current playing sound finishes.
  34821. */
  34822. onEndedObservable: Observable<Sound>;
  34823. private _panningModel;
  34824. private _playbackRate;
  34825. private _streaming;
  34826. private _startTime;
  34827. private _startOffset;
  34828. private _position;
  34829. /** @hidden */
  34830. _positionInEmitterSpace: boolean;
  34831. private _localDirection;
  34832. private _volume;
  34833. private _isReadyToPlay;
  34834. private _isDirectional;
  34835. private _readyToPlayCallback;
  34836. private _audioBuffer;
  34837. private _soundSource;
  34838. private _streamingSource;
  34839. private _soundPanner;
  34840. private _soundGain;
  34841. private _inputAudioNode;
  34842. private _outputAudioNode;
  34843. private _coneInnerAngle;
  34844. private _coneOuterAngle;
  34845. private _coneOuterGain;
  34846. private _scene;
  34847. private _connectedTransformNode;
  34848. private _customAttenuationFunction;
  34849. private _registerFunc;
  34850. private _isOutputConnected;
  34851. private _htmlAudioElement;
  34852. private _urlType;
  34853. /** @hidden */
  34854. static _SceneComponentInitialization: (scene: Scene) => void;
  34855. /**
  34856. * Create a sound and attach it to a scene
  34857. * @param name Name of your sound
  34858. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34859. * @param scene defines the scene the sound belongs to
  34860. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34861. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34862. */
  34863. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34864. /**
  34865. * Release the sound and its associated resources
  34866. */
  34867. dispose(): void;
  34868. /**
  34869. * Gets if the sounds is ready to be played or not.
  34870. * @returns true if ready, otherwise false
  34871. */
  34872. isReady(): boolean;
  34873. private _soundLoaded;
  34874. /**
  34875. * Sets the data of the sound from an audiobuffer
  34876. * @param audioBuffer The audioBuffer containing the data
  34877. */
  34878. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34879. /**
  34880. * Updates the current sounds options such as maxdistance, loop...
  34881. * @param options A JSON object containing values named as the object properties
  34882. */
  34883. updateOptions(options: any): void;
  34884. private _createSpatialParameters;
  34885. private _updateSpatialParameters;
  34886. /**
  34887. * Switch the panning model to HRTF:
  34888. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34890. */
  34891. switchPanningModelToHRTF(): void;
  34892. /**
  34893. * Switch the panning model to Equal Power:
  34894. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34896. */
  34897. switchPanningModelToEqualPower(): void;
  34898. private _switchPanningModel;
  34899. /**
  34900. * Connect this sound to a sound track audio node like gain...
  34901. * @param soundTrackAudioNode the sound track audio node to connect to
  34902. */
  34903. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34904. /**
  34905. * Transform this sound into a directional source
  34906. * @param coneInnerAngle Size of the inner cone in degree
  34907. * @param coneOuterAngle Size of the outer cone in degree
  34908. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34909. */
  34910. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34911. /**
  34912. * Gets or sets the inner angle for the directional cone.
  34913. */
  34914. /**
  34915. * Gets or sets the inner angle for the directional cone.
  34916. */
  34917. directionalConeInnerAngle: number;
  34918. /**
  34919. * Gets or sets the outer angle for the directional cone.
  34920. */
  34921. /**
  34922. * Gets or sets the outer angle for the directional cone.
  34923. */
  34924. directionalConeOuterAngle: number;
  34925. /**
  34926. * Sets the position of the emitter if spatial sound is enabled
  34927. * @param newPosition Defines the new posisiton
  34928. */
  34929. setPosition(newPosition: Vector3): void;
  34930. /**
  34931. * Sets the local direction of the emitter if spatial sound is enabled
  34932. * @param newLocalDirection Defines the new local direction
  34933. */
  34934. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34935. private _updateDirection;
  34936. /** @hidden */
  34937. updateDistanceFromListener(): void;
  34938. /**
  34939. * Sets a new custom attenuation function for the sound.
  34940. * @param callback Defines the function used for the attenuation
  34941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34942. */
  34943. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34944. /**
  34945. * Play the sound
  34946. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34947. * @param offset (optional) Start the sound setting it at a specific time
  34948. */
  34949. play(time?: number, offset?: number): void;
  34950. private _onended;
  34951. /**
  34952. * Stop the sound
  34953. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34954. */
  34955. stop(time?: number): void;
  34956. /**
  34957. * Put the sound in pause
  34958. */
  34959. pause(): void;
  34960. /**
  34961. * Sets a dedicated volume for this sounds
  34962. * @param newVolume Define the new volume of the sound
  34963. * @param time Define in how long the sound should be at this value
  34964. */
  34965. setVolume(newVolume: number, time?: number): void;
  34966. /**
  34967. * Set the sound play back rate
  34968. * @param newPlaybackRate Define the playback rate the sound should be played at
  34969. */
  34970. setPlaybackRate(newPlaybackRate: number): void;
  34971. /**
  34972. * Gets the volume of the sound.
  34973. * @returns the volume of the sound
  34974. */
  34975. getVolume(): number;
  34976. /**
  34977. * Attach the sound to a dedicated mesh
  34978. * @param transformNode The transform node to connect the sound with
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34980. */
  34981. attachToMesh(transformNode: TransformNode): void;
  34982. /**
  34983. * Detach the sound from the previously attached mesh
  34984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34985. */
  34986. detachFromMesh(): void;
  34987. private _onRegisterAfterWorldMatrixUpdate;
  34988. /**
  34989. * Clone the current sound in the scene.
  34990. * @returns the new sound clone
  34991. */
  34992. clone(): Nullable<Sound>;
  34993. /**
  34994. * Gets the current underlying audio buffer containing the data
  34995. * @returns the audio buffer
  34996. */
  34997. getAudioBuffer(): Nullable<AudioBuffer>;
  34998. /**
  34999. * Serializes the Sound in a JSON representation
  35000. * @returns the JSON representation of the sound
  35001. */
  35002. serialize(): any;
  35003. /**
  35004. * Parse a JSON representation of a sound to innstantiate in a given scene
  35005. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35006. * @param scene Define the scene the new parsed sound should be created in
  35007. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35008. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35009. * @returns the newly parsed sound
  35010. */
  35011. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35012. }
  35013. }
  35014. declare module "babylonjs/Actions/directAudioActions" {
  35015. import { Action } from "babylonjs/Actions/action";
  35016. import { Condition } from "babylonjs/Actions/condition";
  35017. import { Sound } from "babylonjs/Audio/sound";
  35018. /**
  35019. * This defines an action helpful to play a defined sound on a triggered action.
  35020. */
  35021. export class PlaySoundAction extends Action {
  35022. private _sound;
  35023. /**
  35024. * Instantiate the action
  35025. * @param triggerOptions defines the trigger options
  35026. * @param sound defines the sound to play
  35027. * @param condition defines the trigger related conditions
  35028. */
  35029. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35030. /** @hidden */
  35031. _prepare(): void;
  35032. /**
  35033. * Execute the action and play the sound.
  35034. */
  35035. execute(): void;
  35036. /**
  35037. * Serializes the actions and its related information.
  35038. * @param parent defines the object to serialize in
  35039. * @returns the serialized object
  35040. */
  35041. serialize(parent: any): any;
  35042. }
  35043. /**
  35044. * This defines an action helpful to stop a defined sound on a triggered action.
  35045. */
  35046. export class StopSoundAction extends Action {
  35047. private _sound;
  35048. /**
  35049. * Instantiate the action
  35050. * @param triggerOptions defines the trigger options
  35051. * @param sound defines the sound to stop
  35052. * @param condition defines the trigger related conditions
  35053. */
  35054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35055. /** @hidden */
  35056. _prepare(): void;
  35057. /**
  35058. * Execute the action and stop the sound.
  35059. */
  35060. execute(): void;
  35061. /**
  35062. * Serializes the actions and its related information.
  35063. * @param parent defines the object to serialize in
  35064. * @returns the serialized object
  35065. */
  35066. serialize(parent: any): any;
  35067. }
  35068. }
  35069. declare module "babylonjs/Actions/interpolateValueAction" {
  35070. import { Action } from "babylonjs/Actions/action";
  35071. import { Condition } from "babylonjs/Actions/condition";
  35072. import { Observable } from "babylonjs/Misc/observable";
  35073. /**
  35074. * This defines an action responsible to change the value of a property
  35075. * by interpolating between its current value and the newly set one once triggered.
  35076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35077. */
  35078. export class InterpolateValueAction extends Action {
  35079. /**
  35080. * Defines the path of the property where the value should be interpolated
  35081. */
  35082. propertyPath: string;
  35083. /**
  35084. * Defines the target value at the end of the interpolation.
  35085. */
  35086. value: any;
  35087. /**
  35088. * Defines the time it will take for the property to interpolate to the value.
  35089. */
  35090. duration: number;
  35091. /**
  35092. * Defines if the other scene animations should be stopped when the action has been triggered
  35093. */
  35094. stopOtherAnimations?: boolean;
  35095. /**
  35096. * Defines a callback raised once the interpolation animation has been done.
  35097. */
  35098. onInterpolationDone?: () => void;
  35099. /**
  35100. * Observable triggered once the interpolation animation has been done.
  35101. */
  35102. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35103. private _target;
  35104. private _effectiveTarget;
  35105. private _property;
  35106. /**
  35107. * Instantiate the action
  35108. * @param triggerOptions defines the trigger options
  35109. * @param target defines the object containing the value to interpolate
  35110. * @param propertyPath defines the path to the property in the target object
  35111. * @param value defines the target value at the end of the interpolation
  35112. * @param duration deines the time it will take for the property to interpolate to the value.
  35113. * @param condition defines the trigger related conditions
  35114. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35115. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35116. */
  35117. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35118. /** @hidden */
  35119. _prepare(): void;
  35120. /**
  35121. * Execute the action starts the value interpolation.
  35122. */
  35123. execute(): void;
  35124. /**
  35125. * Serializes the actions and its related information.
  35126. * @param parent defines the object to serialize in
  35127. * @returns the serialized object
  35128. */
  35129. serialize(parent: any): any;
  35130. }
  35131. }
  35132. declare module "babylonjs/Actions/index" {
  35133. export * from "babylonjs/Actions/action";
  35134. export * from "babylonjs/Actions/actionEvent";
  35135. export * from "babylonjs/Actions/actionManager";
  35136. export * from "babylonjs/Actions/condition";
  35137. export * from "babylonjs/Actions/directActions";
  35138. export * from "babylonjs/Actions/directAudioActions";
  35139. export * from "babylonjs/Actions/interpolateValueAction";
  35140. }
  35141. declare module "babylonjs/Animations/index" {
  35142. export * from "babylonjs/Animations/animatable";
  35143. export * from "babylonjs/Animations/animation";
  35144. export * from "babylonjs/Animations/animationGroup";
  35145. export * from "babylonjs/Animations/animationPropertiesOverride";
  35146. export * from "babylonjs/Animations/easing";
  35147. export * from "babylonjs/Animations/runtimeAnimation";
  35148. export * from "babylonjs/Animations/animationEvent";
  35149. export * from "babylonjs/Animations/animationGroup";
  35150. export * from "babylonjs/Animations/animationKey";
  35151. export * from "babylonjs/Animations/animationRange";
  35152. }
  35153. declare module "babylonjs/Audio/soundTrack" {
  35154. import { Sound } from "babylonjs/Audio/sound";
  35155. import { Analyser } from "babylonjs/Audio/analyser";
  35156. import { Scene } from "babylonjs/scene";
  35157. /**
  35158. * Options allowed during the creation of a sound track.
  35159. */
  35160. export interface ISoundTrackOptions {
  35161. /**
  35162. * The volume the sound track should take during creation
  35163. */
  35164. volume?: number;
  35165. /**
  35166. * Define if the sound track is the main sound track of the scene
  35167. */
  35168. mainTrack?: boolean;
  35169. }
  35170. /**
  35171. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35172. * It will be also used in a future release to apply effects on a specific track.
  35173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35174. */
  35175. export class SoundTrack {
  35176. /**
  35177. * The unique identifier of the sound track in the scene.
  35178. */
  35179. id: number;
  35180. /**
  35181. * The list of sounds included in the sound track.
  35182. */
  35183. soundCollection: Array<Sound>;
  35184. private _outputAudioNode;
  35185. private _scene;
  35186. private _isMainTrack;
  35187. private _connectedAnalyser;
  35188. private _options;
  35189. private _isInitialized;
  35190. /**
  35191. * Creates a new sound track.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35193. * @param scene Define the scene the sound track belongs to
  35194. * @param options
  35195. */
  35196. constructor(scene: Scene, options?: ISoundTrackOptions);
  35197. private _initializeSoundTrackAudioGraph;
  35198. /**
  35199. * Release the sound track and its associated resources
  35200. */
  35201. dispose(): void;
  35202. /**
  35203. * Adds a sound to this sound track
  35204. * @param sound define the cound to add
  35205. * @ignoreNaming
  35206. */
  35207. AddSound(sound: Sound): void;
  35208. /**
  35209. * Removes a sound to this sound track
  35210. * @param sound define the cound to remove
  35211. * @ignoreNaming
  35212. */
  35213. RemoveSound(sound: Sound): void;
  35214. /**
  35215. * Set a global volume for the full sound track.
  35216. * @param newVolume Define the new volume of the sound track
  35217. */
  35218. setVolume(newVolume: number): void;
  35219. /**
  35220. * Switch the panning model to HRTF:
  35221. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35223. */
  35224. switchPanningModelToHRTF(): void;
  35225. /**
  35226. * Switch the panning model to Equal Power:
  35227. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35229. */
  35230. switchPanningModelToEqualPower(): void;
  35231. /**
  35232. * Connect the sound track to an audio analyser allowing some amazing
  35233. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35235. * @param analyser The analyser to connect to the engine
  35236. */
  35237. connectToAnalyser(analyser: Analyser): void;
  35238. }
  35239. }
  35240. declare module "babylonjs/Audio/audioSceneComponent" {
  35241. import { Sound } from "babylonjs/Audio/sound";
  35242. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35243. import { Nullable } from "babylonjs/types";
  35244. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35245. import { Scene } from "babylonjs/scene";
  35246. import { AbstractScene } from "babylonjs/abstractScene";
  35247. module "babylonjs/abstractScene" {
  35248. interface AbstractScene {
  35249. /**
  35250. * The list of sounds used in the scene.
  35251. */
  35252. sounds: Nullable<Array<Sound>>;
  35253. }
  35254. }
  35255. module "babylonjs/scene" {
  35256. interface Scene {
  35257. /**
  35258. * @hidden
  35259. * Backing field
  35260. */
  35261. _mainSoundTrack: SoundTrack;
  35262. /**
  35263. * The main sound track played by the scene.
  35264. * It cotains your primary collection of sounds.
  35265. */
  35266. mainSoundTrack: SoundTrack;
  35267. /**
  35268. * The list of sound tracks added to the scene
  35269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35270. */
  35271. soundTracks: Nullable<Array<SoundTrack>>;
  35272. /**
  35273. * Gets a sound using a given name
  35274. * @param name defines the name to search for
  35275. * @return the found sound or null if not found at all.
  35276. */
  35277. getSoundByName(name: string): Nullable<Sound>;
  35278. /**
  35279. * Gets or sets if audio support is enabled
  35280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35281. */
  35282. audioEnabled: boolean;
  35283. /**
  35284. * Gets or sets if audio will be output to headphones
  35285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35286. */
  35287. headphone: boolean;
  35288. }
  35289. }
  35290. /**
  35291. * Defines the sound scene component responsible to manage any sounds
  35292. * in a given scene.
  35293. */
  35294. export class AudioSceneComponent implements ISceneSerializableComponent {
  35295. /**
  35296. * The component name helpfull to identify the component in the list of scene components.
  35297. */
  35298. readonly name: string;
  35299. /**
  35300. * The scene the component belongs to.
  35301. */
  35302. scene: Scene;
  35303. private _audioEnabled;
  35304. /**
  35305. * Gets whether audio is enabled or not.
  35306. * Please use related enable/disable method to switch state.
  35307. */
  35308. readonly audioEnabled: boolean;
  35309. private _headphone;
  35310. /**
  35311. * Gets whether audio is outputing to headphone or not.
  35312. * Please use the according Switch methods to change output.
  35313. */
  35314. readonly headphone: boolean;
  35315. /**
  35316. * Creates a new instance of the component for the given scene
  35317. * @param scene Defines the scene to register the component in
  35318. */
  35319. constructor(scene: Scene);
  35320. /**
  35321. * Registers the component in a given scene
  35322. */
  35323. register(): void;
  35324. /**
  35325. * Rebuilds the elements related to this component in case of
  35326. * context lost for instance.
  35327. */
  35328. rebuild(): void;
  35329. /**
  35330. * Serializes the component data to the specified json object
  35331. * @param serializationObject The object to serialize to
  35332. */
  35333. serialize(serializationObject: any): void;
  35334. /**
  35335. * Adds all the element from the container to the scene
  35336. * @param container the container holding the elements
  35337. */
  35338. addFromContainer(container: AbstractScene): void;
  35339. /**
  35340. * Removes all the elements in the container from the scene
  35341. * @param container contains the elements to remove
  35342. * @param dispose if the removed element should be disposed (default: false)
  35343. */
  35344. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35345. /**
  35346. * Disposes the component and the associated ressources.
  35347. */
  35348. dispose(): void;
  35349. /**
  35350. * Disables audio in the associated scene.
  35351. */
  35352. disableAudio(): void;
  35353. /**
  35354. * Enables audio in the associated scene.
  35355. */
  35356. enableAudio(): void;
  35357. /**
  35358. * Switch audio to headphone output.
  35359. */
  35360. switchAudioModeForHeadphones(): void;
  35361. /**
  35362. * Switch audio to normal speakers.
  35363. */
  35364. switchAudioModeForNormalSpeakers(): void;
  35365. private _afterRender;
  35366. }
  35367. }
  35368. declare module "babylonjs/Audio/weightedsound" {
  35369. import { Sound } from "babylonjs/Audio/sound";
  35370. /**
  35371. * Wraps one or more Sound objects and selects one with random weight for playback.
  35372. */
  35373. export class WeightedSound {
  35374. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35375. loop: boolean;
  35376. private _coneInnerAngle;
  35377. private _coneOuterAngle;
  35378. private _volume;
  35379. /** A Sound is currently playing. */
  35380. isPlaying: boolean;
  35381. /** A Sound is currently paused. */
  35382. isPaused: boolean;
  35383. private _sounds;
  35384. private _weights;
  35385. private _currentIndex?;
  35386. /**
  35387. * Creates a new WeightedSound from the list of sounds given.
  35388. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35389. * @param sounds Array of Sounds that will be selected from.
  35390. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35391. */
  35392. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35393. /**
  35394. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35395. */
  35396. /**
  35397. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35398. */
  35399. directionalConeInnerAngle: number;
  35400. /**
  35401. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35402. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35403. */
  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. directionalConeOuterAngle: number;
  35409. /**
  35410. * Playback volume.
  35411. */
  35412. /**
  35413. * Playback volume.
  35414. */
  35415. volume: number;
  35416. private _onended;
  35417. /**
  35418. * Suspend playback
  35419. */
  35420. pause(): void;
  35421. /**
  35422. * Stop playback
  35423. */
  35424. stop(): void;
  35425. /**
  35426. * Start playback.
  35427. * @param startOffset Position the clip head at a specific time in seconds.
  35428. */
  35429. play(startOffset?: number): void;
  35430. }
  35431. }
  35432. declare module "babylonjs/Audio/index" {
  35433. export * from "babylonjs/Audio/analyser";
  35434. export * from "babylonjs/Audio/audioEngine";
  35435. export * from "babylonjs/Audio/audioSceneComponent";
  35436. export * from "babylonjs/Audio/sound";
  35437. export * from "babylonjs/Audio/soundTrack";
  35438. export * from "babylonjs/Audio/weightedsound";
  35439. }
  35440. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35441. import { Behavior } from "babylonjs/Behaviors/behavior";
  35442. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35443. import { BackEase } from "babylonjs/Animations/easing";
  35444. /**
  35445. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35447. */
  35448. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35449. /**
  35450. * Gets the name of the behavior.
  35451. */
  35452. readonly name: string;
  35453. /**
  35454. * The easing function used by animations
  35455. */
  35456. static EasingFunction: BackEase;
  35457. /**
  35458. * The easing mode used by animations
  35459. */
  35460. static EasingMode: number;
  35461. /**
  35462. * The duration of the animation, in milliseconds
  35463. */
  35464. transitionDuration: number;
  35465. /**
  35466. * Length of the distance animated by the transition when lower radius is reached
  35467. */
  35468. lowerRadiusTransitionRange: number;
  35469. /**
  35470. * Length of the distance animated by the transition when upper radius is reached
  35471. */
  35472. upperRadiusTransitionRange: number;
  35473. private _autoTransitionRange;
  35474. /**
  35475. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35476. */
  35477. /**
  35478. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35479. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35480. */
  35481. autoTransitionRange: boolean;
  35482. private _attachedCamera;
  35483. private _onAfterCheckInputsObserver;
  35484. private _onMeshTargetChangedObserver;
  35485. /**
  35486. * Initializes the behavior.
  35487. */
  35488. init(): void;
  35489. /**
  35490. * Attaches the behavior to its arc rotate camera.
  35491. * @param camera Defines the camera to attach the behavior to
  35492. */
  35493. attach(camera: ArcRotateCamera): void;
  35494. /**
  35495. * Detaches the behavior from its current arc rotate camera.
  35496. */
  35497. detach(): void;
  35498. private _radiusIsAnimating;
  35499. private _radiusBounceTransition;
  35500. private _animatables;
  35501. private _cachedWheelPrecision;
  35502. /**
  35503. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35504. * @param radiusLimit The limit to check against.
  35505. * @return Bool to indicate if at limit.
  35506. */
  35507. private _isRadiusAtLimit;
  35508. /**
  35509. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35510. * @param radiusDelta The delta by which to animate to. Can be negative.
  35511. */
  35512. private _applyBoundRadiusAnimation;
  35513. /**
  35514. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35515. */
  35516. protected _clearAnimationLocks(): void;
  35517. /**
  35518. * Stops and removes all animations that have been applied to the camera
  35519. */
  35520. stopAllAnimations(): void;
  35521. }
  35522. }
  35523. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35524. import { Behavior } from "babylonjs/Behaviors/behavior";
  35525. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35526. import { ExponentialEase } from "babylonjs/Animations/easing";
  35527. import { Nullable } from "babylonjs/types";
  35528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35529. import { Vector3 } from "babylonjs/Maths/math";
  35530. /**
  35531. * 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.
  35532. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35533. */
  35534. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35535. /**
  35536. * Gets the name of the behavior.
  35537. */
  35538. readonly name: string;
  35539. private _mode;
  35540. private _radiusScale;
  35541. private _positionScale;
  35542. private _defaultElevation;
  35543. private _elevationReturnTime;
  35544. private _elevationReturnWaitTime;
  35545. private _zoomStopsAnimation;
  35546. private _framingTime;
  35547. /**
  35548. * The easing function used by animations
  35549. */
  35550. static EasingFunction: ExponentialEase;
  35551. /**
  35552. * The easing mode used by animations
  35553. */
  35554. static EasingMode: number;
  35555. /**
  35556. * Sets the current mode used by the behavior
  35557. */
  35558. /**
  35559. * Gets current mode used by the behavior.
  35560. */
  35561. mode: number;
  35562. /**
  35563. * Sets the scale applied to the radius (1 by default)
  35564. */
  35565. /**
  35566. * Gets the scale applied to the radius
  35567. */
  35568. radiusScale: number;
  35569. /**
  35570. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35571. */
  35572. /**
  35573. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35574. */
  35575. positionScale: number;
  35576. /**
  35577. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35578. * behaviour is triggered, in radians.
  35579. */
  35580. /**
  35581. * Gets 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. defaultElevation: number;
  35585. /**
  35586. * Sets the time (in milliseconds) taken to return to the default beta position.
  35587. * Negative value indicates camera should not return to default.
  35588. */
  35589. /**
  35590. * Gets the time (in milliseconds) taken to return to the default beta position.
  35591. * Negative value indicates camera should not return to default.
  35592. */
  35593. elevationReturnTime: number;
  35594. /**
  35595. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35596. */
  35597. /**
  35598. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35599. */
  35600. elevationReturnWaitTime: number;
  35601. /**
  35602. * Sets the flag that indicates if user zooming should stop animation.
  35603. */
  35604. /**
  35605. * Gets the flag that indicates if user zooming should stop animation.
  35606. */
  35607. zoomStopsAnimation: boolean;
  35608. /**
  35609. * Sets the transition time when framing the mesh, in milliseconds
  35610. */
  35611. /**
  35612. * Gets the transition time when framing the mesh, in milliseconds
  35613. */
  35614. framingTime: number;
  35615. /**
  35616. * Define if the behavior should automatically change the configured
  35617. * camera limits and sensibilities.
  35618. */
  35619. autoCorrectCameraLimitsAndSensibility: boolean;
  35620. private _onPrePointerObservableObserver;
  35621. private _onAfterCheckInputsObserver;
  35622. private _onMeshTargetChangedObserver;
  35623. private _attachedCamera;
  35624. private _isPointerDown;
  35625. private _lastInteractionTime;
  35626. /**
  35627. * Initializes the behavior.
  35628. */
  35629. init(): void;
  35630. /**
  35631. * Attaches the behavior to its arc rotate camera.
  35632. * @param camera Defines the camera to attach the behavior to
  35633. */
  35634. attach(camera: ArcRotateCamera): void;
  35635. /**
  35636. * Detaches the behavior from its current arc rotate camera.
  35637. */
  35638. detach(): void;
  35639. private _animatables;
  35640. private _betaIsAnimating;
  35641. private _betaTransition;
  35642. private _radiusTransition;
  35643. private _vectorTransition;
  35644. /**
  35645. * Targets the given mesh and updates zoom level accordingly.
  35646. * @param mesh The mesh to target.
  35647. * @param radius Optional. If a cached radius position already exists, overrides default.
  35648. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35651. */
  35652. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35653. /**
  35654. * Targets the given mesh with its children and updates zoom level accordingly.
  35655. * @param mesh The mesh to target.
  35656. * @param radius Optional. If a cached radius position already exists, overrides default.
  35657. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35660. */
  35661. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35662. /**
  35663. * Targets the given meshes with their children and updates zoom level accordingly.
  35664. * @param meshes The mesh to target.
  35665. * @param radius Optional. If a cached radius position already exists, overrides default.
  35666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35669. */
  35670. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35671. /**
  35672. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35673. * @param minimumWorld Determines the smaller position of the bounding box extend
  35674. * @param maximumWorld Determines the bigger position of the bounding box extend
  35675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35677. */
  35678. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35679. /**
  35680. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35681. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35682. * frustum width.
  35683. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35684. * to fully enclose the mesh in the viewing frustum.
  35685. */
  35686. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35687. /**
  35688. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35689. * is automatically returned to its default position (expected to be above ground plane).
  35690. */
  35691. private _maintainCameraAboveGround;
  35692. /**
  35693. * Returns the frustum slope based on the canvas ratio and camera FOV
  35694. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35695. */
  35696. private _getFrustumSlope;
  35697. /**
  35698. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35699. */
  35700. private _clearAnimationLocks;
  35701. /**
  35702. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35703. */
  35704. private _applyUserInteraction;
  35705. /**
  35706. * Stops and removes all animations that have been applied to the camera
  35707. */
  35708. stopAllAnimations(): void;
  35709. /**
  35710. * Gets a value indicating if the user is moving the camera
  35711. */
  35712. readonly isUserIsMoving: boolean;
  35713. /**
  35714. * The camera can move all the way towards the mesh.
  35715. */
  35716. static IgnoreBoundsSizeMode: number;
  35717. /**
  35718. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35719. */
  35720. static FitFrustumSidesMode: number;
  35721. }
  35722. }
  35723. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35724. import { Nullable } from "babylonjs/types";
  35725. import { Camera } from "babylonjs/Cameras/camera";
  35726. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35727. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35728. /**
  35729. * Base class for Camera Pointer Inputs.
  35730. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35731. * for example usage.
  35732. */
  35733. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35734. /**
  35735. * Defines the camera the input is attached to.
  35736. */
  35737. abstract camera: Camera;
  35738. /**
  35739. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35740. */
  35741. protected _altKey: boolean;
  35742. protected _ctrlKey: boolean;
  35743. protected _metaKey: boolean;
  35744. protected _shiftKey: boolean;
  35745. /**
  35746. * Which mouse buttons were pressed at time of last mouse event.
  35747. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35748. */
  35749. protected _buttonsPressed: number;
  35750. /**
  35751. * Defines the buttons associated with the input to handle camera move.
  35752. */
  35753. buttons: number[];
  35754. /**
  35755. * Attach the input controls to a specific dom element to get the input from.
  35756. * @param element Defines the element the controls should be listened from
  35757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35758. */
  35759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35760. /**
  35761. * Detach the current controls from the specified dom element.
  35762. * @param element Defines the element to stop listening the inputs from
  35763. */
  35764. detachControl(element: Nullable<HTMLElement>): void;
  35765. /**
  35766. * Gets the class name of the current input.
  35767. * @returns the class name
  35768. */
  35769. getClassName(): string;
  35770. /**
  35771. * Get the friendly name associated with the input class.
  35772. * @returns the input friendly name
  35773. */
  35774. getSimpleName(): string;
  35775. /**
  35776. * Called on pointer POINTERDOUBLETAP event.
  35777. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35778. */
  35779. protected onDoubleTap(type: string): void;
  35780. /**
  35781. * Called on pointer POINTERMOVE event if only a single touch is active.
  35782. * Override this method to provide functionality.
  35783. */
  35784. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35785. /**
  35786. * Called on pointer POINTERMOVE event if multiple touches are active.
  35787. * Override this method to provide functionality.
  35788. */
  35789. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35790. /**
  35791. * Called on JS contextmenu event.
  35792. * Override this method to provide functionality.
  35793. */
  35794. protected onContextMenu(evt: PointerEvent): void;
  35795. /**
  35796. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35797. * press.
  35798. * Override this method to provide functionality.
  35799. */
  35800. protected onButtonDown(evt: PointerEvent): void;
  35801. /**
  35802. * Called each time a new POINTERUP event occurs. Ie, for each button
  35803. * release.
  35804. * Override this method to provide functionality.
  35805. */
  35806. protected onButtonUp(evt: PointerEvent): void;
  35807. /**
  35808. * Called when window becomes inactive.
  35809. * Override this method to provide functionality.
  35810. */
  35811. protected onLostFocus(): void;
  35812. private _pointerInput;
  35813. private _observer;
  35814. private _onLostFocus;
  35815. private pointA;
  35816. private pointB;
  35817. }
  35818. }
  35819. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35820. import { Nullable } from "babylonjs/types";
  35821. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35822. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35823. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35824. /**
  35825. * Manage the pointers inputs to control an arc rotate camera.
  35826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35827. */
  35828. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35829. /**
  35830. * Defines the camera the input is attached to.
  35831. */
  35832. camera: ArcRotateCamera;
  35833. /**
  35834. * Gets the class name of the current input.
  35835. * @returns the class name
  35836. */
  35837. getClassName(): string;
  35838. /**
  35839. * Defines the buttons associated with the input to handle camera move.
  35840. */
  35841. buttons: number[];
  35842. /**
  35843. * Defines the pointer angular sensibility along the X axis or how fast is
  35844. * the camera rotating.
  35845. */
  35846. angularSensibilityX: number;
  35847. /**
  35848. * Defines the pointer angular sensibility along the Y axis or how fast is
  35849. * the camera rotating.
  35850. */
  35851. angularSensibilityY: number;
  35852. /**
  35853. * Defines the pointer pinch precision or how fast is the camera zooming.
  35854. */
  35855. pinchPrecision: number;
  35856. /**
  35857. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35858. * from 0.
  35859. * It defines the percentage of current camera.radius to use as delta when
  35860. * pinch zoom is used.
  35861. */
  35862. pinchDeltaPercentage: number;
  35863. /**
  35864. * Defines the pointer panning sensibility or how fast is the camera moving.
  35865. */
  35866. panningSensibility: number;
  35867. /**
  35868. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35869. */
  35870. multiTouchPanning: boolean;
  35871. /**
  35872. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35873. * zoom (pinch) through multitouch.
  35874. */
  35875. multiTouchPanAndZoom: boolean;
  35876. /**
  35877. * Revers pinch action direction.
  35878. */
  35879. pinchInwards: boolean;
  35880. private _isPanClick;
  35881. private _twoFingerActivityCount;
  35882. private _isPinching;
  35883. /**
  35884. * Called on pointer POINTERMOVE event if only a single touch is active.
  35885. */
  35886. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35887. /**
  35888. * Called on pointer POINTERDOUBLETAP event.
  35889. */
  35890. protected onDoubleTap(type: string): void;
  35891. /**
  35892. * Called on pointer POINTERMOVE event if multiple touches are active.
  35893. */
  35894. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35895. /**
  35896. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35897. * press.
  35898. */
  35899. protected onButtonDown(evt: PointerEvent): void;
  35900. /**
  35901. * Called each time a new POINTERUP event occurs. Ie, for each button
  35902. * release.
  35903. */
  35904. protected onButtonUp(evt: PointerEvent): void;
  35905. /**
  35906. * Called when window becomes inactive.
  35907. */
  35908. protected onLostFocus(): void;
  35909. }
  35910. }
  35911. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35912. import { Nullable } from "babylonjs/types";
  35913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35914. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35915. /**
  35916. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35918. */
  35919. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35920. /**
  35921. * Defines the camera the input is attached to.
  35922. */
  35923. camera: ArcRotateCamera;
  35924. /**
  35925. * Defines the list of key codes associated with the up action (increase alpha)
  35926. */
  35927. keysUp: number[];
  35928. /**
  35929. * Defines the list of key codes associated with the down action (decrease alpha)
  35930. */
  35931. keysDown: number[];
  35932. /**
  35933. * Defines the list of key codes associated with the left action (increase beta)
  35934. */
  35935. keysLeft: number[];
  35936. /**
  35937. * Defines the list of key codes associated with the right action (decrease beta)
  35938. */
  35939. keysRight: number[];
  35940. /**
  35941. * Defines the list of key codes associated with the reset action.
  35942. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35943. */
  35944. keysReset: number[];
  35945. /**
  35946. * Defines the panning sensibility of the inputs.
  35947. * (How fast is the camera paning)
  35948. */
  35949. panningSensibility: number;
  35950. /**
  35951. * Defines the zooming sensibility of the inputs.
  35952. * (How fast is the camera zooming)
  35953. */
  35954. zoomingSensibility: number;
  35955. /**
  35956. * Defines wether maintaining the alt key down switch the movement mode from
  35957. * orientation to zoom.
  35958. */
  35959. useAltToZoom: boolean;
  35960. /**
  35961. * Rotation speed of the camera
  35962. */
  35963. angularSpeed: number;
  35964. private _keys;
  35965. private _ctrlPressed;
  35966. private _altPressed;
  35967. private _onCanvasBlurObserver;
  35968. private _onKeyboardObserver;
  35969. private _engine;
  35970. private _scene;
  35971. /**
  35972. * Attach the input controls to a specific dom element to get the input from.
  35973. * @param element Defines the element the controls should be listened from
  35974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35975. */
  35976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35977. /**
  35978. * Detach the current controls from the specified dom element.
  35979. * @param element Defines the element to stop listening the inputs from
  35980. */
  35981. detachControl(element: Nullable<HTMLElement>): void;
  35982. /**
  35983. * Update the current camera state depending on the inputs that have been used this frame.
  35984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35985. */
  35986. checkInputs(): void;
  35987. /**
  35988. * Gets the class name of the current intput.
  35989. * @returns the class name
  35990. */
  35991. getClassName(): string;
  35992. /**
  35993. * Get the friendly name associated with the input class.
  35994. * @returns the input friendly name
  35995. */
  35996. getSimpleName(): string;
  35997. }
  35998. }
  35999. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36000. import { Nullable } from "babylonjs/types";
  36001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36002. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36003. /**
  36004. * Manage the mouse wheel inputs to control an arc rotate camera.
  36005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36006. */
  36007. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36008. /**
  36009. * Defines the camera the input is attached to.
  36010. */
  36011. camera: ArcRotateCamera;
  36012. /**
  36013. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36014. */
  36015. wheelPrecision: number;
  36016. /**
  36017. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36018. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36019. */
  36020. wheelDeltaPercentage: number;
  36021. private _wheel;
  36022. private _observer;
  36023. private computeDeltaFromMouseWheelLegacyEvent;
  36024. /**
  36025. * Attach the input controls to a specific dom element to get the input from.
  36026. * @param element Defines the element the controls should be listened from
  36027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36028. */
  36029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36030. /**
  36031. * Detach the current controls from the specified dom element.
  36032. * @param element Defines the element to stop listening the inputs from
  36033. */
  36034. detachControl(element: Nullable<HTMLElement>): void;
  36035. /**
  36036. * Gets the class name of the current intput.
  36037. * @returns the class name
  36038. */
  36039. getClassName(): string;
  36040. /**
  36041. * Get the friendly name associated with the input class.
  36042. * @returns the input friendly name
  36043. */
  36044. getSimpleName(): string;
  36045. }
  36046. }
  36047. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36049. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36050. /**
  36051. * Default Inputs manager for the ArcRotateCamera.
  36052. * It groups all the default supported inputs for ease of use.
  36053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36054. */
  36055. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36056. /**
  36057. * Instantiates a new ArcRotateCameraInputsManager.
  36058. * @param camera Defines the camera the inputs belong to
  36059. */
  36060. constructor(camera: ArcRotateCamera);
  36061. /**
  36062. * Add mouse wheel input support to the input manager.
  36063. * @returns the current input manager
  36064. */
  36065. addMouseWheel(): ArcRotateCameraInputsManager;
  36066. /**
  36067. * Add pointers input support to the input manager.
  36068. * @returns the current input manager
  36069. */
  36070. addPointers(): ArcRotateCameraInputsManager;
  36071. /**
  36072. * Add keyboard input support to the input manager.
  36073. * @returns the current input manager
  36074. */
  36075. addKeyboard(): ArcRotateCameraInputsManager;
  36076. }
  36077. }
  36078. declare module "babylonjs/Cameras/arcRotateCamera" {
  36079. import { Observable } from "babylonjs/Misc/observable";
  36080. import { Nullable } from "babylonjs/types";
  36081. import { Scene } from "babylonjs/scene";
  36082. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36084. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36085. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36086. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36087. import { Camera } from "babylonjs/Cameras/camera";
  36088. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36089. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36090. import { Collider } from "babylonjs/Collisions/collider";
  36091. /**
  36092. * This represents an orbital type of camera.
  36093. *
  36094. * 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.
  36095. * 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.
  36096. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36097. */
  36098. export class ArcRotateCamera extends TargetCamera {
  36099. /**
  36100. * Defines the rotation angle of the camera along the longitudinal axis.
  36101. */
  36102. alpha: number;
  36103. /**
  36104. * Defines the rotation angle of the camera along the latitudinal axis.
  36105. */
  36106. beta: number;
  36107. /**
  36108. * Defines the radius of the camera from it s target point.
  36109. */
  36110. radius: number;
  36111. protected _target: Vector3;
  36112. protected _targetHost: Nullable<AbstractMesh>;
  36113. /**
  36114. * Defines the target point of the camera.
  36115. * The camera looks towards it form the radius distance.
  36116. */
  36117. target: Vector3;
  36118. /**
  36119. * Define the current local position of the camera in the scene
  36120. */
  36121. position: Vector3;
  36122. protected _upVector: Vector3;
  36123. protected _upToYMatrix: Matrix;
  36124. protected _YToUpMatrix: Matrix;
  36125. /**
  36126. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36127. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36128. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36129. */
  36130. upVector: Vector3;
  36131. /**
  36132. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36133. */
  36134. setMatUp(): void;
  36135. /**
  36136. * Current inertia value on the longitudinal axis.
  36137. * The bigger this number the longer it will take for the camera to stop.
  36138. */
  36139. inertialAlphaOffset: number;
  36140. /**
  36141. * Current inertia value on the latitudinal axis.
  36142. * The bigger this number the longer it will take for the camera to stop.
  36143. */
  36144. inertialBetaOffset: number;
  36145. /**
  36146. * Current inertia value on the radius axis.
  36147. * The bigger this number the longer it will take for the camera to stop.
  36148. */
  36149. inertialRadiusOffset: number;
  36150. /**
  36151. * Minimum allowed angle on the longitudinal axis.
  36152. * This can help limiting how the Camera is able to move in the scene.
  36153. */
  36154. lowerAlphaLimit: Nullable<number>;
  36155. /**
  36156. * Maximum allowed angle on the longitudinal axis.
  36157. * This can help limiting how the Camera is able to move in the scene.
  36158. */
  36159. upperAlphaLimit: Nullable<number>;
  36160. /**
  36161. * Minimum allowed angle on the latitudinal axis.
  36162. * This can help limiting how the Camera is able to move in the scene.
  36163. */
  36164. lowerBetaLimit: number;
  36165. /**
  36166. * Maximum allowed angle on the latitudinal axis.
  36167. * This can help limiting how the Camera is able to move in the scene.
  36168. */
  36169. upperBetaLimit: number;
  36170. /**
  36171. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36172. * This can help limiting how the Camera is able to move in the scene.
  36173. */
  36174. lowerRadiusLimit: Nullable<number>;
  36175. /**
  36176. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36177. * This can help limiting how the Camera is able to move in the scene.
  36178. */
  36179. upperRadiusLimit: Nullable<number>;
  36180. /**
  36181. * Defines the current inertia value used during panning of the camera along the X axis.
  36182. */
  36183. inertialPanningX: number;
  36184. /**
  36185. * Defines the current inertia value used during panning of the camera along the Y axis.
  36186. */
  36187. inertialPanningY: number;
  36188. /**
  36189. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36190. * Basically if your fingers moves away from more than this distance you will be considered
  36191. * in pinch mode.
  36192. */
  36193. pinchToPanMaxDistance: number;
  36194. /**
  36195. * Defines the maximum distance the camera can pan.
  36196. * This could help keeping the cammera always in your scene.
  36197. */
  36198. panningDistanceLimit: Nullable<number>;
  36199. /**
  36200. * Defines the target of the camera before paning.
  36201. */
  36202. panningOriginTarget: Vector3;
  36203. /**
  36204. * Defines the value of the inertia used during panning.
  36205. * 0 would mean stop inertia and one would mean no decelleration at all.
  36206. */
  36207. panningInertia: number;
  36208. /**
  36209. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36210. */
  36211. angularSensibilityX: number;
  36212. /**
  36213. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36214. */
  36215. angularSensibilityY: number;
  36216. /**
  36217. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36218. */
  36219. pinchPrecision: number;
  36220. /**
  36221. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36222. * It will be used instead of pinchDeltaPrecision if different from 0.
  36223. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36224. */
  36225. pinchDeltaPercentage: number;
  36226. /**
  36227. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36228. */
  36229. panningSensibility: number;
  36230. /**
  36231. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36232. */
  36233. keysUp: number[];
  36234. /**
  36235. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36236. */
  36237. keysDown: number[];
  36238. /**
  36239. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36240. */
  36241. keysLeft: number[];
  36242. /**
  36243. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36244. */
  36245. keysRight: number[];
  36246. /**
  36247. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36248. */
  36249. wheelPrecision: number;
  36250. /**
  36251. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36252. * It will be used instead of pinchDeltaPrecision if different from 0.
  36253. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36254. */
  36255. wheelDeltaPercentage: number;
  36256. /**
  36257. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36258. */
  36259. zoomOnFactor: number;
  36260. /**
  36261. * Defines a screen offset for the camera position.
  36262. */
  36263. targetScreenOffset: Vector2;
  36264. /**
  36265. * Allows the camera to be completely reversed.
  36266. * If false the camera can not arrive upside down.
  36267. */
  36268. allowUpsideDown: boolean;
  36269. /**
  36270. * Define if double tap/click is used to restore the previously saved state of the camera.
  36271. */
  36272. useInputToRestoreState: boolean;
  36273. /** @hidden */
  36274. _viewMatrix: Matrix;
  36275. /** @hidden */
  36276. _useCtrlForPanning: boolean;
  36277. /** @hidden */
  36278. _panningMouseButton: number;
  36279. /**
  36280. * Defines the input associated to the camera.
  36281. */
  36282. inputs: ArcRotateCameraInputsManager;
  36283. /** @hidden */
  36284. _reset: () => void;
  36285. /**
  36286. * Defines the allowed panning axis.
  36287. */
  36288. panningAxis: Vector3;
  36289. protected _localDirection: Vector3;
  36290. protected _transformedDirection: Vector3;
  36291. private _bouncingBehavior;
  36292. /**
  36293. * Gets the bouncing behavior of the camera if it has been enabled.
  36294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36295. */
  36296. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36297. /**
  36298. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36300. */
  36301. useBouncingBehavior: boolean;
  36302. private _framingBehavior;
  36303. /**
  36304. * Gets the framing behavior of the camera if it has been enabled.
  36305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36306. */
  36307. readonly framingBehavior: Nullable<FramingBehavior>;
  36308. /**
  36309. * Defines if the framing behavior of the camera is enabled on the camera.
  36310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36311. */
  36312. useFramingBehavior: boolean;
  36313. private _autoRotationBehavior;
  36314. /**
  36315. * Gets the auto rotation behavior of the camera if it has been enabled.
  36316. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36317. */
  36318. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36319. /**
  36320. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36322. */
  36323. useAutoRotationBehavior: boolean;
  36324. /**
  36325. * Observable triggered when the mesh target has been changed on the camera.
  36326. */
  36327. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36328. /**
  36329. * Event raised when the camera is colliding with a mesh.
  36330. */
  36331. onCollide: (collidedMesh: AbstractMesh) => void;
  36332. /**
  36333. * Defines whether the camera should check collision with the objects oh the scene.
  36334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36335. */
  36336. checkCollisions: boolean;
  36337. /**
  36338. * Defines the collision radius of the camera.
  36339. * This simulates a sphere around the camera.
  36340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36341. */
  36342. collisionRadius: Vector3;
  36343. protected _collider: Collider;
  36344. protected _previousPosition: Vector3;
  36345. protected _collisionVelocity: Vector3;
  36346. protected _newPosition: Vector3;
  36347. protected _previousAlpha: number;
  36348. protected _previousBeta: number;
  36349. protected _previousRadius: number;
  36350. protected _collisionTriggered: boolean;
  36351. protected _targetBoundingCenter: Nullable<Vector3>;
  36352. private _computationVector;
  36353. /**
  36354. * Instantiates a new ArcRotateCamera in a given scene
  36355. * @param name Defines the name of the camera
  36356. * @param alpha Defines the camera rotation along the logitudinal axis
  36357. * @param beta Defines the camera rotation along the latitudinal axis
  36358. * @param radius Defines the camera distance from its target
  36359. * @param target Defines the camera target
  36360. * @param scene Defines the scene the camera belongs to
  36361. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36362. */
  36363. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36364. /** @hidden */
  36365. _initCache(): void;
  36366. /** @hidden */
  36367. _updateCache(ignoreParentClass?: boolean): void;
  36368. protected _getTargetPosition(): Vector3;
  36369. private _storedAlpha;
  36370. private _storedBeta;
  36371. private _storedRadius;
  36372. private _storedTarget;
  36373. /**
  36374. * Stores the current state of the camera (alpha, beta, radius and target)
  36375. * @returns the camera itself
  36376. */
  36377. storeState(): Camera;
  36378. /**
  36379. * @hidden
  36380. * Restored camera state. You must call storeState() first
  36381. */
  36382. _restoreStateValues(): boolean;
  36383. /** @hidden */
  36384. _isSynchronizedViewMatrix(): boolean;
  36385. /**
  36386. * Attached controls to the current camera.
  36387. * @param element Defines the element the controls should be listened from
  36388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36389. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36390. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36391. */
  36392. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36393. /**
  36394. * Detach the current controls from the camera.
  36395. * The camera will stop reacting to inputs.
  36396. * @param element Defines the element to stop listening the inputs from
  36397. */
  36398. detachControl(element: HTMLElement): void;
  36399. /** @hidden */
  36400. _checkInputs(): void;
  36401. protected _checkLimits(): void;
  36402. /**
  36403. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36404. */
  36405. rebuildAnglesAndRadius(): void;
  36406. /**
  36407. * Use a position to define the current camera related information like aplha, beta and radius
  36408. * @param position Defines the position to set the camera at
  36409. */
  36410. setPosition(position: Vector3): void;
  36411. /**
  36412. * Defines the target the camera should look at.
  36413. * This will automatically adapt alpha beta and radius to fit within the new target.
  36414. * @param target Defines the new target as a Vector or a mesh
  36415. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36416. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36417. */
  36418. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36419. /** @hidden */
  36420. _getViewMatrix(): Matrix;
  36421. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36422. /**
  36423. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36424. * @param meshes Defines the mesh to zoom on
  36425. * @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)
  36426. */
  36427. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36428. /**
  36429. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36430. * The target will be changed but the radius
  36431. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36432. * @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)
  36433. */
  36434. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36435. min: Vector3;
  36436. max: Vector3;
  36437. distance: number;
  36438. }, doNotUpdateMaxZ?: boolean): void;
  36439. /**
  36440. * @override
  36441. * Override Camera.createRigCamera
  36442. */
  36443. createRigCamera(name: string, cameraIndex: number): Camera;
  36444. /**
  36445. * @hidden
  36446. * @override
  36447. * Override Camera._updateRigCameras
  36448. */
  36449. _updateRigCameras(): void;
  36450. /**
  36451. * Destroy the camera and release the current resources hold by it.
  36452. */
  36453. dispose(): void;
  36454. /**
  36455. * Gets the current object class name.
  36456. * @return the class name
  36457. */
  36458. getClassName(): string;
  36459. }
  36460. }
  36461. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36462. import { Behavior } from "babylonjs/Behaviors/behavior";
  36463. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36464. /**
  36465. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36467. */
  36468. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36469. /**
  36470. * Gets the name of the behavior.
  36471. */
  36472. readonly name: string;
  36473. private _zoomStopsAnimation;
  36474. private _idleRotationSpeed;
  36475. private _idleRotationWaitTime;
  36476. private _idleRotationSpinupTime;
  36477. /**
  36478. * Sets the flag that indicates if user zooming should stop animation.
  36479. */
  36480. /**
  36481. * Gets the flag that indicates if user zooming should stop animation.
  36482. */
  36483. zoomStopsAnimation: boolean;
  36484. /**
  36485. * Sets the default speed at which the camera rotates around the model.
  36486. */
  36487. /**
  36488. * Gets the default speed at which the camera rotates around the model.
  36489. */
  36490. idleRotationSpeed: number;
  36491. /**
  36492. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36493. */
  36494. /**
  36495. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36496. */
  36497. idleRotationWaitTime: number;
  36498. /**
  36499. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36500. */
  36501. /**
  36502. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36503. */
  36504. idleRotationSpinupTime: number;
  36505. /**
  36506. * Gets a value indicating if the camera is currently rotating because of this behavior
  36507. */
  36508. readonly rotationInProgress: boolean;
  36509. private _onPrePointerObservableObserver;
  36510. private _onAfterCheckInputsObserver;
  36511. private _attachedCamera;
  36512. private _isPointerDown;
  36513. private _lastFrameTime;
  36514. private _lastInteractionTime;
  36515. private _cameraRotationSpeed;
  36516. /**
  36517. * Initializes the behavior.
  36518. */
  36519. init(): void;
  36520. /**
  36521. * Attaches the behavior to its arc rotate camera.
  36522. * @param camera Defines the camera to attach the behavior to
  36523. */
  36524. attach(camera: ArcRotateCamera): void;
  36525. /**
  36526. * Detaches the behavior from its current arc rotate camera.
  36527. */
  36528. detach(): void;
  36529. /**
  36530. * Returns true if user is scrolling.
  36531. * @return true if user is scrolling.
  36532. */
  36533. private _userIsZooming;
  36534. private _lastFrameRadius;
  36535. private _shouldAnimationStopForInteraction;
  36536. /**
  36537. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36538. */
  36539. private _applyUserInteraction;
  36540. private _userIsMoving;
  36541. }
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/index" {
  36544. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36545. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36546. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36547. }
  36548. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36549. import { Mesh } from "babylonjs/Meshes/mesh";
  36550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36551. import { Behavior } from "babylonjs/Behaviors/behavior";
  36552. /**
  36553. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36554. */
  36555. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36556. private ui;
  36557. /**
  36558. * The name of the behavior
  36559. */
  36560. name: string;
  36561. /**
  36562. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36563. */
  36564. distanceAwayFromFace: number;
  36565. /**
  36566. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36567. */
  36568. distanceAwayFromBottomOfFace: number;
  36569. private _faceVectors;
  36570. private _target;
  36571. private _scene;
  36572. private _onRenderObserver;
  36573. private _tmpMatrix;
  36574. private _tmpVector;
  36575. /**
  36576. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36577. * @param ui The transform node that should be attched to the mesh
  36578. */
  36579. constructor(ui: TransformNode);
  36580. /**
  36581. * Initializes the behavior
  36582. */
  36583. init(): void;
  36584. private _closestFace;
  36585. private _zeroVector;
  36586. private _lookAtTmpMatrix;
  36587. private _lookAtToRef;
  36588. /**
  36589. * Attaches the AttachToBoxBehavior to the passed in mesh
  36590. * @param target The mesh that the specified node will be attached to
  36591. */
  36592. attach(target: Mesh): void;
  36593. /**
  36594. * Detaches the behavior from the mesh
  36595. */
  36596. detach(): void;
  36597. }
  36598. }
  36599. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36600. import { Behavior } from "babylonjs/Behaviors/behavior";
  36601. import { Mesh } from "babylonjs/Meshes/mesh";
  36602. /**
  36603. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36604. */
  36605. export class FadeInOutBehavior implements Behavior<Mesh> {
  36606. /**
  36607. * Time in milliseconds to delay before fading in (Default: 0)
  36608. */
  36609. delay: number;
  36610. /**
  36611. * Time in milliseconds for the mesh to fade in (Default: 300)
  36612. */
  36613. fadeInTime: number;
  36614. private _millisecondsPerFrame;
  36615. private _hovered;
  36616. private _hoverValue;
  36617. private _ownerNode;
  36618. /**
  36619. * Instatiates the FadeInOutBehavior
  36620. */
  36621. constructor();
  36622. /**
  36623. * The name of the behavior
  36624. */
  36625. readonly name: string;
  36626. /**
  36627. * Initializes the behavior
  36628. */
  36629. init(): void;
  36630. /**
  36631. * Attaches the fade behavior on the passed in mesh
  36632. * @param ownerNode The mesh that will be faded in/out once attached
  36633. */
  36634. attach(ownerNode: Mesh): void;
  36635. /**
  36636. * Detaches the behavior from the mesh
  36637. */
  36638. detach(): void;
  36639. /**
  36640. * Triggers the mesh to begin fading in or out
  36641. * @param value if the object should fade in or out (true to fade in)
  36642. */
  36643. fadeIn(value: boolean): void;
  36644. private _update;
  36645. private _setAllVisibility;
  36646. }
  36647. }
  36648. declare module "babylonjs/Misc/pivotTools" {
  36649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36650. /**
  36651. * Class containing a set of static utilities functions for managing Pivots
  36652. * @hidden
  36653. */
  36654. export class PivotTools {
  36655. private static _PivotCached;
  36656. private static _OldPivotPoint;
  36657. private static _PivotTranslation;
  36658. private static _PivotTmpVector;
  36659. /** @hidden */
  36660. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36661. /** @hidden */
  36662. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36663. }
  36664. }
  36665. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36666. import { Scene } from "babylonjs/scene";
  36667. import { Vector4, Plane } from "babylonjs/Maths/math";
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. import { Nullable } from "babylonjs/types";
  36670. /**
  36671. * Class containing static functions to help procedurally build meshes
  36672. */
  36673. export class PlaneBuilder {
  36674. /**
  36675. * Creates a plane mesh
  36676. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36677. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36678. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36682. * @param name defines the name of the mesh
  36683. * @param options defines the options used to create the mesh
  36684. * @param scene defines the hosting scene
  36685. * @returns the plane mesh
  36686. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36687. */
  36688. static CreatePlane(name: string, options: {
  36689. size?: number;
  36690. width?: number;
  36691. height?: number;
  36692. sideOrientation?: number;
  36693. frontUVs?: Vector4;
  36694. backUVs?: Vector4;
  36695. updatable?: boolean;
  36696. sourcePlane?: Plane;
  36697. }, scene?: Nullable<Scene>): Mesh;
  36698. }
  36699. }
  36700. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36701. import { Behavior } from "babylonjs/Behaviors/behavior";
  36702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36703. import { Observable } from "babylonjs/Misc/observable";
  36704. import { Vector3 } from "babylonjs/Maths/math";
  36705. import { Ray } from "babylonjs/Culling/ray";
  36706. import "babylonjs/Meshes/Builders/planeBuilder";
  36707. /**
  36708. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36709. */
  36710. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36711. private static _AnyMouseID;
  36712. private _attachedNode;
  36713. private _dragPlane;
  36714. private _scene;
  36715. private _pointerObserver;
  36716. private _beforeRenderObserver;
  36717. private static _planeScene;
  36718. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36719. /**
  36720. * 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)
  36721. */
  36722. maxDragAngle: number;
  36723. /**
  36724. * @hidden
  36725. */
  36726. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36727. /**
  36728. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36729. */
  36730. currentDraggingPointerID: number;
  36731. /**
  36732. * The last position where the pointer hit the drag plane in world space
  36733. */
  36734. lastDragPosition: Vector3;
  36735. /**
  36736. * If the behavior is currently in a dragging state
  36737. */
  36738. dragging: boolean;
  36739. /**
  36740. * 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)
  36741. */
  36742. dragDeltaRatio: number;
  36743. /**
  36744. * If the drag plane orientation should be updated during the dragging (Default: true)
  36745. */
  36746. updateDragPlane: boolean;
  36747. private _debugMode;
  36748. private _moving;
  36749. /**
  36750. * Fires each time the attached mesh is dragged with the pointer
  36751. * * delta between last drag position and current drag position in world space
  36752. * * dragDistance along the drag axis
  36753. * * dragPlaneNormal normal of the current drag plane used during the drag
  36754. * * dragPlanePoint in world space where the drag intersects the drag plane
  36755. */
  36756. onDragObservable: Observable<{
  36757. delta: Vector3;
  36758. dragPlanePoint: Vector3;
  36759. dragPlaneNormal: Vector3;
  36760. dragDistance: number;
  36761. pointerId: number;
  36762. }>;
  36763. /**
  36764. * Fires each time a drag begins (eg. mouse down on mesh)
  36765. */
  36766. onDragStartObservable: Observable<{
  36767. dragPlanePoint: Vector3;
  36768. pointerId: number;
  36769. }>;
  36770. /**
  36771. * Fires each time a drag ends (eg. mouse release after drag)
  36772. */
  36773. onDragEndObservable: Observable<{
  36774. dragPlanePoint: Vector3;
  36775. pointerId: number;
  36776. }>;
  36777. /**
  36778. * If the attached mesh should be moved when dragged
  36779. */
  36780. moveAttached: boolean;
  36781. /**
  36782. * If the drag behavior will react to drag events (Default: true)
  36783. */
  36784. enabled: boolean;
  36785. /**
  36786. * If camera controls should be detached during the drag
  36787. */
  36788. detachCameraControls: boolean;
  36789. /**
  36790. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36791. */
  36792. useObjectOrienationForDragging: boolean;
  36793. private _options;
  36794. /**
  36795. * Creates a pointer drag behavior that can be attached to a mesh
  36796. * @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)
  36797. */
  36798. constructor(options?: {
  36799. dragAxis?: Vector3;
  36800. dragPlaneNormal?: Vector3;
  36801. });
  36802. /**
  36803. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36804. */
  36805. validateDrag: (targetPosition: Vector3) => boolean;
  36806. /**
  36807. * The name of the behavior
  36808. */
  36809. readonly name: string;
  36810. /**
  36811. * Initializes the behavior
  36812. */
  36813. init(): void;
  36814. private _tmpVector;
  36815. private _alternatePickedPoint;
  36816. private _worldDragAxis;
  36817. private _targetPosition;
  36818. private _attachedElement;
  36819. /**
  36820. * Attaches the drag behavior the passed in mesh
  36821. * @param ownerNode The mesh that will be dragged around once attached
  36822. */
  36823. attach(ownerNode: AbstractMesh): void;
  36824. /**
  36825. * Force relase the drag action by code.
  36826. */
  36827. releaseDrag(): void;
  36828. private _startDragRay;
  36829. private _lastPointerRay;
  36830. /**
  36831. * Simulates the start of a pointer drag event on the behavior
  36832. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36833. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36834. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36835. */
  36836. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36837. private _startDrag;
  36838. private _dragDelta;
  36839. private _moveDrag;
  36840. private _pickWithRayOnDragPlane;
  36841. private _pointA;
  36842. private _pointB;
  36843. private _pointC;
  36844. private _lineA;
  36845. private _lineB;
  36846. private _localAxis;
  36847. private _lookAt;
  36848. private _updateDragPlanePosition;
  36849. /**
  36850. * Detaches the behavior from the mesh
  36851. */
  36852. detach(): void;
  36853. }
  36854. }
  36855. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36856. import { Mesh } from "babylonjs/Meshes/mesh";
  36857. import { Behavior } from "babylonjs/Behaviors/behavior";
  36858. /**
  36859. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36860. */
  36861. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36862. private _dragBehaviorA;
  36863. private _dragBehaviorB;
  36864. private _startDistance;
  36865. private _initialScale;
  36866. private _targetScale;
  36867. private _ownerNode;
  36868. private _sceneRenderObserver;
  36869. /**
  36870. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36871. */
  36872. constructor();
  36873. /**
  36874. * The name of the behavior
  36875. */
  36876. readonly name: string;
  36877. /**
  36878. * Initializes the behavior
  36879. */
  36880. init(): void;
  36881. private _getCurrentDistance;
  36882. /**
  36883. * Attaches the scale behavior the passed in mesh
  36884. * @param ownerNode The mesh that will be scaled around once attached
  36885. */
  36886. attach(ownerNode: Mesh): void;
  36887. /**
  36888. * Detaches the behavior from the mesh
  36889. */
  36890. detach(): void;
  36891. }
  36892. }
  36893. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36894. import { Behavior } from "babylonjs/Behaviors/behavior";
  36895. import { Mesh } from "babylonjs/Meshes/mesh";
  36896. import { Observable } from "babylonjs/Misc/observable";
  36897. /**
  36898. * 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
  36899. */
  36900. export class SixDofDragBehavior implements Behavior<Mesh> {
  36901. private static _virtualScene;
  36902. private _ownerNode;
  36903. private _sceneRenderObserver;
  36904. private _scene;
  36905. private _targetPosition;
  36906. private _virtualOriginMesh;
  36907. private _virtualDragMesh;
  36908. private _pointerObserver;
  36909. private _moving;
  36910. private _startingOrientation;
  36911. /**
  36912. * 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)
  36913. */
  36914. private zDragFactor;
  36915. /**
  36916. * If the object should rotate to face the drag origin
  36917. */
  36918. rotateDraggedObject: boolean;
  36919. /**
  36920. * If the behavior is currently in a dragging state
  36921. */
  36922. dragging: boolean;
  36923. /**
  36924. * 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)
  36925. */
  36926. dragDeltaRatio: number;
  36927. /**
  36928. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36929. */
  36930. currentDraggingPointerID: number;
  36931. /**
  36932. * If camera controls should be detached during the drag
  36933. */
  36934. detachCameraControls: boolean;
  36935. /**
  36936. * Fires each time a drag starts
  36937. */
  36938. onDragStartObservable: Observable<{}>;
  36939. /**
  36940. * Fires each time a drag ends (eg. mouse release after drag)
  36941. */
  36942. onDragEndObservable: Observable<{}>;
  36943. /**
  36944. * 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
  36945. */
  36946. constructor();
  36947. /**
  36948. * The name of the behavior
  36949. */
  36950. readonly name: string;
  36951. /**
  36952. * Initializes the behavior
  36953. */
  36954. init(): void;
  36955. /**
  36956. * Attaches the scale behavior the passed in mesh
  36957. * @param ownerNode The mesh that will be scaled around once attached
  36958. */
  36959. attach(ownerNode: Mesh): void;
  36960. /**
  36961. * Detaches the behavior from the mesh
  36962. */
  36963. detach(): void;
  36964. }
  36965. }
  36966. declare module "babylonjs/Behaviors/Meshes/index" {
  36967. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36968. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36969. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36970. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36971. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36972. }
  36973. declare module "babylonjs/Behaviors/index" {
  36974. export * from "babylonjs/Behaviors/behavior";
  36975. export * from "babylonjs/Behaviors/Cameras/index";
  36976. export * from "babylonjs/Behaviors/Meshes/index";
  36977. }
  36978. declare module "babylonjs/Bones/boneIKController" {
  36979. import { Bone } from "babylonjs/Bones/bone";
  36980. import { Vector3 } from "babylonjs/Maths/math";
  36981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36982. import { Nullable } from "babylonjs/types";
  36983. /**
  36984. * Class used to apply inverse kinematics to bones
  36985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36986. */
  36987. export class BoneIKController {
  36988. private static _tmpVecs;
  36989. private static _tmpQuat;
  36990. private static _tmpMats;
  36991. /**
  36992. * Gets or sets the target mesh
  36993. */
  36994. targetMesh: AbstractMesh;
  36995. /** Gets or sets the mesh used as pole */
  36996. poleTargetMesh: AbstractMesh;
  36997. /**
  36998. * Gets or sets the bone used as pole
  36999. */
  37000. poleTargetBone: Nullable<Bone>;
  37001. /**
  37002. * Gets or sets the target position
  37003. */
  37004. targetPosition: Vector3;
  37005. /**
  37006. * Gets or sets the pole target position
  37007. */
  37008. poleTargetPosition: Vector3;
  37009. /**
  37010. * Gets or sets the pole target local offset
  37011. */
  37012. poleTargetLocalOffset: Vector3;
  37013. /**
  37014. * Gets or sets the pole angle
  37015. */
  37016. poleAngle: number;
  37017. /**
  37018. * Gets or sets the mesh associated with the controller
  37019. */
  37020. mesh: AbstractMesh;
  37021. /**
  37022. * 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)
  37023. */
  37024. slerpAmount: number;
  37025. private _bone1Quat;
  37026. private _bone1Mat;
  37027. private _bone2Ang;
  37028. private _bone1;
  37029. private _bone2;
  37030. private _bone1Length;
  37031. private _bone2Length;
  37032. private _maxAngle;
  37033. private _maxReach;
  37034. private _rightHandedSystem;
  37035. private _bendAxis;
  37036. private _slerping;
  37037. private _adjustRoll;
  37038. /**
  37039. * Gets or sets maximum allowed angle
  37040. */
  37041. maxAngle: number;
  37042. /**
  37043. * Creates a new BoneIKController
  37044. * @param mesh defines the mesh to control
  37045. * @param bone defines the bone to control
  37046. * @param options defines options to set up the controller
  37047. */
  37048. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37049. targetMesh?: AbstractMesh;
  37050. poleTargetMesh?: AbstractMesh;
  37051. poleTargetBone?: Bone;
  37052. poleTargetLocalOffset?: Vector3;
  37053. poleAngle?: number;
  37054. bendAxis?: Vector3;
  37055. maxAngle?: number;
  37056. slerpAmount?: number;
  37057. });
  37058. private _setMaxAngle;
  37059. /**
  37060. * Force the controller to update the bones
  37061. */
  37062. update(): void;
  37063. }
  37064. }
  37065. declare module "babylonjs/Bones/boneLookController" {
  37066. import { Vector3, Space } from "babylonjs/Maths/math";
  37067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37068. import { Bone } from "babylonjs/Bones/bone";
  37069. /**
  37070. * Class used to make a bone look toward a point in space
  37071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37072. */
  37073. export class BoneLookController {
  37074. private static _tmpVecs;
  37075. private static _tmpQuat;
  37076. private static _tmpMats;
  37077. /**
  37078. * The target Vector3 that the bone will look at
  37079. */
  37080. target: Vector3;
  37081. /**
  37082. * The mesh that the bone is attached to
  37083. */
  37084. mesh: AbstractMesh;
  37085. /**
  37086. * The bone that will be looking to the target
  37087. */
  37088. bone: Bone;
  37089. /**
  37090. * The up axis of the coordinate system that is used when the bone is rotated
  37091. */
  37092. upAxis: Vector3;
  37093. /**
  37094. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37095. */
  37096. upAxisSpace: Space;
  37097. /**
  37098. * Used to make an adjustment to the yaw of the bone
  37099. */
  37100. adjustYaw: number;
  37101. /**
  37102. * Used to make an adjustment to the pitch of the bone
  37103. */
  37104. adjustPitch: number;
  37105. /**
  37106. * Used to make an adjustment to the roll of the bone
  37107. */
  37108. adjustRoll: number;
  37109. /**
  37110. * 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)
  37111. */
  37112. slerpAmount: number;
  37113. private _minYaw;
  37114. private _maxYaw;
  37115. private _minPitch;
  37116. private _maxPitch;
  37117. private _minYawSin;
  37118. private _minYawCos;
  37119. private _maxYawSin;
  37120. private _maxYawCos;
  37121. private _midYawConstraint;
  37122. private _minPitchTan;
  37123. private _maxPitchTan;
  37124. private _boneQuat;
  37125. private _slerping;
  37126. private _transformYawPitch;
  37127. private _transformYawPitchInv;
  37128. private _firstFrameSkipped;
  37129. private _yawRange;
  37130. private _fowardAxis;
  37131. /**
  37132. * Gets or sets the minimum yaw angle that the bone can look to
  37133. */
  37134. minYaw: number;
  37135. /**
  37136. * Gets or sets the maximum yaw angle that the bone can look to
  37137. */
  37138. maxYaw: number;
  37139. /**
  37140. * Gets or sets the minimum pitch angle that the bone can look to
  37141. */
  37142. minPitch: number;
  37143. /**
  37144. * Gets or sets the maximum pitch angle that the bone can look to
  37145. */
  37146. maxPitch: number;
  37147. /**
  37148. * Create a BoneLookController
  37149. * @param mesh the mesh that the bone belongs to
  37150. * @param bone the bone that will be looking to the target
  37151. * @param target the target Vector3 to look at
  37152. * @param options optional settings:
  37153. * * maxYaw: the maximum angle the bone will yaw to
  37154. * * minYaw: the minimum angle the bone will yaw to
  37155. * * maxPitch: the maximum angle the bone will pitch to
  37156. * * minPitch: the minimum angle the bone will yaw to
  37157. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37158. * * upAxis: the up axis of the coordinate system
  37159. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37160. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37161. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37162. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37163. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37164. * * adjustRoll: used to make an adjustment to the roll of the bone
  37165. **/
  37166. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37167. maxYaw?: number;
  37168. minYaw?: number;
  37169. maxPitch?: number;
  37170. minPitch?: number;
  37171. slerpAmount?: number;
  37172. upAxis?: Vector3;
  37173. upAxisSpace?: Space;
  37174. yawAxis?: Vector3;
  37175. pitchAxis?: Vector3;
  37176. adjustYaw?: number;
  37177. adjustPitch?: number;
  37178. adjustRoll?: number;
  37179. });
  37180. /**
  37181. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37182. */
  37183. update(): void;
  37184. private _getAngleDiff;
  37185. private _getAngleBetween;
  37186. private _isAngleBetween;
  37187. }
  37188. }
  37189. declare module "babylonjs/Bones/index" {
  37190. export * from "babylonjs/Bones/bone";
  37191. export * from "babylonjs/Bones/boneIKController";
  37192. export * from "babylonjs/Bones/boneLookController";
  37193. export * from "babylonjs/Bones/skeleton";
  37194. }
  37195. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37196. import { Nullable } from "babylonjs/types";
  37197. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37198. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37199. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37200. /**
  37201. * Manage the gamepad inputs to control an arc rotate camera.
  37202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37203. */
  37204. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37205. /**
  37206. * Defines the camera the input is attached to.
  37207. */
  37208. camera: ArcRotateCamera;
  37209. /**
  37210. * Defines the gamepad the input is gathering event from.
  37211. */
  37212. gamepad: Nullable<Gamepad>;
  37213. /**
  37214. * Defines the gamepad rotation sensiblity.
  37215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37216. */
  37217. gamepadRotationSensibility: number;
  37218. /**
  37219. * Defines the gamepad move sensiblity.
  37220. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37221. */
  37222. gamepadMoveSensibility: number;
  37223. private _onGamepadConnectedObserver;
  37224. private _onGamepadDisconnectedObserver;
  37225. /**
  37226. * Attach the input controls to a specific dom element to get the input from.
  37227. * @param element Defines the element the controls should be listened from
  37228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37229. */
  37230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37231. /**
  37232. * Detach the current controls from the specified dom element.
  37233. * @param element Defines the element to stop listening the inputs from
  37234. */
  37235. detachControl(element: Nullable<HTMLElement>): void;
  37236. /**
  37237. * Update the current camera state depending on the inputs that have been used this frame.
  37238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37239. */
  37240. checkInputs(): void;
  37241. /**
  37242. * Gets the class name of the current intput.
  37243. * @returns the class name
  37244. */
  37245. getClassName(): string;
  37246. /**
  37247. * Get the friendly name associated with the input class.
  37248. * @returns the input friendly name
  37249. */
  37250. getSimpleName(): string;
  37251. }
  37252. }
  37253. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37254. import { Nullable } from "babylonjs/types";
  37255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37256. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37257. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37258. interface ArcRotateCameraInputsManager {
  37259. /**
  37260. * Add orientation input support to the input manager.
  37261. * @returns the current input manager
  37262. */
  37263. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37264. }
  37265. }
  37266. /**
  37267. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37269. */
  37270. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37271. /**
  37272. * Defines the camera the input is attached to.
  37273. */
  37274. camera: ArcRotateCamera;
  37275. /**
  37276. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37277. */
  37278. alphaCorrection: number;
  37279. /**
  37280. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37281. */
  37282. gammaCorrection: number;
  37283. private _alpha;
  37284. private _gamma;
  37285. private _dirty;
  37286. private _deviceOrientationHandler;
  37287. /**
  37288. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37289. */
  37290. constructor();
  37291. /**
  37292. * Attach the input controls to a specific dom element to get the input from.
  37293. * @param element Defines the element the controls should be listened from
  37294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37295. */
  37296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37297. /** @hidden */
  37298. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37299. /**
  37300. * Update the current camera state depending on the inputs that have been used this frame.
  37301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37302. */
  37303. checkInputs(): void;
  37304. /**
  37305. * Detach the current controls from the specified dom element.
  37306. * @param element Defines the element to stop listening the inputs from
  37307. */
  37308. detachControl(element: Nullable<HTMLElement>): void;
  37309. /**
  37310. * Gets the class name of the current intput.
  37311. * @returns the class name
  37312. */
  37313. getClassName(): string;
  37314. /**
  37315. * Get the friendly name associated with the input class.
  37316. * @returns the input friendly name
  37317. */
  37318. getSimpleName(): string;
  37319. }
  37320. }
  37321. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37322. import { Nullable } from "babylonjs/types";
  37323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37325. /**
  37326. * Listen to mouse events to control the camera.
  37327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37328. */
  37329. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37330. /**
  37331. * Defines the camera the input is attached to.
  37332. */
  37333. camera: FlyCamera;
  37334. /**
  37335. * Defines if touch is enabled. (Default is true.)
  37336. */
  37337. touchEnabled: boolean;
  37338. /**
  37339. * Defines the buttons associated with the input to handle camera rotation.
  37340. */
  37341. buttons: number[];
  37342. /**
  37343. * Assign buttons for Yaw control.
  37344. */
  37345. buttonsYaw: number[];
  37346. /**
  37347. * Assign buttons for Pitch control.
  37348. */
  37349. buttonsPitch: number[];
  37350. /**
  37351. * Assign buttons for Roll control.
  37352. */
  37353. buttonsRoll: number[];
  37354. /**
  37355. * Detect if any button is being pressed while mouse is moved.
  37356. * -1 = Mouse locked.
  37357. * 0 = Left button.
  37358. * 1 = Middle Button.
  37359. * 2 = Right Button.
  37360. */
  37361. activeButton: number;
  37362. /**
  37363. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37364. * Higher values reduce its sensitivity.
  37365. */
  37366. angularSensibility: number;
  37367. private _mousemoveCallback;
  37368. private _observer;
  37369. private _rollObserver;
  37370. private previousPosition;
  37371. private noPreventDefault;
  37372. private element;
  37373. /**
  37374. * Listen to mouse events to control the camera.
  37375. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37377. */
  37378. constructor(touchEnabled?: boolean);
  37379. /**
  37380. * Attach the mouse control to the HTML DOM element.
  37381. * @param element Defines the element that listens to the input events.
  37382. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37383. */
  37384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37385. /**
  37386. * Detach the current controls from the specified dom element.
  37387. * @param element Defines the element to stop listening the inputs from
  37388. */
  37389. detachControl(element: Nullable<HTMLElement>): void;
  37390. /**
  37391. * Gets the class name of the current input.
  37392. * @returns the class name.
  37393. */
  37394. getClassName(): string;
  37395. /**
  37396. * Get the friendly name associated with the input class.
  37397. * @returns the input's friendly name.
  37398. */
  37399. getSimpleName(): string;
  37400. private _pointerInput;
  37401. private _onMouseMove;
  37402. /**
  37403. * Rotate camera by mouse offset.
  37404. */
  37405. private rotateCamera;
  37406. }
  37407. }
  37408. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37409. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37411. /**
  37412. * Default Inputs manager for the FlyCamera.
  37413. * It groups all the default supported inputs for ease of use.
  37414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37415. */
  37416. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37417. /**
  37418. * Instantiates a new FlyCameraInputsManager.
  37419. * @param camera Defines the camera the inputs belong to.
  37420. */
  37421. constructor(camera: FlyCamera);
  37422. /**
  37423. * Add keyboard input support to the input manager.
  37424. * @returns the new FlyCameraKeyboardMoveInput().
  37425. */
  37426. addKeyboard(): FlyCameraInputsManager;
  37427. /**
  37428. * Add mouse input support to the input manager.
  37429. * @param touchEnabled Enable touch screen support.
  37430. * @returns the new FlyCameraMouseInput().
  37431. */
  37432. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/flyCamera" {
  37436. import { Scene } from "babylonjs/scene";
  37437. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37439. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37440. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37441. /**
  37442. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37443. * such as in a 3D Space Shooter or a Flight Simulator.
  37444. */
  37445. export class FlyCamera extends TargetCamera {
  37446. /**
  37447. * Define the collision ellipsoid of the camera.
  37448. * This is helpful for simulating a camera body, like a player's body.
  37449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37450. */
  37451. ellipsoid: Vector3;
  37452. /**
  37453. * Define an offset for the position of the ellipsoid around the camera.
  37454. * This can be helpful if the camera is attached away from the player's body center,
  37455. * such as at its head.
  37456. */
  37457. ellipsoidOffset: Vector3;
  37458. /**
  37459. * Enable or disable collisions of the camera with the rest of the scene objects.
  37460. */
  37461. checkCollisions: boolean;
  37462. /**
  37463. * Enable or disable gravity on the camera.
  37464. */
  37465. applyGravity: boolean;
  37466. /**
  37467. * Define the current direction the camera is moving to.
  37468. */
  37469. cameraDirection: Vector3;
  37470. /**
  37471. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37472. * This overrides and empties cameraRotation.
  37473. */
  37474. rotationQuaternion: Quaternion;
  37475. /**
  37476. * Track Roll to maintain the wanted Rolling when looking around.
  37477. */
  37478. _trackRoll: number;
  37479. /**
  37480. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37481. */
  37482. rollCorrect: number;
  37483. /**
  37484. * Mimic a banked turn, Rolling the camera when Yawing.
  37485. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37486. */
  37487. bankedTurn: boolean;
  37488. /**
  37489. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37490. */
  37491. bankedTurnLimit: number;
  37492. /**
  37493. * Value of 0 disables the banked Roll.
  37494. * Value of 1 is equal to the Yaw angle in radians.
  37495. */
  37496. bankedTurnMultiplier: number;
  37497. /**
  37498. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37499. */
  37500. inputs: FlyCameraInputsManager;
  37501. /**
  37502. * Gets the input sensibility for mouse input.
  37503. * Higher values reduce sensitivity.
  37504. */
  37505. /**
  37506. * Sets the input sensibility for a mouse input.
  37507. * Higher values reduce sensitivity.
  37508. */
  37509. angularSensibility: number;
  37510. /**
  37511. * Get the keys for camera movement forward.
  37512. */
  37513. /**
  37514. * Set the keys for camera movement forward.
  37515. */
  37516. keysForward: number[];
  37517. /**
  37518. * Get the keys for camera movement backward.
  37519. */
  37520. keysBackward: number[];
  37521. /**
  37522. * Get the keys for camera movement up.
  37523. */
  37524. /**
  37525. * Set the keys for camera movement up.
  37526. */
  37527. keysUp: number[];
  37528. /**
  37529. * Get the keys for camera movement down.
  37530. */
  37531. /**
  37532. * Set the keys for camera movement down.
  37533. */
  37534. keysDown: number[];
  37535. /**
  37536. * Get the keys for camera movement left.
  37537. */
  37538. /**
  37539. * Set the keys for camera movement left.
  37540. */
  37541. keysLeft: number[];
  37542. /**
  37543. * Set the keys for camera movement right.
  37544. */
  37545. /**
  37546. * Set the keys for camera movement right.
  37547. */
  37548. keysRight: number[];
  37549. /**
  37550. * Event raised when the camera collides with a mesh in the scene.
  37551. */
  37552. onCollide: (collidedMesh: AbstractMesh) => void;
  37553. private _collider;
  37554. private _needMoveForGravity;
  37555. private _oldPosition;
  37556. private _diffPosition;
  37557. private _newPosition;
  37558. /** @hidden */
  37559. _localDirection: Vector3;
  37560. /** @hidden */
  37561. _transformedDirection: Vector3;
  37562. /**
  37563. * Instantiates a FlyCamera.
  37564. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37565. * such as in a 3D Space Shooter or a Flight Simulator.
  37566. * @param name Define the name of the camera in the scene.
  37567. * @param position Define the starting position of the camera in the scene.
  37568. * @param scene Define the scene the camera belongs to.
  37569. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37570. */
  37571. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37572. /**
  37573. * Attach a control to the HTML DOM element.
  37574. * @param element Defines the element that listens to the input events.
  37575. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37576. */
  37577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37578. /**
  37579. * Detach a control from the HTML DOM element.
  37580. * The camera will stop reacting to that input.
  37581. * @param element Defines the element that listens to the input events.
  37582. */
  37583. detachControl(element: HTMLElement): void;
  37584. private _collisionMask;
  37585. /**
  37586. * Get the mask that the camera ignores in collision events.
  37587. */
  37588. /**
  37589. * Set the mask that the camera ignores in collision events.
  37590. */
  37591. collisionMask: number;
  37592. /** @hidden */
  37593. _collideWithWorld(displacement: Vector3): void;
  37594. /** @hidden */
  37595. private _onCollisionPositionChange;
  37596. /** @hidden */
  37597. _checkInputs(): void;
  37598. /** @hidden */
  37599. _decideIfNeedsToMove(): boolean;
  37600. /** @hidden */
  37601. _updatePosition(): void;
  37602. /**
  37603. * Restore the Roll to its target value at the rate specified.
  37604. * @param rate - Higher means slower restoring.
  37605. * @hidden
  37606. */
  37607. restoreRoll(rate: number): void;
  37608. /**
  37609. * Destroy the camera and release the current resources held by it.
  37610. */
  37611. dispose(): void;
  37612. /**
  37613. * Get the current object class name.
  37614. * @returns the class name.
  37615. */
  37616. getClassName(): string;
  37617. }
  37618. }
  37619. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37620. import { Nullable } from "babylonjs/types";
  37621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37622. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37623. /**
  37624. * Listen to keyboard events to control the camera.
  37625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37626. */
  37627. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37628. /**
  37629. * Defines the camera the input is attached to.
  37630. */
  37631. camera: FlyCamera;
  37632. /**
  37633. * The list of keyboard keys used to control the forward move of the camera.
  37634. */
  37635. keysForward: number[];
  37636. /**
  37637. * The list of keyboard keys used to control the backward move of the camera.
  37638. */
  37639. keysBackward: number[];
  37640. /**
  37641. * The list of keyboard keys used to control the forward move of the camera.
  37642. */
  37643. keysUp: number[];
  37644. /**
  37645. * The list of keyboard keys used to control the backward move of the camera.
  37646. */
  37647. keysDown: number[];
  37648. /**
  37649. * The list of keyboard keys used to control the right strafe move of the camera.
  37650. */
  37651. keysRight: number[];
  37652. /**
  37653. * The list of keyboard keys used to control the left strafe move of the camera.
  37654. */
  37655. keysLeft: number[];
  37656. private _keys;
  37657. private _onCanvasBlurObserver;
  37658. private _onKeyboardObserver;
  37659. private _engine;
  37660. private _scene;
  37661. /**
  37662. * Attach the input controls to a specific dom element to get the input from.
  37663. * @param element Defines the element the controls should be listened from
  37664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37665. */
  37666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37667. /**
  37668. * Detach the current controls from the specified dom element.
  37669. * @param element Defines the element to stop listening the inputs from
  37670. */
  37671. detachControl(element: Nullable<HTMLElement>): void;
  37672. /**
  37673. * Gets the class name of the current intput.
  37674. * @returns the class name
  37675. */
  37676. getClassName(): string;
  37677. /** @hidden */
  37678. _onLostFocus(e: FocusEvent): void;
  37679. /**
  37680. * Get the friendly name associated with the input class.
  37681. * @returns the input friendly name
  37682. */
  37683. getSimpleName(): string;
  37684. /**
  37685. * Update the current camera state depending on the inputs that have been used this frame.
  37686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37687. */
  37688. checkInputs(): void;
  37689. }
  37690. }
  37691. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37692. import { Nullable } from "babylonjs/types";
  37693. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37694. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37695. /**
  37696. * Manage the mouse wheel inputs to control a follow camera.
  37697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37698. */
  37699. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37700. /**
  37701. * Defines the camera the input is attached to.
  37702. */
  37703. camera: FollowCamera;
  37704. /**
  37705. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37706. */
  37707. axisControlRadius: boolean;
  37708. /**
  37709. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37710. */
  37711. axisControlHeight: boolean;
  37712. /**
  37713. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37714. */
  37715. axisControlRotation: boolean;
  37716. /**
  37717. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37718. * relation to mouseWheel events.
  37719. */
  37720. wheelPrecision: number;
  37721. /**
  37722. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37723. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37724. */
  37725. wheelDeltaPercentage: number;
  37726. private _wheel;
  37727. private _observer;
  37728. /**
  37729. * Attach the input controls to a specific dom element to get the input from.
  37730. * @param element Defines the element the controls should be listened from
  37731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37732. */
  37733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37734. /**
  37735. * Detach the current controls from the specified dom element.
  37736. * @param element Defines the element to stop listening the inputs from
  37737. */
  37738. detachControl(element: Nullable<HTMLElement>): void;
  37739. /**
  37740. * Gets the class name of the current intput.
  37741. * @returns the class name
  37742. */
  37743. getClassName(): string;
  37744. /**
  37745. * Get the friendly name associated with the input class.
  37746. * @returns the input friendly name
  37747. */
  37748. getSimpleName(): string;
  37749. }
  37750. }
  37751. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37752. import { Nullable } from "babylonjs/types";
  37753. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37754. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37755. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37756. /**
  37757. * Manage the pointers inputs to control an follow camera.
  37758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37759. */
  37760. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37761. /**
  37762. * Defines the camera the input is attached to.
  37763. */
  37764. camera: FollowCamera;
  37765. /**
  37766. * Gets the class name of the current input.
  37767. * @returns the class name
  37768. */
  37769. getClassName(): string;
  37770. /**
  37771. * Defines the pointer angular sensibility along the X axis or how fast is
  37772. * the camera rotating.
  37773. * A negative number will reverse the axis direction.
  37774. */
  37775. angularSensibilityX: number;
  37776. /**
  37777. * Defines the pointer angular sensibility along the Y axis or how fast is
  37778. * the camera rotating.
  37779. * A negative number will reverse the axis direction.
  37780. */
  37781. angularSensibilityY: number;
  37782. /**
  37783. * Defines the pointer pinch precision or how fast is the camera zooming.
  37784. * A negative number will reverse the axis direction.
  37785. */
  37786. pinchPrecision: number;
  37787. /**
  37788. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37789. * from 0.
  37790. * It defines the percentage of current camera.radius to use as delta when
  37791. * pinch zoom is used.
  37792. */
  37793. pinchDeltaPercentage: number;
  37794. /**
  37795. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37796. */
  37797. axisXControlRadius: boolean;
  37798. /**
  37799. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37800. */
  37801. axisXControlHeight: boolean;
  37802. /**
  37803. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37804. */
  37805. axisXControlRotation: boolean;
  37806. /**
  37807. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37808. */
  37809. axisYControlRadius: boolean;
  37810. /**
  37811. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37812. */
  37813. axisYControlHeight: boolean;
  37814. /**
  37815. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37816. */
  37817. axisYControlRotation: boolean;
  37818. /**
  37819. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37820. */
  37821. axisPinchControlRadius: boolean;
  37822. /**
  37823. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37824. */
  37825. axisPinchControlHeight: boolean;
  37826. /**
  37827. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37828. */
  37829. axisPinchControlRotation: boolean;
  37830. /**
  37831. * Log error messages if basic misconfiguration has occurred.
  37832. */
  37833. warningEnable: boolean;
  37834. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37835. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37836. private _warningCounter;
  37837. private _warning;
  37838. }
  37839. }
  37840. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37841. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37842. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37843. /**
  37844. * Default Inputs manager for the FollowCamera.
  37845. * It groups all the default supported inputs for ease of use.
  37846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37847. */
  37848. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37849. /**
  37850. * Instantiates a new FollowCameraInputsManager.
  37851. * @param camera Defines the camera the inputs belong to
  37852. */
  37853. constructor(camera: FollowCamera);
  37854. /**
  37855. * Add keyboard input support to the input manager.
  37856. * @returns the current input manager
  37857. */
  37858. addKeyboard(): FollowCameraInputsManager;
  37859. /**
  37860. * Add mouse wheel input support to the input manager.
  37861. * @returns the current input manager
  37862. */
  37863. addMouseWheel(): FollowCameraInputsManager;
  37864. /**
  37865. * Add pointers input support to the input manager.
  37866. * @returns the current input manager
  37867. */
  37868. addPointers(): FollowCameraInputsManager;
  37869. /**
  37870. * Add orientation input support to the input manager.
  37871. * @returns the current input manager
  37872. */
  37873. addVRDeviceOrientation(): FollowCameraInputsManager;
  37874. }
  37875. }
  37876. declare module "babylonjs/Cameras/followCamera" {
  37877. import { Nullable } from "babylonjs/types";
  37878. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37879. import { Scene } from "babylonjs/scene";
  37880. import { Vector3 } from "babylonjs/Maths/math";
  37881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37882. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37883. /**
  37884. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37885. * an arc rotate version arcFollowCamera are available.
  37886. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37887. */
  37888. export class FollowCamera extends TargetCamera {
  37889. /**
  37890. * Distance the follow camera should follow an object at
  37891. */
  37892. radius: number;
  37893. /**
  37894. * Minimum allowed distance of the camera to the axis of rotation
  37895. * (The camera can not get closer).
  37896. * This can help limiting how the Camera is able to move in the scene.
  37897. */
  37898. lowerRadiusLimit: Nullable<number>;
  37899. /**
  37900. * Maximum allowed distance of the camera to the axis of rotation
  37901. * (The camera can not get further).
  37902. * This can help limiting how the Camera is able to move in the scene.
  37903. */
  37904. upperRadiusLimit: Nullable<number>;
  37905. /**
  37906. * Define a rotation offset between the camera and the object it follows
  37907. */
  37908. rotationOffset: number;
  37909. /**
  37910. * Minimum allowed angle to camera position relative to target object.
  37911. * This can help limiting how the Camera is able to move in the scene.
  37912. */
  37913. lowerRotationOffsetLimit: Nullable<number>;
  37914. /**
  37915. * Maximum allowed angle to camera position relative to target object.
  37916. * This can help limiting how the Camera is able to move in the scene.
  37917. */
  37918. upperRotationOffsetLimit: Nullable<number>;
  37919. /**
  37920. * Define a height offset between the camera and the object it follows.
  37921. * It can help following an object from the top (like a car chaing a plane)
  37922. */
  37923. heightOffset: number;
  37924. /**
  37925. * Minimum allowed height of camera position relative to target object.
  37926. * This can help limiting how the Camera is able to move in the scene.
  37927. */
  37928. lowerHeightOffsetLimit: Nullable<number>;
  37929. /**
  37930. * Maximum allowed height of camera position relative to target object.
  37931. * This can help limiting how the Camera is able to move in the scene.
  37932. */
  37933. upperHeightOffsetLimit: Nullable<number>;
  37934. /**
  37935. * Define how fast the camera can accelerate to follow it s target.
  37936. */
  37937. cameraAcceleration: number;
  37938. /**
  37939. * Define the speed limit of the camera following an object.
  37940. */
  37941. maxCameraSpeed: number;
  37942. /**
  37943. * Define the target of the camera.
  37944. */
  37945. lockedTarget: Nullable<AbstractMesh>;
  37946. /**
  37947. * Defines the input associated with the camera.
  37948. */
  37949. inputs: FollowCameraInputsManager;
  37950. /**
  37951. * Instantiates the follow camera.
  37952. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37953. * @param name Define the name of the camera in the scene
  37954. * @param position Define the position of the camera
  37955. * @param scene Define the scene the camera belong to
  37956. * @param lockedTarget Define the target of the camera
  37957. */
  37958. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37959. private _follow;
  37960. /**
  37961. * Attached controls to the current camera.
  37962. * @param element Defines the element the controls should be listened from
  37963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37964. */
  37965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37966. /**
  37967. * Detach the current controls from the camera.
  37968. * The camera will stop reacting to inputs.
  37969. * @param element Defines the element to stop listening the inputs from
  37970. */
  37971. detachControl(element: HTMLElement): void;
  37972. /** @hidden */
  37973. _checkInputs(): void;
  37974. private _checkLimits;
  37975. /**
  37976. * Gets the camera class name.
  37977. * @returns the class name
  37978. */
  37979. getClassName(): string;
  37980. }
  37981. /**
  37982. * Arc Rotate version of the follow camera.
  37983. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37985. */
  37986. export class ArcFollowCamera extends TargetCamera {
  37987. /** The longitudinal angle of the camera */
  37988. alpha: number;
  37989. /** The latitudinal angle of the camera */
  37990. beta: number;
  37991. /** The radius of the camera from its target */
  37992. radius: number;
  37993. /** Define the camera target (the messh it should follow) */
  37994. target: Nullable<AbstractMesh>;
  37995. private _cartesianCoordinates;
  37996. /**
  37997. * Instantiates a new ArcFollowCamera
  37998. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37999. * @param name Define the name of the camera
  38000. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38001. * @param beta Define the rotation angle of the camera around the elevation axis
  38002. * @param radius Define the radius of the camera from its target point
  38003. * @param target Define the target of the camera
  38004. * @param scene Define the scene the camera belongs to
  38005. */
  38006. constructor(name: string,
  38007. /** The longitudinal angle of the camera */
  38008. alpha: number,
  38009. /** The latitudinal angle of the camera */
  38010. beta: number,
  38011. /** The radius of the camera from its target */
  38012. radius: number,
  38013. /** Define the camera target (the messh it should follow) */
  38014. target: Nullable<AbstractMesh>, scene: Scene);
  38015. private _follow;
  38016. /** @hidden */
  38017. _checkInputs(): void;
  38018. /**
  38019. * Returns the class name of the object.
  38020. * It is mostly used internally for serialization purposes.
  38021. */
  38022. getClassName(): string;
  38023. }
  38024. }
  38025. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38027. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38028. import { Nullable } from "babylonjs/types";
  38029. /**
  38030. * Manage the keyboard inputs to control the movement of a follow camera.
  38031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38032. */
  38033. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38034. /**
  38035. * Defines the camera the input is attached to.
  38036. */
  38037. camera: FollowCamera;
  38038. /**
  38039. * Defines the list of key codes associated with the up action (increase heightOffset)
  38040. */
  38041. keysHeightOffsetIncr: number[];
  38042. /**
  38043. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38044. */
  38045. keysHeightOffsetDecr: number[];
  38046. /**
  38047. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38048. */
  38049. keysHeightOffsetModifierAlt: boolean;
  38050. /**
  38051. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38052. */
  38053. keysHeightOffsetModifierCtrl: boolean;
  38054. /**
  38055. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38056. */
  38057. keysHeightOffsetModifierShift: boolean;
  38058. /**
  38059. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38060. */
  38061. keysRotationOffsetIncr: number[];
  38062. /**
  38063. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38064. */
  38065. keysRotationOffsetDecr: number[];
  38066. /**
  38067. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38068. */
  38069. keysRotationOffsetModifierAlt: boolean;
  38070. /**
  38071. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38072. */
  38073. keysRotationOffsetModifierCtrl: boolean;
  38074. /**
  38075. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38076. */
  38077. keysRotationOffsetModifierShift: boolean;
  38078. /**
  38079. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38080. */
  38081. keysRadiusIncr: number[];
  38082. /**
  38083. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38084. */
  38085. keysRadiusDecr: number[];
  38086. /**
  38087. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38088. */
  38089. keysRadiusModifierAlt: boolean;
  38090. /**
  38091. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38092. */
  38093. keysRadiusModifierCtrl: boolean;
  38094. /**
  38095. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38096. */
  38097. keysRadiusModifierShift: boolean;
  38098. /**
  38099. * Defines the rate of change of heightOffset.
  38100. */
  38101. heightSensibility: number;
  38102. /**
  38103. * Defines the rate of change of rotationOffset.
  38104. */
  38105. rotationSensibility: number;
  38106. /**
  38107. * Defines the rate of change of radius.
  38108. */
  38109. radiusSensibility: number;
  38110. private _keys;
  38111. private _ctrlPressed;
  38112. private _altPressed;
  38113. private _shiftPressed;
  38114. private _onCanvasBlurObserver;
  38115. private _onKeyboardObserver;
  38116. private _engine;
  38117. private _scene;
  38118. /**
  38119. * Attach the input controls to a specific dom element to get the input from.
  38120. * @param element Defines the element the controls should be listened from
  38121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38122. */
  38123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38124. /**
  38125. * Detach the current controls from the specified dom element.
  38126. * @param element Defines the element to stop listening the inputs from
  38127. */
  38128. detachControl(element: Nullable<HTMLElement>): void;
  38129. /**
  38130. * Update the current camera state depending on the inputs that have been used this frame.
  38131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38132. */
  38133. checkInputs(): void;
  38134. /**
  38135. * Gets the class name of the current input.
  38136. * @returns the class name
  38137. */
  38138. getClassName(): string;
  38139. /**
  38140. * Get the friendly name associated with the input class.
  38141. * @returns the input friendly name
  38142. */
  38143. getSimpleName(): string;
  38144. /**
  38145. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38146. * allow modification of the heightOffset value.
  38147. */
  38148. private _modifierHeightOffset;
  38149. /**
  38150. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38151. * allow modification of the rotationOffset value.
  38152. */
  38153. private _modifierRotationOffset;
  38154. /**
  38155. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38156. * allow modification of the radius value.
  38157. */
  38158. private _modifierRadius;
  38159. }
  38160. }
  38161. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38162. import { Nullable } from "babylonjs/types";
  38163. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38165. import { Observable } from "babylonjs/Misc/observable";
  38166. module "babylonjs/Cameras/freeCameraInputsManager" {
  38167. interface FreeCameraInputsManager {
  38168. /**
  38169. * @hidden
  38170. */
  38171. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38172. /**
  38173. * Add orientation input support to the input manager.
  38174. * @returns the current input manager
  38175. */
  38176. addDeviceOrientation(): FreeCameraInputsManager;
  38177. }
  38178. }
  38179. /**
  38180. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38181. * Screen rotation is taken into account.
  38182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38183. */
  38184. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38185. private _camera;
  38186. private _screenOrientationAngle;
  38187. private _constantTranform;
  38188. private _screenQuaternion;
  38189. private _alpha;
  38190. private _beta;
  38191. private _gamma;
  38192. /**
  38193. * @hidden
  38194. */
  38195. _onDeviceOrientationChangedObservable: Observable<void>;
  38196. /**
  38197. * Instantiates a new input
  38198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38199. */
  38200. constructor();
  38201. /**
  38202. * Define the camera controlled by the input.
  38203. */
  38204. camera: FreeCamera;
  38205. /**
  38206. * Attach the input controls to a specific dom element to get the input from.
  38207. * @param element Defines the element the controls should be listened from
  38208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38209. */
  38210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38211. private _orientationChanged;
  38212. private _deviceOrientation;
  38213. /**
  38214. * Detach the current controls from the specified dom element.
  38215. * @param element Defines the element to stop listening the inputs from
  38216. */
  38217. detachControl(element: Nullable<HTMLElement>): void;
  38218. /**
  38219. * Update the current camera state depending on the inputs that have been used this frame.
  38220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38221. */
  38222. checkInputs(): void;
  38223. /**
  38224. * Gets the class name of the current intput.
  38225. * @returns the class name
  38226. */
  38227. getClassName(): string;
  38228. /**
  38229. * Get the friendly name associated with the input class.
  38230. * @returns the input friendly name
  38231. */
  38232. getSimpleName(): string;
  38233. }
  38234. }
  38235. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38236. import { Nullable } from "babylonjs/types";
  38237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38239. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38240. /**
  38241. * Manage the gamepad inputs to control a free camera.
  38242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38243. */
  38244. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38245. /**
  38246. * Define the camera the input is attached to.
  38247. */
  38248. camera: FreeCamera;
  38249. /**
  38250. * Define the Gamepad controlling the input
  38251. */
  38252. gamepad: Nullable<Gamepad>;
  38253. /**
  38254. * Defines the gamepad rotation sensiblity.
  38255. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38256. */
  38257. gamepadAngularSensibility: number;
  38258. /**
  38259. * Defines the gamepad move sensiblity.
  38260. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38261. */
  38262. gamepadMoveSensibility: number;
  38263. private _onGamepadConnectedObserver;
  38264. private _onGamepadDisconnectedObserver;
  38265. private _cameraTransform;
  38266. private _deltaTransform;
  38267. private _vector3;
  38268. private _vector2;
  38269. /**
  38270. * Attach the input controls to a specific dom element to get the input from.
  38271. * @param element Defines the element the controls should be listened from
  38272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38273. */
  38274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38275. /**
  38276. * Detach the current controls from the specified dom element.
  38277. * @param element Defines the element to stop listening the inputs from
  38278. */
  38279. detachControl(element: Nullable<HTMLElement>): void;
  38280. /**
  38281. * Update the current camera state depending on the inputs that have been used this frame.
  38282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38283. */
  38284. checkInputs(): void;
  38285. /**
  38286. * Gets the class name of the current intput.
  38287. * @returns the class name
  38288. */
  38289. getClassName(): string;
  38290. /**
  38291. * Get the friendly name associated with the input class.
  38292. * @returns the input friendly name
  38293. */
  38294. getSimpleName(): string;
  38295. }
  38296. }
  38297. declare module "babylonjs/Misc/virtualJoystick" {
  38298. import { Nullable } from "babylonjs/types";
  38299. import { Vector3 } from "babylonjs/Maths/math";
  38300. /**
  38301. * Defines the potential axis of a Joystick
  38302. */
  38303. export enum JoystickAxis {
  38304. /** X axis */
  38305. X = 0,
  38306. /** Y axis */
  38307. Y = 1,
  38308. /** Z axis */
  38309. Z = 2
  38310. }
  38311. /**
  38312. * Class used to define virtual joystick (used in touch mode)
  38313. */
  38314. export class VirtualJoystick {
  38315. /**
  38316. * Gets or sets a boolean indicating that left and right values must be inverted
  38317. */
  38318. reverseLeftRight: boolean;
  38319. /**
  38320. * Gets or sets a boolean indicating that up and down values must be inverted
  38321. */
  38322. reverseUpDown: boolean;
  38323. /**
  38324. * Gets the offset value for the position (ie. the change of the position value)
  38325. */
  38326. deltaPosition: Vector3;
  38327. /**
  38328. * Gets a boolean indicating if the virtual joystick was pressed
  38329. */
  38330. pressed: boolean;
  38331. /**
  38332. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38333. */
  38334. static Canvas: Nullable<HTMLCanvasElement>;
  38335. private static _globalJoystickIndex;
  38336. private static vjCanvasContext;
  38337. private static vjCanvasWidth;
  38338. private static vjCanvasHeight;
  38339. private static halfWidth;
  38340. private _action;
  38341. private _axisTargetedByLeftAndRight;
  38342. private _axisTargetedByUpAndDown;
  38343. private _joystickSensibility;
  38344. private _inversedSensibility;
  38345. private _joystickPointerID;
  38346. private _joystickColor;
  38347. private _joystickPointerPos;
  38348. private _joystickPreviousPointerPos;
  38349. private _joystickPointerStartPos;
  38350. private _deltaJoystickVector;
  38351. private _leftJoystick;
  38352. private _touches;
  38353. private _onPointerDownHandlerRef;
  38354. private _onPointerMoveHandlerRef;
  38355. private _onPointerUpHandlerRef;
  38356. private _onResize;
  38357. /**
  38358. * Creates a new virtual joystick
  38359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38360. */
  38361. constructor(leftJoystick?: boolean);
  38362. /**
  38363. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38364. * @param newJoystickSensibility defines the new sensibility
  38365. */
  38366. setJoystickSensibility(newJoystickSensibility: number): void;
  38367. private _onPointerDown;
  38368. private _onPointerMove;
  38369. private _onPointerUp;
  38370. /**
  38371. * Change the color of the virtual joystick
  38372. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38373. */
  38374. setJoystickColor(newColor: string): void;
  38375. /**
  38376. * Defines a callback to call when the joystick is touched
  38377. * @param action defines the callback
  38378. */
  38379. setActionOnTouch(action: () => any): void;
  38380. /**
  38381. * Defines which axis you'd like to control for left & right
  38382. * @param axis defines the axis to use
  38383. */
  38384. setAxisForLeftRight(axis: JoystickAxis): void;
  38385. /**
  38386. * Defines which axis you'd like to control for up & down
  38387. * @param axis defines the axis to use
  38388. */
  38389. setAxisForUpDown(axis: JoystickAxis): void;
  38390. private _drawVirtualJoystick;
  38391. /**
  38392. * Release internal HTML canvas
  38393. */
  38394. releaseCanvas(): void;
  38395. }
  38396. }
  38397. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38398. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38399. import { Nullable } from "babylonjs/types";
  38400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38402. module "babylonjs/Cameras/freeCameraInputsManager" {
  38403. interface FreeCameraInputsManager {
  38404. /**
  38405. * Add virtual joystick input support to the input manager.
  38406. * @returns the current input manager
  38407. */
  38408. addVirtualJoystick(): FreeCameraInputsManager;
  38409. }
  38410. }
  38411. /**
  38412. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38414. */
  38415. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38416. /**
  38417. * Defines the camera the input is attached to.
  38418. */
  38419. camera: FreeCamera;
  38420. private _leftjoystick;
  38421. private _rightjoystick;
  38422. /**
  38423. * Gets the left stick of the virtual joystick.
  38424. * @returns The virtual Joystick
  38425. */
  38426. getLeftJoystick(): VirtualJoystick;
  38427. /**
  38428. * Gets the right stick of the virtual joystick.
  38429. * @returns The virtual Joystick
  38430. */
  38431. getRightJoystick(): VirtualJoystick;
  38432. /**
  38433. * Update the current camera state depending on the inputs that have been used this frame.
  38434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38435. */
  38436. checkInputs(): void;
  38437. /**
  38438. * Attach the input controls to a specific dom element to get the input from.
  38439. * @param element Defines the element the controls should be listened from
  38440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38441. */
  38442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38443. /**
  38444. * Detach the current controls from the specified dom element.
  38445. * @param element Defines the element to stop listening the inputs from
  38446. */
  38447. detachControl(element: Nullable<HTMLElement>): void;
  38448. /**
  38449. * Gets the class name of the current intput.
  38450. * @returns the class name
  38451. */
  38452. getClassName(): string;
  38453. /**
  38454. * Get the friendly name associated with the input class.
  38455. * @returns the input friendly name
  38456. */
  38457. getSimpleName(): string;
  38458. }
  38459. }
  38460. declare module "babylonjs/Cameras/Inputs/index" {
  38461. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38466. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38467. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38468. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38469. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38470. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38471. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38472. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38473. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38474. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38475. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38476. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38477. }
  38478. declare module "babylonjs/Cameras/touchCamera" {
  38479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38480. import { Scene } from "babylonjs/scene";
  38481. import { Vector3 } from "babylonjs/Maths/math";
  38482. /**
  38483. * This represents a FPS type of camera controlled by touch.
  38484. * This is like a universal camera minus the Gamepad controls.
  38485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38486. */
  38487. export class TouchCamera extends FreeCamera {
  38488. /**
  38489. * Defines the touch sensibility for rotation.
  38490. * The higher the faster.
  38491. */
  38492. touchAngularSensibility: number;
  38493. /**
  38494. * Defines the touch sensibility for move.
  38495. * The higher the faster.
  38496. */
  38497. touchMoveSensibility: number;
  38498. /**
  38499. * Instantiates a new touch camera.
  38500. * This represents a FPS type of camera controlled by touch.
  38501. * This is like a universal camera minus the Gamepad controls.
  38502. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38503. * @param name Define the name of the camera in the scene
  38504. * @param position Define the start position of the camera in the scene
  38505. * @param scene Define the scene the camera belongs to
  38506. */
  38507. constructor(name: string, position: Vector3, scene: Scene);
  38508. /**
  38509. * Gets the current object class name.
  38510. * @return the class name
  38511. */
  38512. getClassName(): string;
  38513. /** @hidden */
  38514. _setupInputs(): void;
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38519. import { Scene } from "babylonjs/scene";
  38520. import { Vector3, Axis } from "babylonjs/Maths/math";
  38521. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38522. /**
  38523. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38524. * being tilted forward or back and left or right.
  38525. */
  38526. export class DeviceOrientationCamera extends FreeCamera {
  38527. private _initialQuaternion;
  38528. private _quaternionCache;
  38529. private _tmpDragQuaternion;
  38530. /**
  38531. * Creates a new device orientation camera
  38532. * @param name The name of the camera
  38533. * @param position The start position camera
  38534. * @param scene The scene the camera belongs to
  38535. */
  38536. constructor(name: string, position: Vector3, scene: Scene);
  38537. /**
  38538. * @hidden
  38539. * Disabled pointer input on first orientation sensor update (Default: true)
  38540. */
  38541. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38542. private _dragFactor;
  38543. /**
  38544. * Enabled turning on the y axis when the orientation sensor is active
  38545. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38546. */
  38547. enableHorizontalDragging(dragFactor?: number): void;
  38548. /**
  38549. * Gets the current instance class name ("DeviceOrientationCamera").
  38550. * This helps avoiding instanceof at run time.
  38551. * @returns the class name
  38552. */
  38553. getClassName(): string;
  38554. /**
  38555. * @hidden
  38556. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38557. */
  38558. _checkInputs(): void;
  38559. /**
  38560. * Reset the camera to its default orientation on the specified axis only.
  38561. * @param axis The axis to reset
  38562. */
  38563. resetToCurrentRotation(axis?: Axis): void;
  38564. }
  38565. }
  38566. declare module "babylonjs/Cameras/universalCamera" {
  38567. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38568. import { Scene } from "babylonjs/scene";
  38569. import { Vector3 } from "babylonjs/Maths/math";
  38570. /**
  38571. * 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,
  38572. * which still works and will still be found in many Playgrounds.
  38573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38574. */
  38575. export class UniversalCamera extends TouchCamera {
  38576. /**
  38577. * Defines the gamepad rotation sensiblity.
  38578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38579. */
  38580. gamepadAngularSensibility: number;
  38581. /**
  38582. * Defines the gamepad move sensiblity.
  38583. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38584. */
  38585. gamepadMoveSensibility: number;
  38586. /**
  38587. * 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,
  38588. * which still works and will still be found in many Playgrounds.
  38589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38590. * @param name Define the name of the camera in the scene
  38591. * @param position Define the start position of the camera in the scene
  38592. * @param scene Define the scene the camera belongs to
  38593. */
  38594. constructor(name: string, position: Vector3, scene: Scene);
  38595. /**
  38596. * Gets the current object class name.
  38597. * @return the class name
  38598. */
  38599. getClassName(): string;
  38600. }
  38601. }
  38602. declare module "babylonjs/Cameras/gamepadCamera" {
  38603. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38604. import { Scene } from "babylonjs/scene";
  38605. import { Vector3 } from "babylonjs/Maths/math";
  38606. /**
  38607. * This represents a FPS type of camera. This is only here for back compat purpose.
  38608. * Please use the UniversalCamera instead as both are identical.
  38609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38610. */
  38611. export class GamepadCamera extends UniversalCamera {
  38612. /**
  38613. * Instantiates a new Gamepad Camera
  38614. * This represents a FPS type of camera. This is only here for back compat purpose.
  38615. * Please use the UniversalCamera instead as both are identical.
  38616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38617. * @param name Define the name of the camera in the scene
  38618. * @param position Define the start position of the camera in the scene
  38619. * @param scene Define the scene the camera belongs to
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene);
  38622. /**
  38623. * Gets the current object class name.
  38624. * @return the class name
  38625. */
  38626. getClassName(): string;
  38627. }
  38628. }
  38629. declare module "babylonjs/Shaders/pass.fragment" {
  38630. /** @hidden */
  38631. export var passPixelShader: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module "babylonjs/Shaders/passCube.fragment" {
  38637. /** @hidden */
  38638. export var passCubePixelShader: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module "babylonjs/PostProcesses/passPostProcess" {
  38644. import { Nullable } from "babylonjs/types";
  38645. import { Camera } from "babylonjs/Cameras/camera";
  38646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38647. import { Engine } from "babylonjs/Engines/engine";
  38648. import "babylonjs/Shaders/pass.fragment";
  38649. import "babylonjs/Shaders/passCube.fragment";
  38650. /**
  38651. * PassPostProcess which produces an output the same as it's input
  38652. */
  38653. export class PassPostProcess extends PostProcess {
  38654. /**
  38655. * Creates the PassPostProcess
  38656. * @param name The name of the effect.
  38657. * @param options The required width/height ratio to downsize to before computing the render pass.
  38658. * @param camera The camera to apply the render pass to.
  38659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38660. * @param engine The engine which the post process will be applied. (default: current engine)
  38661. * @param reusable If the post process can be reused on the same frame. (default: false)
  38662. * @param textureType The type of texture to be used when performing the post processing.
  38663. * @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)
  38664. */
  38665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38666. }
  38667. /**
  38668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38669. */
  38670. export class PassCubePostProcess extends PostProcess {
  38671. private _face;
  38672. /**
  38673. * Gets or sets the cube face to display.
  38674. * * 0 is +X
  38675. * * 1 is -X
  38676. * * 2 is +Y
  38677. * * 3 is -Y
  38678. * * 4 is +Z
  38679. * * 5 is -Z
  38680. */
  38681. face: number;
  38682. /**
  38683. * Creates the PassCubePostProcess
  38684. * @param name The name of the effect.
  38685. * @param options The required width/height ratio to downsize to before computing the render pass.
  38686. * @param camera The camera to apply the render pass to.
  38687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38688. * @param engine The engine which the post process will be applied. (default: current engine)
  38689. * @param reusable If the post process can be reused on the same frame. (default: false)
  38690. * @param textureType The type of texture to be used when performing the post processing.
  38691. * @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)
  38692. */
  38693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38694. }
  38695. }
  38696. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38697. /** @hidden */
  38698. export var anaglyphPixelShader: {
  38699. name: string;
  38700. shader: string;
  38701. };
  38702. }
  38703. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38704. import { Engine } from "babylonjs/Engines/engine";
  38705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38706. import { Camera } from "babylonjs/Cameras/camera";
  38707. import "babylonjs/Shaders/anaglyph.fragment";
  38708. /**
  38709. * Postprocess used to generate anaglyphic rendering
  38710. */
  38711. export class AnaglyphPostProcess extends PostProcess {
  38712. private _passedProcess;
  38713. /**
  38714. * Creates a new AnaglyphPostProcess
  38715. * @param name defines postprocess name
  38716. * @param options defines creation options or target ratio scale
  38717. * @param rigCameras defines cameras using this postprocess
  38718. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38719. * @param engine defines hosting engine
  38720. * @param reusable defines if the postprocess will be reused multiple times per frame
  38721. */
  38722. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38723. }
  38724. }
  38725. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38726. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38728. import { Scene } from "babylonjs/scene";
  38729. import { Vector3 } from "babylonjs/Maths/math";
  38730. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38731. /**
  38732. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38733. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38734. */
  38735. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38736. /**
  38737. * Creates a new AnaglyphArcRotateCamera
  38738. * @param name defines camera name
  38739. * @param alpha defines alpha angle (in radians)
  38740. * @param beta defines beta angle (in radians)
  38741. * @param radius defines radius
  38742. * @param target defines camera target
  38743. * @param interaxialDistance defines distance between each color axis
  38744. * @param scene defines the hosting scene
  38745. */
  38746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38747. /**
  38748. * Gets camera class name
  38749. * @returns AnaglyphArcRotateCamera
  38750. */
  38751. getClassName(): string;
  38752. }
  38753. }
  38754. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38755. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38756. import { Scene } from "babylonjs/scene";
  38757. import { Vector3 } from "babylonjs/Maths/math";
  38758. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38759. /**
  38760. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38762. */
  38763. export class AnaglyphFreeCamera extends FreeCamera {
  38764. /**
  38765. * Creates a new AnaglyphFreeCamera
  38766. * @param name defines camera name
  38767. * @param position defines initial position
  38768. * @param interaxialDistance defines distance between each color axis
  38769. * @param scene defines the hosting scene
  38770. */
  38771. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38772. /**
  38773. * Gets camera class name
  38774. * @returns AnaglyphFreeCamera
  38775. */
  38776. getClassName(): string;
  38777. }
  38778. }
  38779. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38780. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38781. import { Scene } from "babylonjs/scene";
  38782. import { Vector3 } from "babylonjs/Maths/math";
  38783. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38784. /**
  38785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38787. */
  38788. export class AnaglyphGamepadCamera extends GamepadCamera {
  38789. /**
  38790. * Creates a new AnaglyphGamepadCamera
  38791. * @param name defines camera name
  38792. * @param position defines initial position
  38793. * @param interaxialDistance defines distance between each color axis
  38794. * @param scene defines the hosting scene
  38795. */
  38796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38797. /**
  38798. * Gets camera class name
  38799. * @returns AnaglyphGamepadCamera
  38800. */
  38801. getClassName(): string;
  38802. }
  38803. }
  38804. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38805. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38806. import { Scene } from "babylonjs/scene";
  38807. import { Vector3 } from "babylonjs/Maths/math";
  38808. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38809. /**
  38810. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38812. */
  38813. export class AnaglyphUniversalCamera extends UniversalCamera {
  38814. /**
  38815. * Creates a new AnaglyphUniversalCamera
  38816. * @param name defines camera name
  38817. * @param position defines initial position
  38818. * @param interaxialDistance defines distance between each color axis
  38819. * @param scene defines the hosting scene
  38820. */
  38821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38822. /**
  38823. * Gets camera class name
  38824. * @returns AnaglyphUniversalCamera
  38825. */
  38826. getClassName(): string;
  38827. }
  38828. }
  38829. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38830. /** @hidden */
  38831. export var stereoscopicInterlacePixelShader: {
  38832. name: string;
  38833. shader: string;
  38834. };
  38835. }
  38836. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38837. import { Camera } from "babylonjs/Cameras/camera";
  38838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38839. import { Engine } from "babylonjs/Engines/engine";
  38840. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38841. /**
  38842. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38843. */
  38844. export class StereoscopicInterlacePostProcess extends PostProcess {
  38845. private _stepSize;
  38846. private _passedProcess;
  38847. /**
  38848. * Initializes a StereoscopicInterlacePostProcess
  38849. * @param name The name of the effect.
  38850. * @param rigCameras The rig cameras to be appled to the post process
  38851. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38853. * @param engine The engine which the post process will be applied. (default: current engine)
  38854. * @param reusable If the post process can be reused on the same frame. (default: false)
  38855. */
  38856. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38857. }
  38858. }
  38859. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38862. import { Scene } from "babylonjs/scene";
  38863. import { Vector3 } from "babylonjs/Maths/math";
  38864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38865. /**
  38866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38867. * @see http://doc.babylonjs.com/features/cameras
  38868. */
  38869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38870. /**
  38871. * Creates a new StereoscopicArcRotateCamera
  38872. * @param name defines camera name
  38873. * @param alpha defines alpha angle (in radians)
  38874. * @param beta defines beta angle (in radians)
  38875. * @param radius defines radius
  38876. * @param target defines camera target
  38877. * @param interaxialDistance defines distance between each color axis
  38878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38879. * @param scene defines the hosting scene
  38880. */
  38881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38882. /**
  38883. * Gets camera class name
  38884. * @returns StereoscopicArcRotateCamera
  38885. */
  38886. getClassName(): string;
  38887. }
  38888. }
  38889. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38891. import { Scene } from "babylonjs/scene";
  38892. import { Vector3 } from "babylonjs/Maths/math";
  38893. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38894. /**
  38895. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38896. * @see http://doc.babylonjs.com/features/cameras
  38897. */
  38898. export class StereoscopicFreeCamera extends FreeCamera {
  38899. /**
  38900. * Creates a new StereoscopicFreeCamera
  38901. * @param name defines camera name
  38902. * @param position defines initial position
  38903. * @param interaxialDistance defines distance between each color axis
  38904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38905. * @param scene defines the hosting scene
  38906. */
  38907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38908. /**
  38909. * Gets camera class name
  38910. * @returns StereoscopicFreeCamera
  38911. */
  38912. getClassName(): string;
  38913. }
  38914. }
  38915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38916. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38917. import { Scene } from "babylonjs/scene";
  38918. import { Vector3 } from "babylonjs/Maths/math";
  38919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38920. /**
  38921. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38922. * @see http://doc.babylonjs.com/features/cameras
  38923. */
  38924. export class StereoscopicGamepadCamera extends GamepadCamera {
  38925. /**
  38926. * Creates a new StereoscopicGamepadCamera
  38927. * @param name defines camera name
  38928. * @param position defines initial position
  38929. * @param interaxialDistance defines distance between each color axis
  38930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38931. * @param scene defines the hosting scene
  38932. */
  38933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38934. /**
  38935. * Gets camera class name
  38936. * @returns StereoscopicGamepadCamera
  38937. */
  38938. getClassName(): string;
  38939. }
  38940. }
  38941. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38943. import { Scene } from "babylonjs/scene";
  38944. import { Vector3 } from "babylonjs/Maths/math";
  38945. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38946. /**
  38947. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38948. * @see http://doc.babylonjs.com/features/cameras
  38949. */
  38950. export class StereoscopicUniversalCamera extends UniversalCamera {
  38951. /**
  38952. * Creates a new StereoscopicUniversalCamera
  38953. * @param name defines camera name
  38954. * @param position defines initial position
  38955. * @param interaxialDistance defines distance between each color axis
  38956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38957. * @param scene defines the hosting scene
  38958. */
  38959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38960. /**
  38961. * Gets camera class name
  38962. * @returns StereoscopicUniversalCamera
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38971. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38975. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38976. }
  38977. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38979. import { Scene } from "babylonjs/scene";
  38980. import { Vector3 } from "babylonjs/Maths/math";
  38981. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38982. /**
  38983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38984. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38985. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38986. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38987. */
  38988. export class VirtualJoysticksCamera extends FreeCamera {
  38989. /**
  38990. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38993. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38994. * @param name Define the name of the camera in the scene
  38995. * @param position Define the start position of the camera in the scene
  38996. * @param scene Define the scene the camera belongs to
  38997. */
  38998. constructor(name: string, position: Vector3, scene: Scene);
  38999. /**
  39000. * Gets the current object class name.
  39001. * @return the class name
  39002. */
  39003. getClassName(): string;
  39004. }
  39005. }
  39006. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39007. import { Matrix } from "babylonjs/Maths/math";
  39008. /**
  39009. * This represents all the required metrics to create a VR camera.
  39010. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39011. */
  39012. export class VRCameraMetrics {
  39013. /**
  39014. * Define the horizontal resolution off the screen.
  39015. */
  39016. hResolution: number;
  39017. /**
  39018. * Define the vertical resolution off the screen.
  39019. */
  39020. vResolution: number;
  39021. /**
  39022. * Define the horizontal screen size.
  39023. */
  39024. hScreenSize: number;
  39025. /**
  39026. * Define the vertical screen size.
  39027. */
  39028. vScreenSize: number;
  39029. /**
  39030. * Define the vertical screen center position.
  39031. */
  39032. vScreenCenter: number;
  39033. /**
  39034. * Define the distance of the eyes to the screen.
  39035. */
  39036. eyeToScreenDistance: number;
  39037. /**
  39038. * Define the distance between both lenses
  39039. */
  39040. lensSeparationDistance: number;
  39041. /**
  39042. * Define the distance between both viewer's eyes.
  39043. */
  39044. interpupillaryDistance: number;
  39045. /**
  39046. * Define the distortion factor of the VR postprocess.
  39047. * Please, touch with care.
  39048. */
  39049. distortionK: number[];
  39050. /**
  39051. * Define the chromatic aberration correction factors for the VR post process.
  39052. */
  39053. chromaAbCorrection: number[];
  39054. /**
  39055. * Define the scale factor of the post process.
  39056. * The smaller the better but the slower.
  39057. */
  39058. postProcessScaleFactor: number;
  39059. /**
  39060. * Define an offset for the lens center.
  39061. */
  39062. lensCenterOffset: number;
  39063. /**
  39064. * Define if the current vr camera should compensate the distortion of the lense or not.
  39065. */
  39066. compensateDistortion: boolean;
  39067. /**
  39068. * Defines if multiview should be enabled when rendering (Default: false)
  39069. */
  39070. multiviewEnabled: boolean;
  39071. /**
  39072. * Gets the rendering aspect ratio based on the provided resolutions.
  39073. */
  39074. readonly aspectRatio: number;
  39075. /**
  39076. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39077. */
  39078. readonly aspectRatioFov: number;
  39079. /**
  39080. * @hidden
  39081. */
  39082. readonly leftHMatrix: Matrix;
  39083. /**
  39084. * @hidden
  39085. */
  39086. readonly rightHMatrix: Matrix;
  39087. /**
  39088. * @hidden
  39089. */
  39090. readonly leftPreViewMatrix: Matrix;
  39091. /**
  39092. * @hidden
  39093. */
  39094. readonly rightPreViewMatrix: Matrix;
  39095. /**
  39096. * Get the default VRMetrics based on the most generic setup.
  39097. * @returns the default vr metrics
  39098. */
  39099. static GetDefault(): VRCameraMetrics;
  39100. }
  39101. }
  39102. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39103. /** @hidden */
  39104. export var vrDistortionCorrectionPixelShader: {
  39105. name: string;
  39106. shader: string;
  39107. };
  39108. }
  39109. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39110. import { Camera } from "babylonjs/Cameras/camera";
  39111. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39113. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39114. /**
  39115. * VRDistortionCorrectionPostProcess used for mobile VR
  39116. */
  39117. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39118. private _isRightEye;
  39119. private _distortionFactors;
  39120. private _postProcessScaleFactor;
  39121. private _lensCenterOffset;
  39122. private _scaleIn;
  39123. private _scaleFactor;
  39124. private _lensCenter;
  39125. /**
  39126. * Initializes the VRDistortionCorrectionPostProcess
  39127. * @param name The name of the effect.
  39128. * @param camera The camera to apply the render pass to.
  39129. * @param isRightEye If this is for the right eye distortion
  39130. * @param vrMetrics All the required metrics for the VR camera
  39131. */
  39132. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39133. }
  39134. }
  39135. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39136. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39138. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39139. import { Scene } from "babylonjs/scene";
  39140. import { Vector3 } from "babylonjs/Maths/math";
  39141. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39142. import "babylonjs/Cameras/RigModes/vrRigMode";
  39143. /**
  39144. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39146. */
  39147. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39148. /**
  39149. * Creates a new VRDeviceOrientationArcRotateCamera
  39150. * @param name defines camera name
  39151. * @param alpha defines the camera rotation along the logitudinal axis
  39152. * @param beta defines the camera rotation along the latitudinal axis
  39153. * @param radius defines the camera distance from its target
  39154. * @param target defines the camera target
  39155. * @param scene defines the scene the camera belongs to
  39156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39158. */
  39159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39160. /**
  39161. * Gets camera class name
  39162. * @returns VRDeviceOrientationArcRotateCamera
  39163. */
  39164. getClassName(): string;
  39165. }
  39166. }
  39167. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39168. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39169. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39170. import { Scene } from "babylonjs/scene";
  39171. import { Vector3 } from "babylonjs/Maths/math";
  39172. import "babylonjs/Cameras/RigModes/vrRigMode";
  39173. /**
  39174. * Camera used to simulate VR rendering (based on FreeCamera)
  39175. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39176. */
  39177. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39178. /**
  39179. * Creates a new VRDeviceOrientationFreeCamera
  39180. * @param name defines camera name
  39181. * @param position defines the start position of the camera
  39182. * @param scene defines the scene the camera belongs to
  39183. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39184. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39185. */
  39186. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39187. /**
  39188. * Gets camera class name
  39189. * @returns VRDeviceOrientationFreeCamera
  39190. */
  39191. getClassName(): string;
  39192. }
  39193. }
  39194. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39195. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39196. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39197. import { Scene } from "babylonjs/scene";
  39198. import { Vector3 } from "babylonjs/Maths/math";
  39199. /**
  39200. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39201. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39202. */
  39203. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39204. /**
  39205. * Creates a new VRDeviceOrientationGamepadCamera
  39206. * @param name defines camera name
  39207. * @param position defines the start position of the camera
  39208. * @param scene defines the scene the camera belongs to
  39209. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39210. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39211. */
  39212. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39213. /**
  39214. * Gets camera class name
  39215. * @returns VRDeviceOrientationGamepadCamera
  39216. */
  39217. getClassName(): string;
  39218. }
  39219. }
  39220. declare module "babylonjs/Gamepads/xboxGamepad" {
  39221. import { Observable } from "babylonjs/Misc/observable";
  39222. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39223. /**
  39224. * Defines supported buttons for XBox360 compatible gamepads
  39225. */
  39226. export enum Xbox360Button {
  39227. /** A */
  39228. A = 0,
  39229. /** B */
  39230. B = 1,
  39231. /** X */
  39232. X = 2,
  39233. /** Y */
  39234. Y = 3,
  39235. /** Start */
  39236. Start = 4,
  39237. /** Back */
  39238. Back = 5,
  39239. /** Left button */
  39240. LB = 6,
  39241. /** Right button */
  39242. RB = 7,
  39243. /** Left stick */
  39244. LeftStick = 8,
  39245. /** Right stick */
  39246. RightStick = 9
  39247. }
  39248. /** Defines values for XBox360 DPad */
  39249. export enum Xbox360Dpad {
  39250. /** Up */
  39251. Up = 0,
  39252. /** Down */
  39253. Down = 1,
  39254. /** Left */
  39255. Left = 2,
  39256. /** Right */
  39257. Right = 3
  39258. }
  39259. /**
  39260. * Defines a XBox360 gamepad
  39261. */
  39262. export class Xbox360Pad extends Gamepad {
  39263. private _leftTrigger;
  39264. private _rightTrigger;
  39265. private _onlefttriggerchanged;
  39266. private _onrighttriggerchanged;
  39267. private _onbuttondown;
  39268. private _onbuttonup;
  39269. private _ondpaddown;
  39270. private _ondpadup;
  39271. /** Observable raised when a button is pressed */
  39272. onButtonDownObservable: Observable<Xbox360Button>;
  39273. /** Observable raised when a button is released */
  39274. onButtonUpObservable: Observable<Xbox360Button>;
  39275. /** Observable raised when a pad is pressed */
  39276. onPadDownObservable: Observable<Xbox360Dpad>;
  39277. /** Observable raised when a pad is released */
  39278. onPadUpObservable: Observable<Xbox360Dpad>;
  39279. private _buttonA;
  39280. private _buttonB;
  39281. private _buttonX;
  39282. private _buttonY;
  39283. private _buttonBack;
  39284. private _buttonStart;
  39285. private _buttonLB;
  39286. private _buttonRB;
  39287. private _buttonLeftStick;
  39288. private _buttonRightStick;
  39289. private _dPadUp;
  39290. private _dPadDown;
  39291. private _dPadLeft;
  39292. private _dPadRight;
  39293. private _isXboxOnePad;
  39294. /**
  39295. * Creates a new XBox360 gamepad object
  39296. * @param id defines the id of this gamepad
  39297. * @param index defines its index
  39298. * @param gamepad defines the internal HTML gamepad object
  39299. * @param xboxOne defines if it is a XBox One gamepad
  39300. */
  39301. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39302. /**
  39303. * Defines the callback to call when left trigger is pressed
  39304. * @param callback defines the callback to use
  39305. */
  39306. onlefttriggerchanged(callback: (value: number) => void): void;
  39307. /**
  39308. * Defines the callback to call when right trigger is pressed
  39309. * @param callback defines the callback to use
  39310. */
  39311. onrighttriggerchanged(callback: (value: number) => void): void;
  39312. /**
  39313. * Gets the left trigger value
  39314. */
  39315. /**
  39316. * Sets the left trigger value
  39317. */
  39318. leftTrigger: number;
  39319. /**
  39320. * Gets the right trigger value
  39321. */
  39322. /**
  39323. * Sets the right trigger value
  39324. */
  39325. rightTrigger: number;
  39326. /**
  39327. * Defines the callback to call when a button is pressed
  39328. * @param callback defines the callback to use
  39329. */
  39330. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39331. /**
  39332. * Defines the callback to call when a button is released
  39333. * @param callback defines the callback to use
  39334. */
  39335. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39336. /**
  39337. * Defines the callback to call when a pad is pressed
  39338. * @param callback defines the callback to use
  39339. */
  39340. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39341. /**
  39342. * Defines the callback to call when a pad is released
  39343. * @param callback defines the callback to use
  39344. */
  39345. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39346. private _setButtonValue;
  39347. private _setDPadValue;
  39348. /**
  39349. * Gets the value of the `A` button
  39350. */
  39351. /**
  39352. * Sets the value of the `A` button
  39353. */
  39354. buttonA: number;
  39355. /**
  39356. * Gets the value of the `B` button
  39357. */
  39358. /**
  39359. * Sets the value of the `B` button
  39360. */
  39361. buttonB: number;
  39362. /**
  39363. * Gets the value of the `X` button
  39364. */
  39365. /**
  39366. * Sets the value of the `X` button
  39367. */
  39368. buttonX: number;
  39369. /**
  39370. * Gets the value of the `Y` button
  39371. */
  39372. /**
  39373. * Sets the value of the `Y` button
  39374. */
  39375. buttonY: number;
  39376. /**
  39377. * Gets the value of the `Start` button
  39378. */
  39379. /**
  39380. * Sets the value of the `Start` button
  39381. */
  39382. buttonStart: number;
  39383. /**
  39384. * Gets the value of the `Back` button
  39385. */
  39386. /**
  39387. * Sets the value of the `Back` button
  39388. */
  39389. buttonBack: number;
  39390. /**
  39391. * Gets the value of the `Left` button
  39392. */
  39393. /**
  39394. * Sets the value of the `Left` button
  39395. */
  39396. buttonLB: number;
  39397. /**
  39398. * Gets the value of the `Right` button
  39399. */
  39400. /**
  39401. * Sets the value of the `Right` button
  39402. */
  39403. buttonRB: number;
  39404. /**
  39405. * Gets the value of the Left joystick
  39406. */
  39407. /**
  39408. * Sets the value of the Left joystick
  39409. */
  39410. buttonLeftStick: number;
  39411. /**
  39412. * Gets the value of the Right joystick
  39413. */
  39414. /**
  39415. * Sets the value of the Right joystick
  39416. */
  39417. buttonRightStick: number;
  39418. /**
  39419. * Gets the value of D-pad up
  39420. */
  39421. /**
  39422. * Sets the value of D-pad up
  39423. */
  39424. dPadUp: number;
  39425. /**
  39426. * Gets the value of D-pad down
  39427. */
  39428. /**
  39429. * Sets the value of D-pad down
  39430. */
  39431. dPadDown: number;
  39432. /**
  39433. * Gets the value of D-pad left
  39434. */
  39435. /**
  39436. * Sets the value of D-pad left
  39437. */
  39438. dPadLeft: number;
  39439. /**
  39440. * Gets the value of D-pad right
  39441. */
  39442. /**
  39443. * Sets the value of D-pad right
  39444. */
  39445. dPadRight: number;
  39446. /**
  39447. * Force the gamepad to synchronize with device values
  39448. */
  39449. update(): void;
  39450. /**
  39451. * Disposes the gamepad
  39452. */
  39453. dispose(): void;
  39454. }
  39455. }
  39456. declare module "babylonjs/Materials/pushMaterial" {
  39457. import { Nullable } from "babylonjs/types";
  39458. import { Scene } from "babylonjs/scene";
  39459. import { Matrix } from "babylonjs/Maths/math";
  39460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39461. import { Mesh } from "babylonjs/Meshes/mesh";
  39462. import { Material } from "babylonjs/Materials/material";
  39463. import { Effect } from "babylonjs/Materials/effect";
  39464. /**
  39465. * Base class of materials working in push mode in babylon JS
  39466. * @hidden
  39467. */
  39468. export class PushMaterial extends Material {
  39469. protected _activeEffect: Effect;
  39470. protected _normalMatrix: Matrix;
  39471. /**
  39472. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39473. * This means that the material can keep using a previous shader while a new one is being compiled.
  39474. * This is mostly used when shader parallel compilation is supported (true by default)
  39475. */
  39476. allowShaderHotSwapping: boolean;
  39477. constructor(name: string, scene: Scene);
  39478. getEffect(): Effect;
  39479. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39480. /**
  39481. * Binds the given world matrix to the active effect
  39482. *
  39483. * @param world the matrix to bind
  39484. */
  39485. bindOnlyWorldMatrix(world: Matrix): void;
  39486. /**
  39487. * Binds the given normal matrix to the active effect
  39488. *
  39489. * @param normalMatrix the matrix to bind
  39490. */
  39491. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39492. bind(world: Matrix, mesh?: Mesh): void;
  39493. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39494. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39495. }
  39496. }
  39497. declare module "babylonjs/Materials/materialFlags" {
  39498. /**
  39499. * This groups all the flags used to control the materials channel.
  39500. */
  39501. export class MaterialFlags {
  39502. private static _DiffuseTextureEnabled;
  39503. /**
  39504. * Are diffuse textures enabled in the application.
  39505. */
  39506. static DiffuseTextureEnabled: boolean;
  39507. private static _AmbientTextureEnabled;
  39508. /**
  39509. * Are ambient textures enabled in the application.
  39510. */
  39511. static AmbientTextureEnabled: boolean;
  39512. private static _OpacityTextureEnabled;
  39513. /**
  39514. * Are opacity textures enabled in the application.
  39515. */
  39516. static OpacityTextureEnabled: boolean;
  39517. private static _ReflectionTextureEnabled;
  39518. /**
  39519. * Are reflection textures enabled in the application.
  39520. */
  39521. static ReflectionTextureEnabled: boolean;
  39522. private static _EmissiveTextureEnabled;
  39523. /**
  39524. * Are emissive textures enabled in the application.
  39525. */
  39526. static EmissiveTextureEnabled: boolean;
  39527. private static _SpecularTextureEnabled;
  39528. /**
  39529. * Are specular textures enabled in the application.
  39530. */
  39531. static SpecularTextureEnabled: boolean;
  39532. private static _BumpTextureEnabled;
  39533. /**
  39534. * Are bump textures enabled in the application.
  39535. */
  39536. static BumpTextureEnabled: boolean;
  39537. private static _LightmapTextureEnabled;
  39538. /**
  39539. * Are lightmap textures enabled in the application.
  39540. */
  39541. static LightmapTextureEnabled: boolean;
  39542. private static _RefractionTextureEnabled;
  39543. /**
  39544. * Are refraction textures enabled in the application.
  39545. */
  39546. static RefractionTextureEnabled: boolean;
  39547. private static _ColorGradingTextureEnabled;
  39548. /**
  39549. * Are color grading textures enabled in the application.
  39550. */
  39551. static ColorGradingTextureEnabled: boolean;
  39552. private static _FresnelEnabled;
  39553. /**
  39554. * Are fresnels enabled in the application.
  39555. */
  39556. static FresnelEnabled: boolean;
  39557. private static _ClearCoatTextureEnabled;
  39558. /**
  39559. * Are clear coat textures enabled in the application.
  39560. */
  39561. static ClearCoatTextureEnabled: boolean;
  39562. private static _ClearCoatBumpTextureEnabled;
  39563. /**
  39564. * Are clear coat bump textures enabled in the application.
  39565. */
  39566. static ClearCoatBumpTextureEnabled: boolean;
  39567. private static _ClearCoatTintTextureEnabled;
  39568. /**
  39569. * Are clear coat tint textures enabled in the application.
  39570. */
  39571. static ClearCoatTintTextureEnabled: boolean;
  39572. private static _SheenTextureEnabled;
  39573. /**
  39574. * Are sheen textures enabled in the application.
  39575. */
  39576. static SheenTextureEnabled: boolean;
  39577. private static _AnisotropicTextureEnabled;
  39578. /**
  39579. * Are anisotropic textures enabled in the application.
  39580. */
  39581. static AnisotropicTextureEnabled: boolean;
  39582. private static _ThicknessTextureEnabled;
  39583. /**
  39584. * Are thickness textures enabled in the application.
  39585. */
  39586. static ThicknessTextureEnabled: boolean;
  39587. }
  39588. }
  39589. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39590. /** @hidden */
  39591. export var defaultFragmentDeclaration: {
  39592. name: string;
  39593. shader: string;
  39594. };
  39595. }
  39596. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39597. /** @hidden */
  39598. export var defaultUboDeclaration: {
  39599. name: string;
  39600. shader: string;
  39601. };
  39602. }
  39603. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39604. /** @hidden */
  39605. export var lightFragmentDeclaration: {
  39606. name: string;
  39607. shader: string;
  39608. };
  39609. }
  39610. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39611. /** @hidden */
  39612. export var lightUboDeclaration: {
  39613. name: string;
  39614. shader: string;
  39615. };
  39616. }
  39617. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39618. /** @hidden */
  39619. export var lightsFragmentFunctions: {
  39620. name: string;
  39621. shader: string;
  39622. };
  39623. }
  39624. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39625. /** @hidden */
  39626. export var shadowsFragmentFunctions: {
  39627. name: string;
  39628. shader: string;
  39629. };
  39630. }
  39631. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39632. /** @hidden */
  39633. export var fresnelFunction: {
  39634. name: string;
  39635. shader: string;
  39636. };
  39637. }
  39638. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39639. /** @hidden */
  39640. export var reflectionFunction: {
  39641. name: string;
  39642. shader: string;
  39643. };
  39644. }
  39645. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39646. /** @hidden */
  39647. export var bumpFragmentFunctions: {
  39648. name: string;
  39649. shader: string;
  39650. };
  39651. }
  39652. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39653. /** @hidden */
  39654. export var logDepthDeclaration: {
  39655. name: string;
  39656. shader: string;
  39657. };
  39658. }
  39659. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39660. /** @hidden */
  39661. export var bumpFragment: {
  39662. name: string;
  39663. shader: string;
  39664. };
  39665. }
  39666. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39667. /** @hidden */
  39668. export var depthPrePass: {
  39669. name: string;
  39670. shader: string;
  39671. };
  39672. }
  39673. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39674. /** @hidden */
  39675. export var lightFragment: {
  39676. name: string;
  39677. shader: string;
  39678. };
  39679. }
  39680. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39681. /** @hidden */
  39682. export var logDepthFragment: {
  39683. name: string;
  39684. shader: string;
  39685. };
  39686. }
  39687. declare module "babylonjs/Shaders/default.fragment" {
  39688. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39689. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39690. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39691. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39692. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39693. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39694. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39695. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39696. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39697. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39698. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39699. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39700. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39701. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39702. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39704. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39705. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39706. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39707. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39708. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39709. /** @hidden */
  39710. export var defaultPixelShader: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39716. /** @hidden */
  39717. export var defaultVertexDeclaration: {
  39718. name: string;
  39719. shader: string;
  39720. };
  39721. }
  39722. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39723. /** @hidden */
  39724. export var bumpVertexDeclaration: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39730. /** @hidden */
  39731. export var bumpVertex: {
  39732. name: string;
  39733. shader: string;
  39734. };
  39735. }
  39736. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39737. /** @hidden */
  39738. export var fogVertex: {
  39739. name: string;
  39740. shader: string;
  39741. };
  39742. }
  39743. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39744. /** @hidden */
  39745. export var shadowsVertex: {
  39746. name: string;
  39747. shader: string;
  39748. };
  39749. }
  39750. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39751. /** @hidden */
  39752. export var pointCloudVertex: {
  39753. name: string;
  39754. shader: string;
  39755. };
  39756. }
  39757. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39758. /** @hidden */
  39759. export var logDepthVertex: {
  39760. name: string;
  39761. shader: string;
  39762. };
  39763. }
  39764. declare module "babylonjs/Shaders/default.vertex" {
  39765. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39766. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39768. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39769. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39770. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39772. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39773. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39774. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39775. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39777. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39779. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39780. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39781. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39782. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39783. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39784. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39785. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39786. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39787. /** @hidden */
  39788. export var defaultVertexShader: {
  39789. name: string;
  39790. shader: string;
  39791. };
  39792. }
  39793. declare module "babylonjs/Materials/standardMaterial" {
  39794. import { SmartArray } from "babylonjs/Misc/smartArray";
  39795. import { IAnimatable } from "babylonjs/Misc/tools";
  39796. import { Nullable } from "babylonjs/types";
  39797. import { Scene } from "babylonjs/scene";
  39798. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39801. import { Mesh } from "babylonjs/Meshes/mesh";
  39802. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39803. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39804. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39805. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39806. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39809. import "babylonjs/Shaders/default.fragment";
  39810. import "babylonjs/Shaders/default.vertex";
  39811. /** @hidden */
  39812. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39813. MAINUV1: boolean;
  39814. MAINUV2: boolean;
  39815. DIFFUSE: boolean;
  39816. DIFFUSEDIRECTUV: number;
  39817. AMBIENT: boolean;
  39818. AMBIENTDIRECTUV: number;
  39819. OPACITY: boolean;
  39820. OPACITYDIRECTUV: number;
  39821. OPACITYRGB: boolean;
  39822. REFLECTION: boolean;
  39823. EMISSIVE: boolean;
  39824. EMISSIVEDIRECTUV: number;
  39825. SPECULAR: boolean;
  39826. SPECULARDIRECTUV: number;
  39827. BUMP: boolean;
  39828. BUMPDIRECTUV: number;
  39829. PARALLAX: boolean;
  39830. PARALLAXOCCLUSION: boolean;
  39831. SPECULAROVERALPHA: boolean;
  39832. CLIPPLANE: boolean;
  39833. CLIPPLANE2: boolean;
  39834. CLIPPLANE3: boolean;
  39835. CLIPPLANE4: boolean;
  39836. ALPHATEST: boolean;
  39837. DEPTHPREPASS: boolean;
  39838. ALPHAFROMDIFFUSE: boolean;
  39839. POINTSIZE: boolean;
  39840. FOG: boolean;
  39841. SPECULARTERM: boolean;
  39842. DIFFUSEFRESNEL: boolean;
  39843. OPACITYFRESNEL: boolean;
  39844. REFLECTIONFRESNEL: boolean;
  39845. REFRACTIONFRESNEL: boolean;
  39846. EMISSIVEFRESNEL: boolean;
  39847. FRESNEL: boolean;
  39848. NORMAL: boolean;
  39849. UV1: boolean;
  39850. UV2: boolean;
  39851. VERTEXCOLOR: boolean;
  39852. VERTEXALPHA: boolean;
  39853. NUM_BONE_INFLUENCERS: number;
  39854. BonesPerMesh: number;
  39855. BONETEXTURE: boolean;
  39856. INSTANCES: boolean;
  39857. GLOSSINESS: boolean;
  39858. ROUGHNESS: boolean;
  39859. EMISSIVEASILLUMINATION: boolean;
  39860. LINKEMISSIVEWITHDIFFUSE: boolean;
  39861. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39862. LIGHTMAP: boolean;
  39863. LIGHTMAPDIRECTUV: number;
  39864. OBJECTSPACE_NORMALMAP: boolean;
  39865. USELIGHTMAPASSHADOWMAP: boolean;
  39866. REFLECTIONMAP_3D: boolean;
  39867. REFLECTIONMAP_SPHERICAL: boolean;
  39868. REFLECTIONMAP_PLANAR: boolean;
  39869. REFLECTIONMAP_CUBIC: boolean;
  39870. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39871. REFLECTIONMAP_PROJECTION: boolean;
  39872. REFLECTIONMAP_SKYBOX: boolean;
  39873. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39874. REFLECTIONMAP_EXPLICIT: boolean;
  39875. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39876. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39877. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39878. INVERTCUBICMAP: boolean;
  39879. LOGARITHMICDEPTH: boolean;
  39880. REFRACTION: boolean;
  39881. REFRACTIONMAP_3D: boolean;
  39882. REFLECTIONOVERALPHA: boolean;
  39883. TWOSIDEDLIGHTING: boolean;
  39884. SHADOWFLOAT: boolean;
  39885. MORPHTARGETS: boolean;
  39886. MORPHTARGETS_NORMAL: boolean;
  39887. MORPHTARGETS_TANGENT: boolean;
  39888. NUM_MORPH_INFLUENCERS: number;
  39889. NONUNIFORMSCALING: boolean;
  39890. PREMULTIPLYALPHA: boolean;
  39891. IMAGEPROCESSING: boolean;
  39892. VIGNETTE: boolean;
  39893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39894. VIGNETTEBLENDMODEOPAQUE: boolean;
  39895. TONEMAPPING: boolean;
  39896. TONEMAPPING_ACES: boolean;
  39897. CONTRAST: boolean;
  39898. COLORCURVES: boolean;
  39899. COLORGRADING: boolean;
  39900. COLORGRADING3D: boolean;
  39901. SAMPLER3DGREENDEPTH: boolean;
  39902. SAMPLER3DBGRMAP: boolean;
  39903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39904. MULTIVIEW: boolean;
  39905. /**
  39906. * If the reflection texture on this material is in linear color space
  39907. * @hidden
  39908. */
  39909. IS_REFLECTION_LINEAR: boolean;
  39910. /**
  39911. * If the refraction texture on this material is in linear color space
  39912. * @hidden
  39913. */
  39914. IS_REFRACTION_LINEAR: boolean;
  39915. EXPOSURE: boolean;
  39916. constructor();
  39917. setReflectionMode(modeToEnable: string): void;
  39918. }
  39919. /**
  39920. * This is the default material used in Babylon. It is the best trade off between quality
  39921. * and performances.
  39922. * @see http://doc.babylonjs.com/babylon101/materials
  39923. */
  39924. export class StandardMaterial extends PushMaterial {
  39925. private _diffuseTexture;
  39926. /**
  39927. * The basic texture of the material as viewed under a light.
  39928. */
  39929. diffuseTexture: Nullable<BaseTexture>;
  39930. private _ambientTexture;
  39931. /**
  39932. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39933. */
  39934. ambientTexture: Nullable<BaseTexture>;
  39935. private _opacityTexture;
  39936. /**
  39937. * Define the transparency of the material from a texture.
  39938. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39939. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39940. */
  39941. opacityTexture: Nullable<BaseTexture>;
  39942. private _reflectionTexture;
  39943. /**
  39944. * Define the texture used to display the reflection.
  39945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39946. */
  39947. reflectionTexture: Nullable<BaseTexture>;
  39948. private _emissiveTexture;
  39949. /**
  39950. * Define texture of the material as if self lit.
  39951. * This will be mixed in the final result even in the absence of light.
  39952. */
  39953. emissiveTexture: Nullable<BaseTexture>;
  39954. private _specularTexture;
  39955. /**
  39956. * Define how the color and intensity of the highlight given by the light in the material.
  39957. */
  39958. specularTexture: Nullable<BaseTexture>;
  39959. private _bumpTexture;
  39960. /**
  39961. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39962. * 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.
  39963. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39964. */
  39965. bumpTexture: Nullable<BaseTexture>;
  39966. private _lightmapTexture;
  39967. /**
  39968. * Complex lighting can be computationally expensive to compute at runtime.
  39969. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39970. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39971. */
  39972. lightmapTexture: Nullable<BaseTexture>;
  39973. private _refractionTexture;
  39974. /**
  39975. * Define the texture used to display the refraction.
  39976. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39977. */
  39978. refractionTexture: Nullable<BaseTexture>;
  39979. /**
  39980. * The color of the material lit by the environmental background lighting.
  39981. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39982. */
  39983. ambientColor: Color3;
  39984. /**
  39985. * The basic color of the material as viewed under a light.
  39986. */
  39987. diffuseColor: Color3;
  39988. /**
  39989. * Define how the color and intensity of the highlight given by the light in the material.
  39990. */
  39991. specularColor: Color3;
  39992. /**
  39993. * Define the color of the material as if self lit.
  39994. * This will be mixed in the final result even in the absence of light.
  39995. */
  39996. emissiveColor: Color3;
  39997. /**
  39998. * Defines how sharp are the highlights in the material.
  39999. * The bigger the value the sharper giving a more glossy feeling to the result.
  40000. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40001. */
  40002. specularPower: number;
  40003. private _useAlphaFromDiffuseTexture;
  40004. /**
  40005. * Does the transparency come from the diffuse texture alpha channel.
  40006. */
  40007. useAlphaFromDiffuseTexture: boolean;
  40008. private _useEmissiveAsIllumination;
  40009. /**
  40010. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40011. */
  40012. useEmissiveAsIllumination: boolean;
  40013. private _linkEmissiveWithDiffuse;
  40014. /**
  40015. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40016. * the emissive level when the final color is close to one.
  40017. */
  40018. linkEmissiveWithDiffuse: boolean;
  40019. private _useSpecularOverAlpha;
  40020. /**
  40021. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40022. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40023. */
  40024. useSpecularOverAlpha: boolean;
  40025. private _useReflectionOverAlpha;
  40026. /**
  40027. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40028. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40029. */
  40030. useReflectionOverAlpha: boolean;
  40031. private _disableLighting;
  40032. /**
  40033. * Does lights from the scene impacts this material.
  40034. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40035. */
  40036. disableLighting: boolean;
  40037. private _useObjectSpaceNormalMap;
  40038. /**
  40039. * Allows using an object space normal map (instead of tangent space).
  40040. */
  40041. useObjectSpaceNormalMap: boolean;
  40042. private _useParallax;
  40043. /**
  40044. * Is parallax enabled or not.
  40045. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40046. */
  40047. useParallax: boolean;
  40048. private _useParallaxOcclusion;
  40049. /**
  40050. * Is parallax occlusion enabled or not.
  40051. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40052. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40053. */
  40054. useParallaxOcclusion: boolean;
  40055. /**
  40056. * 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.
  40057. */
  40058. parallaxScaleBias: number;
  40059. private _roughness;
  40060. /**
  40061. * Helps to define how blurry the reflections should appears in the material.
  40062. */
  40063. roughness: number;
  40064. /**
  40065. * In case of refraction, define the value of the indice of refraction.
  40066. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40067. */
  40068. indexOfRefraction: number;
  40069. /**
  40070. * Invert the refraction texture alongside the y axis.
  40071. * It can be useful with procedural textures or probe for instance.
  40072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40073. */
  40074. invertRefractionY: boolean;
  40075. /**
  40076. * Defines the alpha limits in alpha test mode.
  40077. */
  40078. alphaCutOff: number;
  40079. private _useLightmapAsShadowmap;
  40080. /**
  40081. * In case of light mapping, define whether the map contains light or shadow informations.
  40082. */
  40083. useLightmapAsShadowmap: boolean;
  40084. private _diffuseFresnelParameters;
  40085. /**
  40086. * Define the diffuse fresnel parameters of the material.
  40087. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40088. */
  40089. diffuseFresnelParameters: FresnelParameters;
  40090. private _opacityFresnelParameters;
  40091. /**
  40092. * Define the opacity fresnel parameters of the material.
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40094. */
  40095. opacityFresnelParameters: FresnelParameters;
  40096. private _reflectionFresnelParameters;
  40097. /**
  40098. * Define the reflection fresnel parameters of the material.
  40099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40100. */
  40101. reflectionFresnelParameters: FresnelParameters;
  40102. private _refractionFresnelParameters;
  40103. /**
  40104. * Define the refraction fresnel parameters of the material.
  40105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40106. */
  40107. refractionFresnelParameters: FresnelParameters;
  40108. private _emissiveFresnelParameters;
  40109. /**
  40110. * Define the emissive fresnel parameters of the material.
  40111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40112. */
  40113. emissiveFresnelParameters: FresnelParameters;
  40114. private _useReflectionFresnelFromSpecular;
  40115. /**
  40116. * If true automatically deducts the fresnels values from the material specularity.
  40117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40118. */
  40119. useReflectionFresnelFromSpecular: boolean;
  40120. private _useGlossinessFromSpecularMapAlpha;
  40121. /**
  40122. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40123. */
  40124. useGlossinessFromSpecularMapAlpha: boolean;
  40125. private _maxSimultaneousLights;
  40126. /**
  40127. * Defines the maximum number of lights that can be used in the material
  40128. */
  40129. maxSimultaneousLights: number;
  40130. private _invertNormalMapX;
  40131. /**
  40132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40133. */
  40134. invertNormalMapX: boolean;
  40135. private _invertNormalMapY;
  40136. /**
  40137. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40138. */
  40139. invertNormalMapY: boolean;
  40140. private _twoSidedLighting;
  40141. /**
  40142. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40143. */
  40144. twoSidedLighting: boolean;
  40145. /**
  40146. * Default configuration related to image processing available in the standard Material.
  40147. */
  40148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40149. /**
  40150. * Gets the image processing configuration used either in this material.
  40151. */
  40152. /**
  40153. * Sets the Default image processing configuration used either in the this material.
  40154. *
  40155. * If sets to null, the scene one is in use.
  40156. */
  40157. imageProcessingConfiguration: ImageProcessingConfiguration;
  40158. /**
  40159. * Keep track of the image processing observer to allow dispose and replace.
  40160. */
  40161. private _imageProcessingObserver;
  40162. /**
  40163. * Attaches a new image processing configuration to the Standard Material.
  40164. * @param configuration
  40165. */
  40166. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40167. /**
  40168. * Gets wether the color curves effect is enabled.
  40169. */
  40170. /**
  40171. * Sets wether the color curves effect is enabled.
  40172. */
  40173. cameraColorCurvesEnabled: boolean;
  40174. /**
  40175. * Gets wether the color grading effect is enabled.
  40176. */
  40177. /**
  40178. * Gets wether the color grading effect is enabled.
  40179. */
  40180. cameraColorGradingEnabled: boolean;
  40181. /**
  40182. * Gets wether tonemapping is enabled or not.
  40183. */
  40184. /**
  40185. * Sets wether tonemapping is enabled or not
  40186. */
  40187. cameraToneMappingEnabled: boolean;
  40188. /**
  40189. * The camera exposure used on this material.
  40190. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40191. * This corresponds to a photographic exposure.
  40192. */
  40193. /**
  40194. * The camera exposure used on this material.
  40195. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40196. * This corresponds to a photographic exposure.
  40197. */
  40198. cameraExposure: number;
  40199. /**
  40200. * Gets The camera contrast used on this material.
  40201. */
  40202. /**
  40203. * Sets The camera contrast used on this material.
  40204. */
  40205. cameraContrast: number;
  40206. /**
  40207. * Gets the Color Grading 2D Lookup Texture.
  40208. */
  40209. /**
  40210. * Sets the Color Grading 2D Lookup Texture.
  40211. */
  40212. cameraColorGradingTexture: Nullable<BaseTexture>;
  40213. /**
  40214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40216. * 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;
  40217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40218. */
  40219. /**
  40220. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40221. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40222. * 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;
  40223. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40224. */
  40225. cameraColorCurves: Nullable<ColorCurves>;
  40226. /**
  40227. * Custom callback helping to override the default shader used in the material.
  40228. */
  40229. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40230. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40231. protected _worldViewProjectionMatrix: Matrix;
  40232. protected _globalAmbientColor: Color3;
  40233. protected _useLogarithmicDepth: boolean;
  40234. /**
  40235. * Instantiates a new standard material.
  40236. * This is the default material used in Babylon. It is the best trade off between quality
  40237. * and performances.
  40238. * @see http://doc.babylonjs.com/babylon101/materials
  40239. * @param name Define the name of the material in the scene
  40240. * @param scene Define the scene the material belong to
  40241. */
  40242. constructor(name: string, scene: Scene);
  40243. /**
  40244. * Gets a boolean indicating that current material needs to register RTT
  40245. */
  40246. readonly hasRenderTargetTextures: boolean;
  40247. /**
  40248. * Gets the current class name of the material e.g. "StandardMaterial"
  40249. * Mainly use in serialization.
  40250. * @returns the class name
  40251. */
  40252. getClassName(): string;
  40253. /**
  40254. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40255. * You can try switching to logarithmic depth.
  40256. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40257. */
  40258. useLogarithmicDepth: boolean;
  40259. /**
  40260. * Specifies if the material will require alpha blending
  40261. * @returns a boolean specifying if alpha blending is needed
  40262. */
  40263. needAlphaBlending(): boolean;
  40264. /**
  40265. * Specifies if this material should be rendered in alpha test mode
  40266. * @returns a boolean specifying if an alpha test is needed.
  40267. */
  40268. needAlphaTesting(): boolean;
  40269. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40270. /**
  40271. * Get the texture used for alpha test purpose.
  40272. * @returns the diffuse texture in case of the standard material.
  40273. */
  40274. getAlphaTestTexture(): Nullable<BaseTexture>;
  40275. /**
  40276. * Get if the submesh is ready to be used and all its information available.
  40277. * Child classes can use it to update shaders
  40278. * @param mesh defines the mesh to check
  40279. * @param subMesh defines which submesh to check
  40280. * @param useInstances specifies that instances should be used
  40281. * @returns a boolean indicating that the submesh is ready or not
  40282. */
  40283. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40284. /**
  40285. * Builds the material UBO layouts.
  40286. * Used internally during the effect preparation.
  40287. */
  40288. buildUniformLayout(): void;
  40289. /**
  40290. * Unbinds the material from the mesh
  40291. */
  40292. unbind(): void;
  40293. /**
  40294. * Binds the submesh to this material by preparing the effect and shader to draw
  40295. * @param world defines the world transformation matrix
  40296. * @param mesh defines the mesh containing the submesh
  40297. * @param subMesh defines the submesh to bind the material to
  40298. */
  40299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40300. /**
  40301. * Get the list of animatables in the material.
  40302. * @returns the list of animatables object used in the material
  40303. */
  40304. getAnimatables(): IAnimatable[];
  40305. /**
  40306. * Gets the active textures from the material
  40307. * @returns an array of textures
  40308. */
  40309. getActiveTextures(): BaseTexture[];
  40310. /**
  40311. * Specifies if the material uses a texture
  40312. * @param texture defines the texture to check against the material
  40313. * @returns a boolean specifying if the material uses the texture
  40314. */
  40315. hasTexture(texture: BaseTexture): boolean;
  40316. /**
  40317. * Disposes the material
  40318. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40319. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40320. */
  40321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40322. /**
  40323. * Makes a duplicate of the material, and gives it a new name
  40324. * @param name defines the new name for the duplicated material
  40325. * @returns the cloned material
  40326. */
  40327. clone(name: string): StandardMaterial;
  40328. /**
  40329. * Serializes this material in a JSON representation
  40330. * @returns the serialized material object
  40331. */
  40332. serialize(): any;
  40333. /**
  40334. * Creates a standard material from parsed material data
  40335. * @param source defines the JSON representation of the material
  40336. * @param scene defines the hosting scene
  40337. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40338. * @returns a new standard material
  40339. */
  40340. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40341. /**
  40342. * Are diffuse textures enabled in the application.
  40343. */
  40344. static DiffuseTextureEnabled: boolean;
  40345. /**
  40346. * Are ambient textures enabled in the application.
  40347. */
  40348. static AmbientTextureEnabled: boolean;
  40349. /**
  40350. * Are opacity textures enabled in the application.
  40351. */
  40352. static OpacityTextureEnabled: boolean;
  40353. /**
  40354. * Are reflection textures enabled in the application.
  40355. */
  40356. static ReflectionTextureEnabled: boolean;
  40357. /**
  40358. * Are emissive textures enabled in the application.
  40359. */
  40360. static EmissiveTextureEnabled: boolean;
  40361. /**
  40362. * Are specular textures enabled in the application.
  40363. */
  40364. static SpecularTextureEnabled: boolean;
  40365. /**
  40366. * Are bump textures enabled in the application.
  40367. */
  40368. static BumpTextureEnabled: boolean;
  40369. /**
  40370. * Are lightmap textures enabled in the application.
  40371. */
  40372. static LightmapTextureEnabled: boolean;
  40373. /**
  40374. * Are refraction textures enabled in the application.
  40375. */
  40376. static RefractionTextureEnabled: boolean;
  40377. /**
  40378. * Are color grading textures enabled in the application.
  40379. */
  40380. static ColorGradingTextureEnabled: boolean;
  40381. /**
  40382. * Are fresnels enabled in the application.
  40383. */
  40384. static FresnelEnabled: boolean;
  40385. }
  40386. }
  40387. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40388. import { Scene } from "babylonjs/scene";
  40389. import { Texture } from "babylonjs/Materials/Textures/texture";
  40390. /**
  40391. * A class extending Texture allowing drawing on a texture
  40392. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40393. */
  40394. export class DynamicTexture extends Texture {
  40395. private _generateMipMaps;
  40396. private _canvas;
  40397. private _context;
  40398. private _engine;
  40399. /**
  40400. * Creates a DynamicTexture
  40401. * @param name defines the name of the texture
  40402. * @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
  40403. * @param scene defines the scene where you want the texture
  40404. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40405. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40406. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40407. */
  40408. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40409. /**
  40410. * Get the current class name of the texture useful for serialization or dynamic coding.
  40411. * @returns "DynamicTexture"
  40412. */
  40413. getClassName(): string;
  40414. /**
  40415. * Gets the current state of canRescale
  40416. */
  40417. readonly canRescale: boolean;
  40418. private _recreate;
  40419. /**
  40420. * Scales the texture
  40421. * @param ratio the scale factor to apply to both width and height
  40422. */
  40423. scale(ratio: number): void;
  40424. /**
  40425. * Resizes the texture
  40426. * @param width the new width
  40427. * @param height the new height
  40428. */
  40429. scaleTo(width: number, height: number): void;
  40430. /**
  40431. * Gets the context of the canvas used by the texture
  40432. * @returns the canvas context of the dynamic texture
  40433. */
  40434. getContext(): CanvasRenderingContext2D;
  40435. /**
  40436. * Clears the texture
  40437. */
  40438. clear(): void;
  40439. /**
  40440. * Updates the texture
  40441. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40442. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40443. */
  40444. update(invertY?: boolean, premulAlpha?: boolean): void;
  40445. /**
  40446. * Draws text onto the texture
  40447. * @param text defines the text to be drawn
  40448. * @param x defines the placement of the text from the left
  40449. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40450. * @param font defines the font to be used with font-style, font-size, font-name
  40451. * @param color defines the color used for the text
  40452. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40453. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40454. * @param update defines whether texture is immediately update (default is true)
  40455. */
  40456. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40457. /**
  40458. * Clones the texture
  40459. * @returns the clone of the texture.
  40460. */
  40461. clone(): DynamicTexture;
  40462. /**
  40463. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40464. * @returns a serialized dynamic texture object
  40465. */
  40466. serialize(): any;
  40467. /** @hidden */
  40468. _rebuild(): void;
  40469. }
  40470. }
  40471. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40474. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40475. /** @hidden */
  40476. export var imageProcessingPixelShader: {
  40477. name: string;
  40478. shader: string;
  40479. };
  40480. }
  40481. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40482. import { Nullable } from "babylonjs/types";
  40483. import { Color4 } from "babylonjs/Maths/math";
  40484. import { Camera } from "babylonjs/Cameras/camera";
  40485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40486. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40487. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40489. import { Engine } from "babylonjs/Engines/engine";
  40490. import "babylonjs/Shaders/imageProcessing.fragment";
  40491. import "babylonjs/Shaders/postprocess.vertex";
  40492. /**
  40493. * ImageProcessingPostProcess
  40494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40495. */
  40496. export class ImageProcessingPostProcess extends PostProcess {
  40497. /**
  40498. * Default configuration related to image processing available in the PBR Material.
  40499. */
  40500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40501. /**
  40502. * Gets the image processing configuration used either in this material.
  40503. */
  40504. /**
  40505. * Sets the Default image processing configuration used either in the this material.
  40506. *
  40507. * If sets to null, the scene one is in use.
  40508. */
  40509. imageProcessingConfiguration: ImageProcessingConfiguration;
  40510. /**
  40511. * Keep track of the image processing observer to allow dispose and replace.
  40512. */
  40513. private _imageProcessingObserver;
  40514. /**
  40515. * Attaches a new image processing configuration to the PBR Material.
  40516. * @param configuration
  40517. */
  40518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40519. /**
  40520. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40521. */
  40522. /**
  40523. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40524. */
  40525. colorCurves: Nullable<ColorCurves>;
  40526. /**
  40527. * Gets wether the color curves effect is enabled.
  40528. */
  40529. /**
  40530. * Sets wether the color curves effect is enabled.
  40531. */
  40532. colorCurvesEnabled: boolean;
  40533. /**
  40534. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40535. */
  40536. /**
  40537. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40538. */
  40539. colorGradingTexture: Nullable<BaseTexture>;
  40540. /**
  40541. * Gets wether the color grading effect is enabled.
  40542. */
  40543. /**
  40544. * Gets wether the color grading effect is enabled.
  40545. */
  40546. colorGradingEnabled: boolean;
  40547. /**
  40548. * Gets exposure used in the effect.
  40549. */
  40550. /**
  40551. * Sets exposure used in the effect.
  40552. */
  40553. exposure: number;
  40554. /**
  40555. * Gets wether tonemapping is enabled or not.
  40556. */
  40557. /**
  40558. * Sets wether tonemapping is enabled or not
  40559. */
  40560. toneMappingEnabled: boolean;
  40561. /**
  40562. * Gets the type of tone mapping effect.
  40563. */
  40564. /**
  40565. * Sets the type of tone mapping effect.
  40566. */
  40567. toneMappingType: number;
  40568. /**
  40569. * Gets contrast used in the effect.
  40570. */
  40571. /**
  40572. * Sets contrast used in the effect.
  40573. */
  40574. contrast: number;
  40575. /**
  40576. * Gets Vignette stretch size.
  40577. */
  40578. /**
  40579. * Sets Vignette stretch size.
  40580. */
  40581. vignetteStretch: number;
  40582. /**
  40583. * Gets Vignette centre X Offset.
  40584. */
  40585. /**
  40586. * Sets Vignette centre X Offset.
  40587. */
  40588. vignetteCentreX: number;
  40589. /**
  40590. * Gets Vignette centre Y Offset.
  40591. */
  40592. /**
  40593. * Sets Vignette centre Y Offset.
  40594. */
  40595. vignetteCentreY: number;
  40596. /**
  40597. * Gets Vignette weight or intensity of the vignette effect.
  40598. */
  40599. /**
  40600. * Sets Vignette weight or intensity of the vignette effect.
  40601. */
  40602. vignetteWeight: number;
  40603. /**
  40604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40605. * if vignetteEnabled is set to true.
  40606. */
  40607. /**
  40608. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40609. * if vignetteEnabled is set to true.
  40610. */
  40611. vignetteColor: Color4;
  40612. /**
  40613. * Gets Camera field of view used by the Vignette effect.
  40614. */
  40615. /**
  40616. * Sets Camera field of view used by the Vignette effect.
  40617. */
  40618. vignetteCameraFov: number;
  40619. /**
  40620. * Gets the vignette blend mode allowing different kind of effect.
  40621. */
  40622. /**
  40623. * Sets the vignette blend mode allowing different kind of effect.
  40624. */
  40625. vignetteBlendMode: number;
  40626. /**
  40627. * Gets wether the vignette effect is enabled.
  40628. */
  40629. /**
  40630. * Sets wether the vignette effect is enabled.
  40631. */
  40632. vignetteEnabled: boolean;
  40633. private _fromLinearSpace;
  40634. /**
  40635. * Gets wether the input of the processing is in Gamma or Linear Space.
  40636. */
  40637. /**
  40638. * Sets wether the input of the processing is in Gamma or Linear Space.
  40639. */
  40640. fromLinearSpace: boolean;
  40641. /**
  40642. * Defines cache preventing GC.
  40643. */
  40644. private _defines;
  40645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40646. /**
  40647. * "ImageProcessingPostProcess"
  40648. * @returns "ImageProcessingPostProcess"
  40649. */
  40650. getClassName(): string;
  40651. protected _updateParameters(): void;
  40652. dispose(camera?: Camera): void;
  40653. }
  40654. }
  40655. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40656. import { Scene } from "babylonjs/scene";
  40657. import { Color3 } from "babylonjs/Maths/math";
  40658. import { Mesh } from "babylonjs/Meshes/mesh";
  40659. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40660. import { Nullable } from "babylonjs/types";
  40661. /**
  40662. * Class containing static functions to help procedurally build meshes
  40663. */
  40664. export class GroundBuilder {
  40665. /**
  40666. * Creates a ground mesh
  40667. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40668. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40670. * @param name defines the name of the mesh
  40671. * @param options defines the options used to create the mesh
  40672. * @param scene defines the hosting scene
  40673. * @returns the ground mesh
  40674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40675. */
  40676. static CreateGround(name: string, options: {
  40677. width?: number;
  40678. height?: number;
  40679. subdivisions?: number;
  40680. subdivisionsX?: number;
  40681. subdivisionsY?: number;
  40682. updatable?: boolean;
  40683. }, scene: any): Mesh;
  40684. /**
  40685. * Creates a tiled ground mesh
  40686. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40687. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40688. * * 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
  40689. * * 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
  40690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40691. * @param name defines the name of the mesh
  40692. * @param options defines the options used to create the mesh
  40693. * @param scene defines the hosting scene
  40694. * @returns the tiled ground mesh
  40695. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40696. */
  40697. static CreateTiledGround(name: string, options: {
  40698. xmin: number;
  40699. zmin: number;
  40700. xmax: number;
  40701. zmax: number;
  40702. subdivisions?: {
  40703. w: number;
  40704. h: number;
  40705. };
  40706. precision?: {
  40707. w: number;
  40708. h: number;
  40709. };
  40710. updatable?: boolean;
  40711. }, scene?: Nullable<Scene>): Mesh;
  40712. /**
  40713. * Creates a ground mesh from a height map
  40714. * * The parameter `url` sets the URL of the height map image resource.
  40715. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40716. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40717. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40718. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40719. * * 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.
  40720. * * 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).
  40721. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40723. * @param name defines the name of the mesh
  40724. * @param url defines the url to the height map
  40725. * @param options defines the options used to create the mesh
  40726. * @param scene defines the hosting scene
  40727. * @returns the ground mesh
  40728. * @see https://doc.babylonjs.com/babylon101/height_map
  40729. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40730. */
  40731. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40732. width?: number;
  40733. height?: number;
  40734. subdivisions?: number;
  40735. minHeight?: number;
  40736. maxHeight?: number;
  40737. colorFilter?: Color3;
  40738. alphaFilter?: number;
  40739. updatable?: boolean;
  40740. onReady?: (mesh: GroundMesh) => void;
  40741. }, scene?: Nullable<Scene>): GroundMesh;
  40742. }
  40743. }
  40744. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40745. import { Vector4 } from "babylonjs/Maths/math";
  40746. import { Mesh } from "babylonjs/Meshes/mesh";
  40747. /**
  40748. * Class containing static functions to help procedurally build meshes
  40749. */
  40750. export class TorusBuilder {
  40751. /**
  40752. * Creates a torus mesh
  40753. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40754. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40755. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40759. * @param name defines the name of the mesh
  40760. * @param options defines the options used to create the mesh
  40761. * @param scene defines the hosting scene
  40762. * @returns the torus mesh
  40763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40764. */
  40765. static CreateTorus(name: string, options: {
  40766. diameter?: number;
  40767. thickness?: number;
  40768. tessellation?: number;
  40769. updatable?: boolean;
  40770. sideOrientation?: number;
  40771. frontUVs?: Vector4;
  40772. backUVs?: Vector4;
  40773. }, scene: any): Mesh;
  40774. }
  40775. }
  40776. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40777. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40778. import { Mesh } from "babylonjs/Meshes/mesh";
  40779. /**
  40780. * Class containing static functions to help procedurally build meshes
  40781. */
  40782. export class CylinderBuilder {
  40783. /**
  40784. * Creates a cylinder or a cone mesh
  40785. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40786. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40787. * * 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.
  40788. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40789. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40790. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40791. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40792. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40793. * * 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).
  40794. * * 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
  40795. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40796. * * 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
  40797. * * 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.
  40798. * * If `enclose` is false, a ring surface is one element.
  40799. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40800. * * 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
  40801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40804. * @param name defines the name of the mesh
  40805. * @param options defines the options used to create the mesh
  40806. * @param scene defines the hosting scene
  40807. * @returns the cylinder mesh
  40808. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40809. */
  40810. static CreateCylinder(name: string, options: {
  40811. height?: number;
  40812. diameterTop?: number;
  40813. diameterBottom?: number;
  40814. diameter?: number;
  40815. tessellation?: number;
  40816. subdivisions?: number;
  40817. arc?: number;
  40818. faceColors?: Color4[];
  40819. faceUV?: Vector4[];
  40820. updatable?: boolean;
  40821. hasRings?: boolean;
  40822. enclose?: boolean;
  40823. sideOrientation?: number;
  40824. frontUVs?: Vector4;
  40825. backUVs?: Vector4;
  40826. }, scene: any): Mesh;
  40827. }
  40828. }
  40829. declare module "babylonjs/Gamepads/gamepadManager" {
  40830. import { Observable } from "babylonjs/Misc/observable";
  40831. import { Nullable } from "babylonjs/types";
  40832. import { Scene } from "babylonjs/scene";
  40833. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40834. /**
  40835. * Manager for handling gamepads
  40836. */
  40837. export class GamepadManager {
  40838. private _scene?;
  40839. private _babylonGamepads;
  40840. private _oneGamepadConnected;
  40841. /** @hidden */
  40842. _isMonitoring: boolean;
  40843. private _gamepadEventSupported;
  40844. private _gamepadSupport;
  40845. /**
  40846. * observable to be triggered when the gamepad controller has been connected
  40847. */
  40848. onGamepadConnectedObservable: Observable<Gamepad>;
  40849. /**
  40850. * observable to be triggered when the gamepad controller has been disconnected
  40851. */
  40852. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40853. private _onGamepadConnectedEvent;
  40854. private _onGamepadDisconnectedEvent;
  40855. /**
  40856. * Initializes the gamepad manager
  40857. * @param _scene BabylonJS scene
  40858. */
  40859. constructor(_scene?: Scene | undefined);
  40860. /**
  40861. * The gamepads in the game pad manager
  40862. */
  40863. readonly gamepads: Gamepad[];
  40864. /**
  40865. * Get the gamepad controllers based on type
  40866. * @param type The type of gamepad controller
  40867. * @returns Nullable gamepad
  40868. */
  40869. getGamepadByType(type?: number): Nullable<Gamepad>;
  40870. /**
  40871. * Disposes the gamepad manager
  40872. */
  40873. dispose(): void;
  40874. private _addNewGamepad;
  40875. private _startMonitoringGamepads;
  40876. private _stopMonitoringGamepads;
  40877. /** @hidden */
  40878. _checkGamepadsStatus(): void;
  40879. private _updateGamepadObjects;
  40880. }
  40881. }
  40882. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40883. import { Nullable } from "babylonjs/types";
  40884. import { Scene } from "babylonjs/scene";
  40885. import { ISceneComponent } from "babylonjs/sceneComponent";
  40886. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40887. module "babylonjs/scene" {
  40888. interface Scene {
  40889. /** @hidden */
  40890. _gamepadManager: Nullable<GamepadManager>;
  40891. /**
  40892. * Gets the gamepad manager associated with the scene
  40893. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40894. */
  40895. gamepadManager: GamepadManager;
  40896. }
  40897. }
  40898. module "babylonjs/Cameras/freeCameraInputsManager" {
  40899. /**
  40900. * Interface representing a free camera inputs manager
  40901. */
  40902. interface FreeCameraInputsManager {
  40903. /**
  40904. * Adds gamepad input support to the FreeCameraInputsManager.
  40905. * @returns the FreeCameraInputsManager
  40906. */
  40907. addGamepad(): FreeCameraInputsManager;
  40908. }
  40909. }
  40910. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40911. /**
  40912. * Interface representing an arc rotate camera inputs manager
  40913. */
  40914. interface ArcRotateCameraInputsManager {
  40915. /**
  40916. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40917. * @returns the camera inputs manager
  40918. */
  40919. addGamepad(): ArcRotateCameraInputsManager;
  40920. }
  40921. }
  40922. /**
  40923. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40924. */
  40925. export class GamepadSystemSceneComponent implements ISceneComponent {
  40926. /**
  40927. * The component name helpfull to identify the component in the list of scene components.
  40928. */
  40929. readonly name: string;
  40930. /**
  40931. * The scene the component belongs to.
  40932. */
  40933. scene: Scene;
  40934. /**
  40935. * Creates a new instance of the component for the given scene
  40936. * @param scene Defines the scene to register the component in
  40937. */
  40938. constructor(scene: Scene);
  40939. /**
  40940. * Registers the component in a given scene
  40941. */
  40942. register(): void;
  40943. /**
  40944. * Rebuilds the elements related to this component in case of
  40945. * context lost for instance.
  40946. */
  40947. rebuild(): void;
  40948. /**
  40949. * Disposes the component and the associated ressources
  40950. */
  40951. dispose(): void;
  40952. private _beforeCameraUpdate;
  40953. }
  40954. }
  40955. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40956. import { Observable } from "babylonjs/Misc/observable";
  40957. import { Nullable } from "babylonjs/types";
  40958. import { Camera } from "babylonjs/Cameras/camera";
  40959. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40960. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40961. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40962. import { Scene } from "babylonjs/scene";
  40963. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40964. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40966. import { Mesh } from "babylonjs/Meshes/mesh";
  40967. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40968. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40969. import "babylonjs/Meshes/Builders/groundBuilder";
  40970. import "babylonjs/Meshes/Builders/torusBuilder";
  40971. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40972. import "babylonjs/Gamepads/gamepadSceneComponent";
  40973. import "babylonjs/Animations/animatable";
  40974. /**
  40975. * Options to modify the vr teleportation behavior.
  40976. */
  40977. export interface VRTeleportationOptions {
  40978. /**
  40979. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40980. */
  40981. floorMeshName?: string;
  40982. /**
  40983. * A list of meshes to be used as the teleportation floor. (default: empty)
  40984. */
  40985. floorMeshes?: Mesh[];
  40986. }
  40987. /**
  40988. * Options to modify the vr experience helper's behavior.
  40989. */
  40990. export interface VRExperienceHelperOptions extends WebVROptions {
  40991. /**
  40992. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40993. */
  40994. createDeviceOrientationCamera?: boolean;
  40995. /**
  40996. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40997. */
  40998. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40999. /**
  41000. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41001. */
  41002. laserToggle?: boolean;
  41003. /**
  41004. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41005. */
  41006. floorMeshes?: Mesh[];
  41007. /**
  41008. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41009. */
  41010. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41011. }
  41012. /**
  41013. * Event containing information after VR has been entered
  41014. */
  41015. export class OnAfterEnteringVRObservableEvent {
  41016. /**
  41017. * If entering vr was successful
  41018. */
  41019. success: boolean;
  41020. }
  41021. /**
  41022. * Helps to quickly add VR support to an existing scene.
  41023. * See http://doc.babylonjs.com/how_to/webvr_helper
  41024. */
  41025. export class VRExperienceHelper {
  41026. /** Options to modify the vr experience helper's behavior. */
  41027. webVROptions: VRExperienceHelperOptions;
  41028. private _scene;
  41029. private _position;
  41030. private _btnVR;
  41031. private _btnVRDisplayed;
  41032. private _webVRsupported;
  41033. private _webVRready;
  41034. private _webVRrequesting;
  41035. private _webVRpresenting;
  41036. private _hasEnteredVR;
  41037. private _fullscreenVRpresenting;
  41038. private _canvas;
  41039. private _webVRCamera;
  41040. private _vrDeviceOrientationCamera;
  41041. private _deviceOrientationCamera;
  41042. private _existingCamera;
  41043. private _onKeyDown;
  41044. private _onVrDisplayPresentChange;
  41045. private _onVRDisplayChanged;
  41046. private _onVRRequestPresentStart;
  41047. private _onVRRequestPresentComplete;
  41048. /**
  41049. * Observable raised right before entering VR.
  41050. */
  41051. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41052. /**
  41053. * Observable raised when entering VR has completed.
  41054. */
  41055. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41056. /**
  41057. * Observable raised when exiting VR.
  41058. */
  41059. onExitingVRObservable: Observable<VRExperienceHelper>;
  41060. /**
  41061. * Observable raised when controller mesh is loaded.
  41062. */
  41063. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41064. /** Return this.onEnteringVRObservable
  41065. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41066. */
  41067. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41068. /** Return this.onExitingVRObservable
  41069. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41070. */
  41071. readonly onExitingVR: Observable<VRExperienceHelper>;
  41072. /** Return this.onControllerMeshLoadedObservable
  41073. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41074. */
  41075. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41076. private _rayLength;
  41077. private _useCustomVRButton;
  41078. private _teleportationRequested;
  41079. private _teleportActive;
  41080. private _floorMeshName;
  41081. private _floorMeshesCollection;
  41082. private _rotationAllowed;
  41083. private _teleportBackwardsVector;
  41084. private _teleportationTarget;
  41085. private _isDefaultTeleportationTarget;
  41086. private _postProcessMove;
  41087. private _teleportationFillColor;
  41088. private _teleportationBorderColor;
  41089. private _rotationAngle;
  41090. private _haloCenter;
  41091. private _cameraGazer;
  41092. private _padSensibilityUp;
  41093. private _padSensibilityDown;
  41094. private _leftController;
  41095. private _rightController;
  41096. /**
  41097. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41098. */
  41099. onNewMeshSelected: Observable<AbstractMesh>;
  41100. /**
  41101. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41102. */
  41103. onNewMeshPicked: Observable<PickingInfo>;
  41104. private _circleEase;
  41105. /**
  41106. * Observable raised before camera teleportation
  41107. */
  41108. onBeforeCameraTeleport: Observable<Vector3>;
  41109. /**
  41110. * Observable raised after camera teleportation
  41111. */
  41112. onAfterCameraTeleport: Observable<Vector3>;
  41113. /**
  41114. * Observable raised when current selected mesh gets unselected
  41115. */
  41116. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41117. private _raySelectionPredicate;
  41118. /**
  41119. * To be optionaly changed by user to define custom ray selection
  41120. */
  41121. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41122. /**
  41123. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41124. */
  41125. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41126. /**
  41127. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41128. */
  41129. teleportationEnabled: boolean;
  41130. private _defaultHeight;
  41131. private _teleportationInitialized;
  41132. private _interactionsEnabled;
  41133. private _interactionsRequested;
  41134. private _displayGaze;
  41135. private _displayLaserPointer;
  41136. /**
  41137. * The mesh used to display where the user is going to teleport.
  41138. */
  41139. /**
  41140. * Sets the mesh to be used to display where the user is going to teleport.
  41141. */
  41142. teleportationTarget: Mesh;
  41143. /**
  41144. * 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
  41145. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41146. * See http://doc.babylonjs.com/resources/baking_transformations
  41147. */
  41148. gazeTrackerMesh: Mesh;
  41149. /**
  41150. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41151. */
  41152. updateGazeTrackerScale: boolean;
  41153. /**
  41154. * If the gaze trackers color should be updated when selecting meshes
  41155. */
  41156. updateGazeTrackerColor: boolean;
  41157. /**
  41158. * The gaze tracking mesh corresponding to the left controller
  41159. */
  41160. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41161. /**
  41162. * The gaze tracking mesh corresponding to the right controller
  41163. */
  41164. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41165. /**
  41166. * If the ray of the gaze should be displayed.
  41167. */
  41168. /**
  41169. * Sets if the ray of the gaze should be displayed.
  41170. */
  41171. displayGaze: boolean;
  41172. /**
  41173. * If the ray of the LaserPointer should be displayed.
  41174. */
  41175. /**
  41176. * Sets if the ray of the LaserPointer should be displayed.
  41177. */
  41178. displayLaserPointer: boolean;
  41179. /**
  41180. * The deviceOrientationCamera used as the camera when not in VR.
  41181. */
  41182. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41183. /**
  41184. * Based on the current WebVR support, returns the current VR camera used.
  41185. */
  41186. readonly currentVRCamera: Nullable<Camera>;
  41187. /**
  41188. * The webVRCamera which is used when in VR.
  41189. */
  41190. readonly webVRCamera: WebVRFreeCamera;
  41191. /**
  41192. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41193. */
  41194. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41195. private readonly _teleportationRequestInitiated;
  41196. /**
  41197. * Defines wether or not Pointer lock should be requested when switching to
  41198. * full screen.
  41199. */
  41200. requestPointerLockOnFullScreen: boolean;
  41201. /**
  41202. * Instantiates a VRExperienceHelper.
  41203. * Helps to quickly add VR support to an existing scene.
  41204. * @param scene The scene the VRExperienceHelper belongs to.
  41205. * @param webVROptions Options to modify the vr experience helper's behavior.
  41206. */
  41207. constructor(scene: Scene,
  41208. /** Options to modify the vr experience helper's behavior. */
  41209. webVROptions?: VRExperienceHelperOptions);
  41210. private _onDefaultMeshLoaded;
  41211. private _onResize;
  41212. private _onFullscreenChange;
  41213. /**
  41214. * Gets a value indicating if we are currently in VR mode.
  41215. */
  41216. readonly isInVRMode: boolean;
  41217. private onVrDisplayPresentChange;
  41218. private onVRDisplayChanged;
  41219. private moveButtonToBottomRight;
  41220. private displayVRButton;
  41221. private updateButtonVisibility;
  41222. private _cachedAngularSensibility;
  41223. /**
  41224. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41225. * Otherwise, will use the fullscreen API.
  41226. */
  41227. enterVR(): void;
  41228. /**
  41229. * Attempt to exit VR, or fullscreen.
  41230. */
  41231. exitVR(): void;
  41232. /**
  41233. * The position of the vr experience helper.
  41234. */
  41235. /**
  41236. * Sets the position of the vr experience helper.
  41237. */
  41238. position: Vector3;
  41239. /**
  41240. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41241. */
  41242. enableInteractions(): void;
  41243. private readonly _noControllerIsActive;
  41244. private beforeRender;
  41245. private _isTeleportationFloor;
  41246. /**
  41247. * Adds a floor mesh to be used for teleportation.
  41248. * @param floorMesh the mesh to be used for teleportation.
  41249. */
  41250. addFloorMesh(floorMesh: Mesh): void;
  41251. /**
  41252. * Removes a floor mesh from being used for teleportation.
  41253. * @param floorMesh the mesh to be removed.
  41254. */
  41255. removeFloorMesh(floorMesh: Mesh): void;
  41256. /**
  41257. * Enables interactions and teleportation using the VR controllers and gaze.
  41258. * @param vrTeleportationOptions options to modify teleportation behavior.
  41259. */
  41260. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41261. private _onNewGamepadConnected;
  41262. private _tryEnableInteractionOnController;
  41263. private _onNewGamepadDisconnected;
  41264. private _enableInteractionOnController;
  41265. private _checkTeleportWithRay;
  41266. private _checkRotate;
  41267. private _checkTeleportBackwards;
  41268. private _enableTeleportationOnController;
  41269. private _createTeleportationCircles;
  41270. private _displayTeleportationTarget;
  41271. private _hideTeleportationTarget;
  41272. private _rotateCamera;
  41273. private _moveTeleportationSelectorTo;
  41274. private _workingVector;
  41275. private _workingQuaternion;
  41276. private _workingMatrix;
  41277. /**
  41278. * Teleports the users feet to the desired location
  41279. * @param location The location where the user's feet should be placed
  41280. */
  41281. teleportCamera(location: Vector3): void;
  41282. private _convertNormalToDirectionOfRay;
  41283. private _castRayAndSelectObject;
  41284. private _notifySelectedMeshUnselected;
  41285. /**
  41286. * Sets the color of the laser ray from the vr controllers.
  41287. * @param color new color for the ray.
  41288. */
  41289. changeLaserColor(color: Color3): void;
  41290. /**
  41291. * Sets the color of the ray from the vr headsets gaze.
  41292. * @param color new color for the ray.
  41293. */
  41294. changeGazeColor(color: Color3): void;
  41295. /**
  41296. * Exits VR and disposes of the vr experience helper
  41297. */
  41298. dispose(): void;
  41299. /**
  41300. * Gets the name of the VRExperienceHelper class
  41301. * @returns "VRExperienceHelper"
  41302. */
  41303. getClassName(): string;
  41304. }
  41305. }
  41306. declare module "babylonjs/Cameras/VR/index" {
  41307. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41308. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41311. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41312. export * from "babylonjs/Cameras/VR/webVRCamera";
  41313. }
  41314. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41315. import { Observable } from "babylonjs/Misc/observable";
  41316. import { Nullable } from "babylonjs/types";
  41317. import { IDisposable, Scene } from "babylonjs/scene";
  41318. import { Vector3 } from "babylonjs/Maths/math";
  41319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41320. import { Ray } from "babylonjs/Culling/ray";
  41321. /**
  41322. * Manages an XRSession
  41323. * @see https://doc.babylonjs.com/how_to/webxr
  41324. */
  41325. export class WebXRSessionManager implements IDisposable {
  41326. private scene;
  41327. /**
  41328. * Fires every time a new xrFrame arrives which can be used to update the camera
  41329. */
  41330. onXRFrameObservable: Observable<any>;
  41331. /**
  41332. * Fires when the xr session is ended either by the device or manually done
  41333. */
  41334. onXRSessionEnded: Observable<any>;
  41335. /** @hidden */
  41336. _xrSession: XRSession;
  41337. /** @hidden */
  41338. _frameOfReference: XRFrameOfReference;
  41339. /** @hidden */
  41340. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41341. /** @hidden */
  41342. _currentXRFrame: Nullable<XRFrame>;
  41343. private _xrNavigator;
  41344. private _xrDevice;
  41345. private _tmpMatrix;
  41346. /**
  41347. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41348. * @param scene The scene which the session should be created for
  41349. */
  41350. constructor(scene: Scene);
  41351. /**
  41352. * Initializes the manager
  41353. * After initialization enterXR can be called to start an XR session
  41354. * @returns Promise which resolves after it is initialized
  41355. */
  41356. initializeAsync(): Promise<void>;
  41357. /**
  41358. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41359. * @param sessionCreationOptions xr options to create the session with
  41360. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41361. * @returns Promise which resolves after it enters XR
  41362. */
  41363. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41364. /**
  41365. * Stops the xrSession and restores the renderloop
  41366. * @returns Promise which resolves after it exits XR
  41367. */
  41368. exitXRAsync(): Promise<void>;
  41369. /**
  41370. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41371. * @param ray ray to cast into the environment
  41372. * @returns Promise which resolves with a collision point in the environment if it exists
  41373. */
  41374. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41375. /**
  41376. * Checks if a session would be supported for the creation options specified
  41377. * @param options creation options to check if they are supported
  41378. * @returns true if supported
  41379. */
  41380. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41381. /**
  41382. * @hidden
  41383. * Converts the render layer of xrSession to a render target
  41384. * @param session session to create render target for
  41385. * @param scene scene the new render target should be created for
  41386. */
  41387. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41388. /**
  41389. * Disposes of the session manager
  41390. */
  41391. dispose(): void;
  41392. }
  41393. }
  41394. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41395. import { Scene } from "babylonjs/scene";
  41396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41397. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41398. /**
  41399. * WebXR Camera which holds the views for the xrSession
  41400. * @see https://doc.babylonjs.com/how_to/webxr
  41401. */
  41402. export class WebXRCamera extends FreeCamera {
  41403. private static _TmpMatrix;
  41404. /**
  41405. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41406. * @param name the name of the camera
  41407. * @param scene the scene to add the camera to
  41408. */
  41409. constructor(name: string, scene: Scene);
  41410. private _updateNumberOfRigCameras;
  41411. /** @hidden */
  41412. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41413. /**
  41414. * Updates the cameras position from the current pose information of the XR session
  41415. * @param xrSessionManager the session containing pose information
  41416. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41417. */
  41418. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41419. }
  41420. }
  41421. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41422. import { Nullable } from "babylonjs/types";
  41423. import { Observable } from "babylonjs/Misc/observable";
  41424. import { IDisposable, Scene } from "babylonjs/scene";
  41425. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41427. import { Ray } from "babylonjs/Culling/ray";
  41428. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41429. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41430. /**
  41431. * States of the webXR experience
  41432. */
  41433. export enum WebXRState {
  41434. /**
  41435. * Transitioning to being in XR mode
  41436. */
  41437. ENTERING_XR = 0,
  41438. /**
  41439. * Transitioning to non XR mode
  41440. */
  41441. EXITING_XR = 1,
  41442. /**
  41443. * In XR mode and presenting
  41444. */
  41445. IN_XR = 2,
  41446. /**
  41447. * Not entered XR mode
  41448. */
  41449. NOT_IN_XR = 3
  41450. }
  41451. /**
  41452. * Helper class used to enable XR
  41453. * @see https://doc.babylonjs.com/how_to/webxr
  41454. */
  41455. export class WebXRExperienceHelper implements IDisposable {
  41456. private scene;
  41457. /**
  41458. * 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
  41459. */
  41460. container: AbstractMesh;
  41461. /**
  41462. * Camera used to render xr content
  41463. */
  41464. camera: WebXRCamera;
  41465. /**
  41466. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41467. */
  41468. state: WebXRState;
  41469. private _setState;
  41470. private static _TmpVector;
  41471. /**
  41472. * Fires when the state of the experience helper has changed
  41473. */
  41474. onStateChangedObservable: Observable<WebXRState>;
  41475. /** @hidden */
  41476. _sessionManager: WebXRSessionManager;
  41477. private _nonVRCamera;
  41478. private _originalSceneAutoClear;
  41479. private _supported;
  41480. /**
  41481. * Creates the experience helper
  41482. * @param scene the scene to attach the experience helper to
  41483. * @returns a promise for the experience helper
  41484. */
  41485. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41486. /**
  41487. * Creates a WebXRExperienceHelper
  41488. * @param scene The scene the helper should be created in
  41489. */
  41490. private constructor();
  41491. /**
  41492. * Exits XR mode and returns the scene to its original state
  41493. * @returns promise that resolves after xr mode has exited
  41494. */
  41495. exitXRAsync(): Promise<void>;
  41496. /**
  41497. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41498. * @param sessionCreationOptions options for the XR session
  41499. * @param frameOfReference frame of reference of the XR session
  41500. * @returns promise that resolves after xr mode has entered
  41501. */
  41502. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41503. /**
  41504. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41505. * @param ray ray to cast into the environment
  41506. * @returns Promise which resolves with a collision point in the environment if it exists
  41507. */
  41508. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41509. /**
  41510. * Updates the global position of the camera by moving the camera's container
  41511. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41512. * @param position The desired global position of the camera
  41513. */
  41514. setPositionOfCameraUsingContainer(position: Vector3): void;
  41515. /**
  41516. * Rotates the xr camera by rotating the camera's container around the camera's position
  41517. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41518. * @param rotation the desired quaternion rotation to apply to the camera
  41519. */
  41520. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41521. /**
  41522. * Checks if the creation options are supported by the xr session
  41523. * @param options creation options
  41524. * @returns true if supported
  41525. */
  41526. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41527. /**
  41528. * Disposes of the experience helper
  41529. */
  41530. dispose(): void;
  41531. }
  41532. }
  41533. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41534. import { Nullable } from "babylonjs/types";
  41535. import { Observable } from "babylonjs/Misc/observable";
  41536. import { IDisposable, Scene } from "babylonjs/scene";
  41537. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41538. /**
  41539. * Button which can be used to enter a different mode of XR
  41540. */
  41541. export class WebXREnterExitUIButton {
  41542. /** button element */
  41543. element: HTMLElement;
  41544. /** XR initialization options for the button */
  41545. initializationOptions: XRSessionCreationOptions;
  41546. /**
  41547. * Creates a WebXREnterExitUIButton
  41548. * @param element button element
  41549. * @param initializationOptions XR initialization options for the button
  41550. */
  41551. constructor(
  41552. /** button element */
  41553. element: HTMLElement,
  41554. /** XR initialization options for the button */
  41555. initializationOptions: XRSessionCreationOptions);
  41556. /**
  41557. * Overwritable function which can be used to update the button's visuals when the state changes
  41558. * @param activeButton the current active button in the UI
  41559. */
  41560. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41561. }
  41562. /**
  41563. * Options to create the webXR UI
  41564. */
  41565. export class WebXREnterExitUIOptions {
  41566. /**
  41567. * Context to enter xr with
  41568. */
  41569. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41570. /**
  41571. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41572. */
  41573. customButtons?: Array<WebXREnterExitUIButton>;
  41574. }
  41575. /**
  41576. * UI to allow the user to enter/exit XR mode
  41577. */
  41578. export class WebXREnterExitUI implements IDisposable {
  41579. private scene;
  41580. private _overlay;
  41581. private _buttons;
  41582. private _activeButton;
  41583. /**
  41584. * Fired every time the active button is changed.
  41585. *
  41586. * When xr is entered via a button that launches xr that button will be the callback parameter
  41587. *
  41588. * When exiting xr the callback parameter will be null)
  41589. */
  41590. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41591. /**
  41592. * Creates UI to allow the user to enter/exit XR mode
  41593. * @param scene the scene to add the ui to
  41594. * @param helper the xr experience helper to enter/exit xr with
  41595. * @param options options to configure the UI
  41596. * @returns the created ui
  41597. */
  41598. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41599. private constructor();
  41600. private _updateButtons;
  41601. /**
  41602. * Disposes of the object
  41603. */
  41604. dispose(): void;
  41605. }
  41606. }
  41607. declare module "babylonjs/Cameras/XR/webXRInput" {
  41608. import { IDisposable, Scene } from "babylonjs/scene";
  41609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41610. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41611. /**
  41612. * Represents an XR input
  41613. */
  41614. export class WebXRController {
  41615. /**
  41616. * 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
  41617. */
  41618. grip?: AbstractMesh;
  41619. /**
  41620. * Pointer which can be used to select objects or attach a visible laser to
  41621. */
  41622. pointer: AbstractMesh;
  41623. /**
  41624. * Creates the controller
  41625. * @see https://doc.babylonjs.com/how_to/webxr
  41626. * @param scene the scene which the controller should be associated to
  41627. */
  41628. constructor(scene: Scene);
  41629. /**
  41630. * Disposes of the object
  41631. */
  41632. dispose(): void;
  41633. }
  41634. /**
  41635. * XR input used to track XR inputs such as controllers/rays
  41636. */
  41637. export class WebXRInput implements IDisposable {
  41638. private helper;
  41639. /**
  41640. * XR controllers being tracked
  41641. */
  41642. controllers: Array<WebXRController>;
  41643. private _tmpMatrix;
  41644. private _frameObserver;
  41645. /**
  41646. * Initializes the WebXRInput
  41647. * @param helper experience helper which the input should be created for
  41648. */
  41649. constructor(helper: WebXRExperienceHelper);
  41650. /**
  41651. * Disposes of the object
  41652. */
  41653. dispose(): void;
  41654. }
  41655. }
  41656. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41657. import { Nullable } from "babylonjs/types";
  41658. import { IDisposable } from "babylonjs/scene";
  41659. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41660. /**
  41661. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41662. */
  41663. export class WebXRManagedOutputCanvas implements IDisposable {
  41664. private _canvas;
  41665. /**
  41666. * xrpresent context of the canvas which can be used to display/mirror xr content
  41667. */
  41668. canvasContext: Nullable<WebGLRenderingContext>;
  41669. /**
  41670. * Initializes the canvas to be added/removed upon entering/exiting xr
  41671. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41672. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41673. */
  41674. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41675. /**
  41676. * Disposes of the object
  41677. */
  41678. dispose(): void;
  41679. private _setManagedOutputCanvas;
  41680. private _addCanvas;
  41681. private _removeCanvas;
  41682. }
  41683. }
  41684. declare module "babylonjs/Cameras/XR/index" {
  41685. export * from "babylonjs/Cameras/XR/webXRCamera";
  41686. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41687. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41688. export * from "babylonjs/Cameras/XR/webXRInput";
  41689. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41690. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41691. }
  41692. declare module "babylonjs/Cameras/RigModes/index" {
  41693. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41694. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41695. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41696. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41697. }
  41698. declare module "babylonjs/Cameras/index" {
  41699. export * from "babylonjs/Cameras/Inputs/index";
  41700. export * from "babylonjs/Cameras/cameraInputsManager";
  41701. export * from "babylonjs/Cameras/camera";
  41702. export * from "babylonjs/Cameras/targetCamera";
  41703. export * from "babylonjs/Cameras/freeCamera";
  41704. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41705. export * from "babylonjs/Cameras/touchCamera";
  41706. export * from "babylonjs/Cameras/arcRotateCamera";
  41707. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41708. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41709. export * from "babylonjs/Cameras/flyCamera";
  41710. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41711. export * from "babylonjs/Cameras/followCamera";
  41712. export * from "babylonjs/Cameras/gamepadCamera";
  41713. export * from "babylonjs/Cameras/Stereoscopic/index";
  41714. export * from "babylonjs/Cameras/universalCamera";
  41715. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41716. export * from "babylonjs/Cameras/VR/index";
  41717. export * from "babylonjs/Cameras/XR/index";
  41718. export * from "babylonjs/Cameras/RigModes/index";
  41719. }
  41720. declare module "babylonjs/Collisions/index" {
  41721. export * from "babylonjs/Collisions/collider";
  41722. export * from "babylonjs/Collisions/collisionCoordinator";
  41723. export * from "babylonjs/Collisions/pickingInfo";
  41724. export * from "babylonjs/Collisions/intersectionInfo";
  41725. export * from "babylonjs/Collisions/meshCollisionData";
  41726. }
  41727. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41728. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41729. import { Vector3, Plane } from "babylonjs/Maths/math";
  41730. import { Ray } from "babylonjs/Culling/ray";
  41731. /**
  41732. * Contains an array of blocks representing the octree
  41733. */
  41734. export interface IOctreeContainer<T> {
  41735. /**
  41736. * Blocks within the octree
  41737. */
  41738. blocks: Array<OctreeBlock<T>>;
  41739. }
  41740. /**
  41741. * Class used to store a cell in an octree
  41742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41743. */
  41744. export class OctreeBlock<T> {
  41745. /**
  41746. * Gets the content of the current block
  41747. */
  41748. entries: T[];
  41749. /**
  41750. * Gets the list of block children
  41751. */
  41752. blocks: Array<OctreeBlock<T>>;
  41753. private _depth;
  41754. private _maxDepth;
  41755. private _capacity;
  41756. private _minPoint;
  41757. private _maxPoint;
  41758. private _boundingVectors;
  41759. private _creationFunc;
  41760. /**
  41761. * Creates a new block
  41762. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41763. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41764. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41765. * @param depth defines the current depth of this block in the octree
  41766. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41767. * @param creationFunc defines a callback to call when an element is added to the block
  41768. */
  41769. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41770. /**
  41771. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41772. */
  41773. readonly capacity: number;
  41774. /**
  41775. * Gets the minimum vector (in world space) of the block's bounding box
  41776. */
  41777. readonly minPoint: Vector3;
  41778. /**
  41779. * Gets the maximum vector (in world space) of the block's bounding box
  41780. */
  41781. readonly maxPoint: Vector3;
  41782. /**
  41783. * Add a new element to this block
  41784. * @param entry defines the element to add
  41785. */
  41786. addEntry(entry: T): void;
  41787. /**
  41788. * Remove an element from this block
  41789. * @param entry defines the element to remove
  41790. */
  41791. removeEntry(entry: T): void;
  41792. /**
  41793. * Add an array of elements to this block
  41794. * @param entries defines the array of elements to add
  41795. */
  41796. addEntries(entries: T[]): void;
  41797. /**
  41798. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41799. * @param frustumPlanes defines the frustum planes to test
  41800. * @param selection defines the array to store current content if selection is positive
  41801. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41802. */
  41803. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41804. /**
  41805. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41806. * @param sphereCenter defines the bounding sphere center
  41807. * @param sphereRadius defines the bounding sphere radius
  41808. * @param selection defines the array to store current content if selection is positive
  41809. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41810. */
  41811. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41812. /**
  41813. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41814. * @param ray defines the ray to test with
  41815. * @param selection defines the array to store current content if selection is positive
  41816. */
  41817. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41818. /**
  41819. * Subdivide the content into child blocks (this block will then be empty)
  41820. */
  41821. createInnerBlocks(): void;
  41822. /**
  41823. * @hidden
  41824. */
  41825. 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;
  41826. }
  41827. }
  41828. declare module "babylonjs/Culling/Octrees/octree" {
  41829. import { SmartArray } from "babylonjs/Misc/smartArray";
  41830. import { Vector3, Plane } from "babylonjs/Maths/math";
  41831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41833. import { Ray } from "babylonjs/Culling/ray";
  41834. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41835. /**
  41836. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41837. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41838. */
  41839. export class Octree<T> {
  41840. /** 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.) */
  41841. maxDepth: number;
  41842. /**
  41843. * Blocks within the octree containing objects
  41844. */
  41845. blocks: Array<OctreeBlock<T>>;
  41846. /**
  41847. * Content stored in the octree
  41848. */
  41849. dynamicContent: T[];
  41850. private _maxBlockCapacity;
  41851. private _selectionContent;
  41852. private _creationFunc;
  41853. /**
  41854. * Creates a octree
  41855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41856. * @param creationFunc function to be used to instatiate the octree
  41857. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41858. * @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.)
  41859. */
  41860. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41861. /** 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. maxDepth?: number);
  41863. /**
  41864. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41865. * @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);
  41866. * @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);
  41867. * @param entries meshes to be added to the octree blocks
  41868. */
  41869. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41870. /**
  41871. * Adds a mesh to the octree
  41872. * @param entry Mesh to add to the octree
  41873. */
  41874. addMesh(entry: T): void;
  41875. /**
  41876. * Remove an element from the octree
  41877. * @param entry defines the element to remove
  41878. */
  41879. removeMesh(entry: T): void;
  41880. /**
  41881. * Selects an array of meshes within the frustum
  41882. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41883. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41884. * @returns array of meshes within the frustum
  41885. */
  41886. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41887. /**
  41888. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41889. * @param sphereCenter defines the bounding sphere center
  41890. * @param sphereRadius defines the bounding sphere radius
  41891. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41892. * @returns an array of objects that intersect the sphere
  41893. */
  41894. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41895. /**
  41896. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41897. * @param ray defines the ray to test with
  41898. * @returns array of intersected objects
  41899. */
  41900. intersectsRay(ray: Ray): SmartArray<T>;
  41901. /**
  41902. * Adds a mesh into the octree block if it intersects the block
  41903. */
  41904. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41905. /**
  41906. * Adds a submesh into the octree block if it intersects the block
  41907. */
  41908. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41909. }
  41910. }
  41911. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41912. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41913. import { Scene } from "babylonjs/scene";
  41914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41916. import { Ray } from "babylonjs/Culling/ray";
  41917. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41918. import { Collider } from "babylonjs/Collisions/collider";
  41919. module "babylonjs/scene" {
  41920. interface Scene {
  41921. /**
  41922. * @hidden
  41923. * Backing Filed
  41924. */
  41925. _selectionOctree: Octree<AbstractMesh>;
  41926. /**
  41927. * Gets the octree used to boost mesh selection (picking)
  41928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41929. */
  41930. selectionOctree: Octree<AbstractMesh>;
  41931. /**
  41932. * Creates or updates the octree used to boost selection (picking)
  41933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41934. * @param maxCapacity defines the maximum capacity per leaf
  41935. * @param maxDepth defines the maximum depth of the octree
  41936. * @returns an octree of AbstractMesh
  41937. */
  41938. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41939. }
  41940. }
  41941. module "babylonjs/Meshes/abstractMesh" {
  41942. interface AbstractMesh {
  41943. /**
  41944. * @hidden
  41945. * Backing Field
  41946. */
  41947. _submeshesOctree: Octree<SubMesh>;
  41948. /**
  41949. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41950. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41951. * @param maxCapacity defines the maximum size of each block (64 by default)
  41952. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41953. * @returns the new octree
  41954. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41956. */
  41957. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41958. }
  41959. }
  41960. /**
  41961. * Defines the octree scene component responsible to manage any octrees
  41962. * in a given scene.
  41963. */
  41964. export class OctreeSceneComponent {
  41965. /**
  41966. * The component name help to identify the component in the list of scene components.
  41967. */
  41968. readonly name: string;
  41969. /**
  41970. * The scene the component belongs to.
  41971. */
  41972. scene: Scene;
  41973. /**
  41974. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41975. */
  41976. readonly checksIsEnabled: boolean;
  41977. /**
  41978. * Creates a new instance of the component for the given scene
  41979. * @param scene Defines the scene to register the component in
  41980. */
  41981. constructor(scene: Scene);
  41982. /**
  41983. * Registers the component in a given scene
  41984. */
  41985. register(): void;
  41986. /**
  41987. * Return the list of active meshes
  41988. * @returns the list of active meshes
  41989. */
  41990. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41991. /**
  41992. * Return the list of active sub meshes
  41993. * @param mesh The mesh to get the candidates sub meshes from
  41994. * @returns the list of active sub meshes
  41995. */
  41996. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41997. private _tempRay;
  41998. /**
  41999. * Return the list of sub meshes intersecting with a given local ray
  42000. * @param mesh defines the mesh to find the submesh for
  42001. * @param localRay defines the ray in local space
  42002. * @returns the list of intersecting sub meshes
  42003. */
  42004. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42005. /**
  42006. * Return the list of sub meshes colliding with a collider
  42007. * @param mesh defines the mesh to find the submesh for
  42008. * @param collider defines the collider to evaluate the collision against
  42009. * @returns the list of colliding sub meshes
  42010. */
  42011. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42012. /**
  42013. * Rebuilds the elements related to this component in case of
  42014. * context lost for instance.
  42015. */
  42016. rebuild(): void;
  42017. /**
  42018. * Disposes the component and the associated ressources.
  42019. */
  42020. dispose(): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Culling/Octrees/index" {
  42024. export * from "babylonjs/Culling/Octrees/octree";
  42025. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42026. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42027. }
  42028. declare module "babylonjs/Culling/index" {
  42029. export * from "babylonjs/Culling/boundingBox";
  42030. export * from "babylonjs/Culling/boundingInfo";
  42031. export * from "babylonjs/Culling/boundingSphere";
  42032. export * from "babylonjs/Culling/Octrees/index";
  42033. export * from "babylonjs/Culling/ray";
  42034. }
  42035. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42036. import { IDisposable, Scene } from "babylonjs/scene";
  42037. import { Nullable } from "babylonjs/types";
  42038. import { Observable } from "babylonjs/Misc/observable";
  42039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42040. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42041. /**
  42042. * Renders a layer on top of an existing scene
  42043. */
  42044. export class UtilityLayerRenderer implements IDisposable {
  42045. /** the original scene that will be rendered on top of */
  42046. originalScene: Scene;
  42047. private _pointerCaptures;
  42048. private _lastPointerEvents;
  42049. private static _DefaultUtilityLayer;
  42050. private static _DefaultKeepDepthUtilityLayer;
  42051. private _sharedGizmoLight;
  42052. /**
  42053. * @hidden
  42054. * Light which used by gizmos to get light shading
  42055. */
  42056. _getSharedGizmoLight(): HemisphericLight;
  42057. /**
  42058. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42059. */
  42060. pickUtilitySceneFirst: boolean;
  42061. /**
  42062. * 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)
  42063. */
  42064. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42065. /**
  42066. * 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)
  42067. */
  42068. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42069. /**
  42070. * The scene that is rendered on top of the original scene
  42071. */
  42072. utilityLayerScene: Scene;
  42073. /**
  42074. * If the utility layer should automatically be rendered on top of existing scene
  42075. */
  42076. shouldRender: boolean;
  42077. /**
  42078. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42079. */
  42080. onlyCheckPointerDownEvents: boolean;
  42081. /**
  42082. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42083. */
  42084. processAllEvents: boolean;
  42085. /**
  42086. * Observable raised when the pointer move from the utility layer scene to the main scene
  42087. */
  42088. onPointerOutObservable: Observable<number>;
  42089. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42090. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42091. private _afterRenderObserver;
  42092. private _sceneDisposeObserver;
  42093. private _originalPointerObserver;
  42094. /**
  42095. * Instantiates a UtilityLayerRenderer
  42096. * @param originalScene the original scene that will be rendered on top of
  42097. * @param handleEvents boolean indicating if the utility layer should handle events
  42098. */
  42099. constructor(
  42100. /** the original scene that will be rendered on top of */
  42101. originalScene: Scene, handleEvents?: boolean);
  42102. private _notifyObservers;
  42103. /**
  42104. * Renders the utility layers scene on top of the original scene
  42105. */
  42106. render(): void;
  42107. /**
  42108. * Disposes of the renderer
  42109. */
  42110. dispose(): void;
  42111. private _updateCamera;
  42112. }
  42113. }
  42114. declare module "babylonjs/Gizmos/gizmo" {
  42115. import { Nullable } from "babylonjs/types";
  42116. import { IDisposable } from "babylonjs/scene";
  42117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42118. import { Mesh } from "babylonjs/Meshes/mesh";
  42119. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42120. /**
  42121. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42122. */
  42123. export class Gizmo implements IDisposable {
  42124. /** The utility layer the gizmo will be added to */
  42125. gizmoLayer: UtilityLayerRenderer;
  42126. /**
  42127. * The root mesh of the gizmo
  42128. */
  42129. _rootMesh: Mesh;
  42130. private _attachedMesh;
  42131. /**
  42132. * Ratio for the scale of the gizmo (Default: 1)
  42133. */
  42134. scaleRatio: number;
  42135. /**
  42136. * If a custom mesh has been set (Default: false)
  42137. */
  42138. protected _customMeshSet: boolean;
  42139. /**
  42140. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42141. * * When set, interactions will be enabled
  42142. */
  42143. attachedMesh: Nullable<AbstractMesh>;
  42144. /**
  42145. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42146. * @param mesh The mesh to replace the default mesh of the gizmo
  42147. */
  42148. setCustomMesh(mesh: Mesh): void;
  42149. /**
  42150. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42151. */
  42152. updateGizmoRotationToMatchAttachedMesh: boolean;
  42153. /**
  42154. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42155. */
  42156. updateGizmoPositionToMatchAttachedMesh: boolean;
  42157. /**
  42158. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42159. */
  42160. protected _updateScale: boolean;
  42161. protected _interactionsEnabled: boolean;
  42162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42163. private _beforeRenderObserver;
  42164. private _tempVector;
  42165. /**
  42166. * Creates a gizmo
  42167. * @param gizmoLayer The utility layer the gizmo will be added to
  42168. */
  42169. constructor(
  42170. /** The utility layer the gizmo will be added to */
  42171. gizmoLayer?: UtilityLayerRenderer);
  42172. /**
  42173. * Updates the gizmo to match the attached mesh's position/rotation
  42174. */
  42175. protected _update(): void;
  42176. /**
  42177. * Disposes of the gizmo
  42178. */
  42179. dispose(): void;
  42180. }
  42181. }
  42182. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42183. import { Observable } from "babylonjs/Misc/observable";
  42184. import { Nullable } from "babylonjs/types";
  42185. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42186. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42188. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42189. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42191. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42192. import { Scene } from "babylonjs/scene";
  42193. /**
  42194. * Single axis drag gizmo
  42195. */
  42196. export class AxisDragGizmo extends Gizmo {
  42197. /**
  42198. * Drag behavior responsible for the gizmos dragging interactions
  42199. */
  42200. dragBehavior: PointerDragBehavior;
  42201. private _pointerObserver;
  42202. /**
  42203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42204. */
  42205. snapDistance: number;
  42206. /**
  42207. * Event that fires each time the gizmo snaps to a new location.
  42208. * * snapDistance is the the change in distance
  42209. */
  42210. onSnapObservable: Observable<{
  42211. snapDistance: number;
  42212. }>;
  42213. /** @hidden */
  42214. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42215. /** @hidden */
  42216. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42217. /**
  42218. * Creates an AxisDragGizmo
  42219. * @param gizmoLayer The utility layer the gizmo will be added to
  42220. * @param dragAxis The axis which the gizmo will be able to drag on
  42221. * @param color The color of the gizmo
  42222. */
  42223. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42224. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42225. /**
  42226. * Disposes of the gizmo
  42227. */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Debug/axesViewer" {
  42232. import { Vector3 } from "babylonjs/Maths/math";
  42233. import { Nullable } from "babylonjs/types";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42236. /**
  42237. * The Axes viewer will show 3 axes in a specific point in space
  42238. */
  42239. export class AxesViewer {
  42240. private _xAxis;
  42241. private _yAxis;
  42242. private _zAxis;
  42243. private _scaleLinesFactor;
  42244. private _instanced;
  42245. /**
  42246. * Gets the hosting scene
  42247. */
  42248. scene: Scene;
  42249. /**
  42250. * Gets or sets a number used to scale line length
  42251. */
  42252. scaleLines: number;
  42253. /** Gets the node hierarchy used to render x-axis */
  42254. readonly xAxis: TransformNode;
  42255. /** Gets the node hierarchy used to render y-axis */
  42256. readonly yAxis: TransformNode;
  42257. /** Gets the node hierarchy used to render z-axis */
  42258. readonly zAxis: TransformNode;
  42259. /**
  42260. * Creates a new AxesViewer
  42261. * @param scene defines the hosting scene
  42262. * @param scaleLines defines a number used to scale line length (1 by default)
  42263. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42264. * @param xAxis defines the node hierarchy used to render the x-axis
  42265. * @param yAxis defines the node hierarchy used to render the y-axis
  42266. * @param zAxis defines the node hierarchy used to render the z-axis
  42267. */
  42268. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42269. /**
  42270. * Force the viewer to update
  42271. * @param position defines the position of the viewer
  42272. * @param xaxis defines the x axis of the viewer
  42273. * @param yaxis defines the y axis of the viewer
  42274. * @param zaxis defines the z axis of the viewer
  42275. */
  42276. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42277. /**
  42278. * Creates an instance of this axes viewer.
  42279. * @returns a new axes viewer with instanced meshes
  42280. */
  42281. createInstance(): AxesViewer;
  42282. /** Releases resources */
  42283. dispose(): void;
  42284. private static _SetRenderingGroupId;
  42285. }
  42286. }
  42287. declare module "babylonjs/Debug/boneAxesViewer" {
  42288. import { Nullable } from "babylonjs/types";
  42289. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42290. import { Vector3 } from "babylonjs/Maths/math";
  42291. import { Mesh } from "babylonjs/Meshes/mesh";
  42292. import { Bone } from "babylonjs/Bones/bone";
  42293. import { Scene } from "babylonjs/scene";
  42294. /**
  42295. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42296. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42297. */
  42298. export class BoneAxesViewer extends AxesViewer {
  42299. /**
  42300. * Gets or sets the target mesh where to display the axes viewer
  42301. */
  42302. mesh: Nullable<Mesh>;
  42303. /**
  42304. * Gets or sets the target bone where to display the axes viewer
  42305. */
  42306. bone: Nullable<Bone>;
  42307. /** Gets current position */
  42308. pos: Vector3;
  42309. /** Gets direction of X axis */
  42310. xaxis: Vector3;
  42311. /** Gets direction of Y axis */
  42312. yaxis: Vector3;
  42313. /** Gets direction of Z axis */
  42314. zaxis: Vector3;
  42315. /**
  42316. * Creates a new BoneAxesViewer
  42317. * @param scene defines the hosting scene
  42318. * @param bone defines the target bone
  42319. * @param mesh defines the target mesh
  42320. * @param scaleLines defines a scaling factor for line length (1 by default)
  42321. */
  42322. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42323. /**
  42324. * Force the viewer to update
  42325. */
  42326. update(): void;
  42327. /** Releases resources */
  42328. dispose(): void;
  42329. }
  42330. }
  42331. declare module "babylonjs/Debug/debugLayer" {
  42332. import { Observable } from "babylonjs/Misc/observable";
  42333. import { Scene } from "babylonjs/scene";
  42334. /**
  42335. * Interface used to define scene explorer extensibility option
  42336. */
  42337. export interface IExplorerExtensibilityOption {
  42338. /**
  42339. * Define the option label
  42340. */
  42341. label: string;
  42342. /**
  42343. * Defines the action to execute on click
  42344. */
  42345. action: (entity: any) => void;
  42346. }
  42347. /**
  42348. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42349. */
  42350. export interface IExplorerExtensibilityGroup {
  42351. /**
  42352. * Defines a predicate to test if a given type mut be extended
  42353. */
  42354. predicate: (entity: any) => boolean;
  42355. /**
  42356. * Gets the list of options added to a type
  42357. */
  42358. entries: IExplorerExtensibilityOption[];
  42359. }
  42360. /**
  42361. * Interface used to define the options to use to create the Inspector
  42362. */
  42363. export interface IInspectorOptions {
  42364. /**
  42365. * Display in overlay mode (default: false)
  42366. */
  42367. overlay?: boolean;
  42368. /**
  42369. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42370. */
  42371. globalRoot?: HTMLElement;
  42372. /**
  42373. * Display the Scene explorer
  42374. */
  42375. showExplorer?: boolean;
  42376. /**
  42377. * Display the property inspector
  42378. */
  42379. showInspector?: boolean;
  42380. /**
  42381. * Display in embed mode (both panes on the right)
  42382. */
  42383. embedMode?: boolean;
  42384. /**
  42385. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42386. */
  42387. handleResize?: boolean;
  42388. /**
  42389. * Allow the panes to popup (default: true)
  42390. */
  42391. enablePopup?: boolean;
  42392. /**
  42393. * Allow the panes to be closed by users (default: true)
  42394. */
  42395. enableClose?: boolean;
  42396. /**
  42397. * Optional list of extensibility entries
  42398. */
  42399. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42400. /**
  42401. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42402. */
  42403. inspectorURL?: string;
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _debugLayer: DebugLayer;
  42412. /**
  42413. * Gets the debug layer (aka Inspector) associated with the scene
  42414. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42415. */
  42416. debugLayer: DebugLayer;
  42417. }
  42418. }
  42419. /**
  42420. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42421. * what is happening in your scene
  42422. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42423. */
  42424. export class DebugLayer {
  42425. /**
  42426. * Define the url to get the inspector script from.
  42427. * By default it uses the babylonjs CDN.
  42428. * @ignoreNaming
  42429. */
  42430. static InspectorURL: string;
  42431. private _scene;
  42432. private BJSINSPECTOR;
  42433. /**
  42434. * Observable triggered when a property is changed through the inspector.
  42435. */
  42436. onPropertyChangedObservable: Observable<{
  42437. object: any;
  42438. property: string;
  42439. value: any;
  42440. initialValue: any;
  42441. }>;
  42442. /**
  42443. * Instantiates a new debug layer.
  42444. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42445. * what is happening in your scene
  42446. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42447. * @param scene Defines the scene to inspect
  42448. */
  42449. constructor(scene: Scene);
  42450. /** Creates the inspector window. */
  42451. private _createInspector;
  42452. /**
  42453. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42454. * @param entity defines the entity to select
  42455. * @param lineContainerTitle defines the specific block to highlight
  42456. */
  42457. select(entity: any, lineContainerTitle?: string): void;
  42458. /** Get the inspector from bundle or global */
  42459. private _getGlobalInspector;
  42460. /**
  42461. * Get if the inspector is visible or not.
  42462. * @returns true if visible otherwise, false
  42463. */
  42464. isVisible(): boolean;
  42465. /**
  42466. * Hide the inspector and close its window.
  42467. */
  42468. hide(): void;
  42469. /**
  42470. * Launch the debugLayer.
  42471. * @param config Define the configuration of the inspector
  42472. * @return a promise fulfilled when the debug layer is visible
  42473. */
  42474. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42475. }
  42476. }
  42477. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42478. import { Nullable } from "babylonjs/types";
  42479. import { Scene } from "babylonjs/scene";
  42480. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42481. import { Mesh } from "babylonjs/Meshes/mesh";
  42482. /**
  42483. * Class containing static functions to help procedurally build meshes
  42484. */
  42485. export class BoxBuilder {
  42486. /**
  42487. * Creates a box mesh
  42488. * * The parameter `size` sets the size (float) of each box side (default 1)
  42489. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42490. * * 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)
  42491. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42496. * @param name defines the name of the mesh
  42497. * @param options defines the options used to create the mesh
  42498. * @param scene defines the hosting scene
  42499. * @returns the box mesh
  42500. */
  42501. static CreateBox(name: string, options: {
  42502. size?: number;
  42503. width?: number;
  42504. height?: number;
  42505. depth?: number;
  42506. faceUV?: Vector4[];
  42507. faceColors?: Color4[];
  42508. sideOrientation?: number;
  42509. frontUVs?: Vector4;
  42510. backUVs?: Vector4;
  42511. wrap?: boolean;
  42512. topBaseAt?: number;
  42513. bottomBaseAt?: number;
  42514. updatable?: boolean;
  42515. }, scene?: Nullable<Scene>): Mesh;
  42516. }
  42517. }
  42518. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42519. import { Vector4 } from "babylonjs/Maths/math";
  42520. import { Mesh } from "babylonjs/Meshes/mesh";
  42521. /**
  42522. * Class containing static functions to help procedurally build meshes
  42523. */
  42524. export class SphereBuilder {
  42525. /**
  42526. * Creates a sphere mesh
  42527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42528. * * 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`)
  42529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42530. * * 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
  42531. * * 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)
  42532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42535. * @param name defines the name of the mesh
  42536. * @param options defines the options used to create the mesh
  42537. * @param scene defines the hosting scene
  42538. * @returns the sphere mesh
  42539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42540. */
  42541. static CreateSphere(name: string, options: {
  42542. segments?: number;
  42543. diameter?: number;
  42544. diameterX?: number;
  42545. diameterY?: number;
  42546. diameterZ?: number;
  42547. arc?: number;
  42548. slice?: number;
  42549. sideOrientation?: number;
  42550. frontUVs?: Vector4;
  42551. backUVs?: Vector4;
  42552. updatable?: boolean;
  42553. }, scene: any): Mesh;
  42554. }
  42555. }
  42556. declare module "babylonjs/Debug/physicsViewer" {
  42557. import { Nullable } from "babylonjs/types";
  42558. import { Scene } from "babylonjs/scene";
  42559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42560. import { Mesh } from "babylonjs/Meshes/mesh";
  42561. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42562. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42563. /**
  42564. * Used to show the physics impostor around the specific mesh
  42565. */
  42566. export class PhysicsViewer {
  42567. /** @hidden */
  42568. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42569. /** @hidden */
  42570. protected _meshes: Array<Nullable<AbstractMesh>>;
  42571. /** @hidden */
  42572. protected _scene: Nullable<Scene>;
  42573. /** @hidden */
  42574. protected _numMeshes: number;
  42575. /** @hidden */
  42576. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42577. private _renderFunction;
  42578. private _utilityLayer;
  42579. private _debugBoxMesh;
  42580. private _debugSphereMesh;
  42581. private _debugCylinderMesh;
  42582. private _debugMaterial;
  42583. private _debugMeshMeshes;
  42584. /**
  42585. * Creates a new PhysicsViewer
  42586. * @param scene defines the hosting scene
  42587. */
  42588. constructor(scene: Scene);
  42589. /** @hidden */
  42590. protected _updateDebugMeshes(): void;
  42591. /**
  42592. * Renders a specified physic impostor
  42593. * @param impostor defines the impostor to render
  42594. * @param targetMesh defines the mesh represented by the impostor
  42595. * @returns the new debug mesh used to render the impostor
  42596. */
  42597. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42598. /**
  42599. * Hides a specified physic impostor
  42600. * @param impostor defines the impostor to hide
  42601. */
  42602. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42603. private _getDebugMaterial;
  42604. private _getDebugBoxMesh;
  42605. private _getDebugSphereMesh;
  42606. private _getDebugCylinderMesh;
  42607. private _getDebugMeshMesh;
  42608. private _getDebugMesh;
  42609. /** Releases all resources */
  42610. dispose(): void;
  42611. }
  42612. }
  42613. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42614. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42615. import { Nullable } from "babylonjs/types";
  42616. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42617. import { Scene } from "babylonjs/scene";
  42618. /**
  42619. * Class containing static functions to help procedurally build meshes
  42620. */
  42621. export class LinesBuilder {
  42622. /**
  42623. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42624. * * 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
  42625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42626. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42627. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42628. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42629. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42630. * * 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
  42631. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42634. * @param name defines the name of the new line system
  42635. * @param options defines the options used to create the line system
  42636. * @param scene defines the hosting scene
  42637. * @returns a new line system mesh
  42638. */
  42639. static CreateLineSystem(name: string, options: {
  42640. lines: Vector3[][];
  42641. updatable?: boolean;
  42642. instance?: Nullable<LinesMesh>;
  42643. colors?: Nullable<Color4[][]>;
  42644. useVertexAlpha?: boolean;
  42645. }, scene: Nullable<Scene>): LinesMesh;
  42646. /**
  42647. * Creates a line mesh
  42648. * 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
  42649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42650. * * The parameter `points` is an array successive Vector3
  42651. * * 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
  42652. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42654. * * When updating an instance, remember that only point positions can change, not the number of points
  42655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42657. * @param name defines the name of the new line system
  42658. * @param options defines the options used to create the line system
  42659. * @param scene defines the hosting scene
  42660. * @returns a new line mesh
  42661. */
  42662. static CreateLines(name: string, options: {
  42663. points: Vector3[];
  42664. updatable?: boolean;
  42665. instance?: Nullable<LinesMesh>;
  42666. colors?: Color4[];
  42667. useVertexAlpha?: boolean;
  42668. }, scene?: Nullable<Scene>): LinesMesh;
  42669. /**
  42670. * Creates a dashed line mesh
  42671. * * 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
  42672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42673. * * The parameter `points` is an array successive Vector3
  42674. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42675. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42676. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42677. * * 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
  42678. * * When updating an instance, remember that only point positions can change, not the number of points
  42679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42680. * @param name defines the name of the mesh
  42681. * @param options defines the options used to create the mesh
  42682. * @param scene defines the hosting scene
  42683. * @returns the dashed line mesh
  42684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42685. */
  42686. static CreateDashedLines(name: string, options: {
  42687. points: Vector3[];
  42688. dashSize?: number;
  42689. gapSize?: number;
  42690. dashNb?: number;
  42691. updatable?: boolean;
  42692. instance?: LinesMesh;
  42693. }, scene?: Nullable<Scene>): LinesMesh;
  42694. }
  42695. }
  42696. declare module "babylonjs/Debug/rayHelper" {
  42697. import { Nullable } from "babylonjs/types";
  42698. import { Ray } from "babylonjs/Culling/ray";
  42699. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42702. import "babylonjs/Meshes/Builders/linesBuilder";
  42703. /**
  42704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42705. * in order to better appreciate the issue one might have.
  42706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42707. */
  42708. export class RayHelper {
  42709. /**
  42710. * Defines the ray we are currently tryin to visualize.
  42711. */
  42712. ray: Nullable<Ray>;
  42713. private _renderPoints;
  42714. private _renderLine;
  42715. private _renderFunction;
  42716. private _scene;
  42717. private _updateToMeshFunction;
  42718. private _attachedToMesh;
  42719. private _meshSpaceDirection;
  42720. private _meshSpaceOrigin;
  42721. /**
  42722. * Helper function to create a colored helper in a scene in one line.
  42723. * @param ray Defines the ray we are currently tryin to visualize
  42724. * @param scene Defines the scene the ray is used in
  42725. * @param color Defines the color we want to see the ray in
  42726. * @returns The newly created ray helper.
  42727. */
  42728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42729. /**
  42730. * Instantiate a new ray helper.
  42731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42732. * in order to better appreciate the issue one might have.
  42733. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42734. * @param ray Defines the ray we are currently tryin to visualize
  42735. */
  42736. constructor(ray: Ray);
  42737. /**
  42738. * Shows the ray we are willing to debug.
  42739. * @param scene Defines the scene the ray needs to be rendered in
  42740. * @param color Defines the color the ray needs to be rendered in
  42741. */
  42742. show(scene: Scene, color?: Color3): void;
  42743. /**
  42744. * Hides the ray we are debugging.
  42745. */
  42746. hide(): void;
  42747. private _render;
  42748. /**
  42749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42750. * @param mesh Defines the mesh we want the helper attached to
  42751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42753. * @param length Defines the length of the ray
  42754. */
  42755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42756. /**
  42757. * Detach the ray helper from the mesh it has previously been attached to.
  42758. */
  42759. detachFromMesh(): void;
  42760. private _updateToMesh;
  42761. /**
  42762. * Dispose the helper and release its associated resources.
  42763. */
  42764. dispose(): void;
  42765. }
  42766. }
  42767. declare module "babylonjs/Debug/skeletonViewer" {
  42768. import { Color3 } from "babylonjs/Maths/math";
  42769. import { Scene } from "babylonjs/scene";
  42770. import { Nullable } from "babylonjs/types";
  42771. import { Skeleton } from "babylonjs/Bones/skeleton";
  42772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42773. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42774. /**
  42775. * Class used to render a debug view of a given skeleton
  42776. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42777. */
  42778. export class SkeletonViewer {
  42779. /** defines the skeleton to render */
  42780. skeleton: Skeleton;
  42781. /** defines the mesh attached to the skeleton */
  42782. mesh: AbstractMesh;
  42783. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42784. autoUpdateBonesMatrices: boolean;
  42785. /** defines the rendering group id to use with the viewer */
  42786. renderingGroupId: number;
  42787. /** Gets or sets the color used to render the skeleton */
  42788. color: Color3;
  42789. private _scene;
  42790. private _debugLines;
  42791. private _debugMesh;
  42792. private _isEnabled;
  42793. private _renderFunction;
  42794. private _utilityLayer;
  42795. /**
  42796. * Returns the mesh used to render the bones
  42797. */
  42798. readonly debugMesh: Nullable<LinesMesh>;
  42799. /**
  42800. * Creates a new SkeletonViewer
  42801. * @param skeleton defines the skeleton to render
  42802. * @param mesh defines the mesh attached to the skeleton
  42803. * @param scene defines the hosting scene
  42804. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42805. * @param renderingGroupId defines the rendering group id to use with the viewer
  42806. */
  42807. constructor(
  42808. /** defines the skeleton to render */
  42809. skeleton: Skeleton,
  42810. /** defines the mesh attached to the skeleton */
  42811. mesh: AbstractMesh, scene: Scene,
  42812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42813. autoUpdateBonesMatrices?: boolean,
  42814. /** defines the rendering group id to use with the viewer */
  42815. renderingGroupId?: number);
  42816. /** Gets or sets a boolean indicating if the viewer is enabled */
  42817. isEnabled: boolean;
  42818. private _getBonePosition;
  42819. private _getLinesForBonesWithLength;
  42820. private _getLinesForBonesNoLength;
  42821. /** Update the viewer to sync with current skeleton state */
  42822. update(): void;
  42823. /** Release associated resources */
  42824. dispose(): void;
  42825. }
  42826. }
  42827. declare module "babylonjs/Debug/index" {
  42828. export * from "babylonjs/Debug/axesViewer";
  42829. export * from "babylonjs/Debug/boneAxesViewer";
  42830. export * from "babylonjs/Debug/debugLayer";
  42831. export * from "babylonjs/Debug/physicsViewer";
  42832. export * from "babylonjs/Debug/rayHelper";
  42833. export * from "babylonjs/Debug/skeletonViewer";
  42834. }
  42835. declare module "babylonjs/Engines/nullEngine" {
  42836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42837. import { Scene } from "babylonjs/scene";
  42838. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42839. import { Engine } from "babylonjs/Engines/engine";
  42840. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42841. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42843. import { Effect } from "babylonjs/Materials/effect";
  42844. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42845. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42846. /**
  42847. * Options to create the null engine
  42848. */
  42849. export class NullEngineOptions {
  42850. /**
  42851. * Render width (Default: 512)
  42852. */
  42853. renderWidth: number;
  42854. /**
  42855. * Render height (Default: 256)
  42856. */
  42857. renderHeight: number;
  42858. /**
  42859. * Texture size (Default: 512)
  42860. */
  42861. textureSize: number;
  42862. /**
  42863. * If delta time between frames should be constant
  42864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42865. */
  42866. deterministicLockstep: boolean;
  42867. /**
  42868. * Maximum about of steps between frames (Default: 4)
  42869. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42870. */
  42871. lockstepMaxSteps: number;
  42872. }
  42873. /**
  42874. * The null engine class provides support for headless version of babylon.js.
  42875. * This can be used in server side scenario or for testing purposes
  42876. */
  42877. export class NullEngine extends Engine {
  42878. private _options;
  42879. /**
  42880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42881. */
  42882. isDeterministicLockStep(): boolean;
  42883. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42884. getLockstepMaxSteps(): number;
  42885. /**
  42886. * Sets hardware scaling, used to save performance if needed
  42887. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42888. */
  42889. getHardwareScalingLevel(): number;
  42890. constructor(options?: NullEngineOptions);
  42891. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42892. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42893. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42894. getRenderWidth(useScreen?: boolean): number;
  42895. getRenderHeight(useScreen?: boolean): number;
  42896. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42897. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42900. bindSamplers(effect: Effect): void;
  42901. enableEffect(effect: Effect): void;
  42902. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42903. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42904. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42905. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42906. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42907. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42908. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42909. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42911. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42912. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42913. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42914. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42915. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42916. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42917. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42918. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42919. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42920. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42921. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42922. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42923. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42924. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42925. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42926. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42927. bindBuffers(vertexBuffers: {
  42928. [key: string]: VertexBuffer;
  42929. }, indexBuffer: DataBuffer, effect: Effect): void;
  42930. wipeCaches(bruteForce?: boolean): void;
  42931. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42932. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42934. /** @hidden */
  42935. _createTexture(): WebGLTexture;
  42936. /** @hidden */
  42937. _releaseTexture(texture: InternalTexture): void;
  42938. 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;
  42939. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42940. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42941. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42943. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42944. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42945. areAllEffectsReady(): boolean;
  42946. /**
  42947. * @hidden
  42948. * Get the current error code of the webGL context
  42949. * @returns the error code
  42950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42951. */
  42952. getError(): number;
  42953. /** @hidden */
  42954. _getUnpackAlignement(): number;
  42955. /** @hidden */
  42956. _unpackFlipY(value: boolean): void;
  42957. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42958. /**
  42959. * Updates a dynamic vertex buffer.
  42960. * @param vertexBuffer the vertex buffer to update
  42961. * @param data the data used to update the vertex buffer
  42962. * @param byteOffset the byte offset of the data (optional)
  42963. * @param byteLength the byte length of the data (optional)
  42964. */
  42965. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42966. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42967. /** @hidden */
  42968. _bindTexture(channel: number, texture: InternalTexture): void;
  42969. /** @hidden */
  42970. _releaseBuffer(buffer: DataBuffer): boolean;
  42971. releaseEffects(): void;
  42972. displayLoadingUI(): void;
  42973. hideLoadingUI(): void;
  42974. /** @hidden */
  42975. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42976. /** @hidden */
  42977. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42978. /** @hidden */
  42979. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42980. /** @hidden */
  42981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42982. }
  42983. }
  42984. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42985. import { Nullable, int } from "babylonjs/types";
  42986. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42987. /** @hidden */
  42988. export class _OcclusionDataStorage {
  42989. /** @hidden */
  42990. occlusionInternalRetryCounter: number;
  42991. /** @hidden */
  42992. isOcclusionQueryInProgress: boolean;
  42993. /** @hidden */
  42994. isOccluded: boolean;
  42995. /** @hidden */
  42996. occlusionRetryCount: number;
  42997. /** @hidden */
  42998. occlusionType: number;
  42999. /** @hidden */
  43000. occlusionQueryAlgorithmType: number;
  43001. }
  43002. module "babylonjs/Engines/engine" {
  43003. interface Engine {
  43004. /**
  43005. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43006. * @return the new query
  43007. */
  43008. createQuery(): WebGLQuery;
  43009. /**
  43010. * Delete and release a webGL query
  43011. * @param query defines the query to delete
  43012. * @return the current engine
  43013. */
  43014. deleteQuery(query: WebGLQuery): Engine;
  43015. /**
  43016. * Check if a given query has resolved and got its value
  43017. * @param query defines the query to check
  43018. * @returns true if the query got its value
  43019. */
  43020. isQueryResultAvailable(query: WebGLQuery): boolean;
  43021. /**
  43022. * Gets the value of a given query
  43023. * @param query defines the query to check
  43024. * @returns the value of the query
  43025. */
  43026. getQueryResult(query: WebGLQuery): number;
  43027. /**
  43028. * Initiates an occlusion query
  43029. * @param algorithmType defines the algorithm to use
  43030. * @param query defines the query to use
  43031. * @returns the current engine
  43032. * @see http://doc.babylonjs.com/features/occlusionquery
  43033. */
  43034. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43035. /**
  43036. * Ends an occlusion query
  43037. * @see http://doc.babylonjs.com/features/occlusionquery
  43038. * @param algorithmType defines the algorithm to use
  43039. * @returns the current engine
  43040. */
  43041. endOcclusionQuery(algorithmType: number): Engine;
  43042. /**
  43043. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43044. * Please note that only one query can be issued at a time
  43045. * @returns a time token used to track the time span
  43046. */
  43047. startTimeQuery(): Nullable<_TimeToken>;
  43048. /**
  43049. * Ends a time query
  43050. * @param token defines the token used to measure the time span
  43051. * @returns the time spent (in ns)
  43052. */
  43053. endTimeQuery(token: _TimeToken): int;
  43054. /** @hidden */
  43055. _currentNonTimestampToken: Nullable<_TimeToken>;
  43056. /** @hidden */
  43057. _createTimeQuery(): WebGLQuery;
  43058. /** @hidden */
  43059. _deleteTimeQuery(query: WebGLQuery): void;
  43060. /** @hidden */
  43061. _getGlAlgorithmType(algorithmType: number): number;
  43062. /** @hidden */
  43063. _getTimeQueryResult(query: WebGLQuery): any;
  43064. /** @hidden */
  43065. _getTimeQueryAvailability(query: WebGLQuery): any;
  43066. }
  43067. }
  43068. module "babylonjs/Meshes/abstractMesh" {
  43069. interface AbstractMesh {
  43070. /**
  43071. * Backing filed
  43072. * @hidden
  43073. */
  43074. __occlusionDataStorage: _OcclusionDataStorage;
  43075. /**
  43076. * Access property
  43077. * @hidden
  43078. */
  43079. _occlusionDataStorage: _OcclusionDataStorage;
  43080. /**
  43081. * 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.
  43082. * The default value is -1 which means don't break the query and wait till the result
  43083. * @see http://doc.babylonjs.com/features/occlusionquery
  43084. */
  43085. occlusionRetryCount: number;
  43086. /**
  43087. * 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:
  43088. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43089. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43090. * * 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.
  43091. * @see http://doc.babylonjs.com/features/occlusionquery
  43092. */
  43093. occlusionType: number;
  43094. /**
  43095. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43096. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43097. * * 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.
  43098. * @see http://doc.babylonjs.com/features/occlusionquery
  43099. */
  43100. occlusionQueryAlgorithmType: number;
  43101. /**
  43102. * 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
  43103. * @see http://doc.babylonjs.com/features/occlusionquery
  43104. */
  43105. isOccluded: boolean;
  43106. /**
  43107. * Flag to check the progress status of the query
  43108. * @see http://doc.babylonjs.com/features/occlusionquery
  43109. */
  43110. isOcclusionQueryInProgress: boolean;
  43111. }
  43112. }
  43113. }
  43114. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43115. import { Nullable } from "babylonjs/types";
  43116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43117. /** @hidden */
  43118. export var _forceTransformFeedbackToBundle: boolean;
  43119. module "babylonjs/Engines/engine" {
  43120. interface Engine {
  43121. /**
  43122. * Creates a webGL transform feedback object
  43123. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43124. * @returns the webGL transform feedback object
  43125. */
  43126. createTransformFeedback(): WebGLTransformFeedback;
  43127. /**
  43128. * Delete a webGL transform feedback object
  43129. * @param value defines the webGL transform feedback object to delete
  43130. */
  43131. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43132. /**
  43133. * Bind a webGL transform feedback object to the webgl context
  43134. * @param value defines the webGL transform feedback object to bind
  43135. */
  43136. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43137. /**
  43138. * Begins a transform feedback operation
  43139. * @param usePoints defines if points or triangles must be used
  43140. */
  43141. beginTransformFeedback(usePoints: boolean): void;
  43142. /**
  43143. * Ends a transform feedback operation
  43144. */
  43145. endTransformFeedback(): void;
  43146. /**
  43147. * Specify the varyings to use with transform feedback
  43148. * @param program defines the associated webGL program
  43149. * @param value defines the list of strings representing the varying names
  43150. */
  43151. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43152. /**
  43153. * Bind a webGL buffer for a transform feedback operation
  43154. * @param value defines the webGL buffer to bind
  43155. */
  43156. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43157. }
  43158. }
  43159. }
  43160. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43161. import { Scene } from "babylonjs/scene";
  43162. import { Engine } from "babylonjs/Engines/engine";
  43163. import { Texture } from "babylonjs/Materials/Textures/texture";
  43164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43165. import "babylonjs/Engines/Extensions/engine.multiRender";
  43166. /**
  43167. * Creation options of the multi render target texture.
  43168. */
  43169. export interface IMultiRenderTargetOptions {
  43170. /**
  43171. * Define if the texture needs to create mip maps after render.
  43172. */
  43173. generateMipMaps?: boolean;
  43174. /**
  43175. * Define the types of all the draw buffers we want to create
  43176. */
  43177. types?: number[];
  43178. /**
  43179. * Define the sampling modes of all the draw buffers we want to create
  43180. */
  43181. samplingModes?: number[];
  43182. /**
  43183. * Define if a depth buffer is required
  43184. */
  43185. generateDepthBuffer?: boolean;
  43186. /**
  43187. * Define if a stencil buffer is required
  43188. */
  43189. generateStencilBuffer?: boolean;
  43190. /**
  43191. * Define if a depth texture is required instead of a depth buffer
  43192. */
  43193. generateDepthTexture?: boolean;
  43194. /**
  43195. * Define the number of desired draw buffers
  43196. */
  43197. textureCount?: number;
  43198. /**
  43199. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43200. */
  43201. doNotChangeAspectRatio?: boolean;
  43202. /**
  43203. * Define the default type of the buffers we are creating
  43204. */
  43205. defaultType?: number;
  43206. }
  43207. /**
  43208. * A multi render target, like a render target provides the ability to render to a texture.
  43209. * Unlike the render target, it can render to several draw buffers in one draw.
  43210. * This is specially interesting in deferred rendering or for any effects requiring more than
  43211. * just one color from a single pass.
  43212. */
  43213. export class MultiRenderTarget extends RenderTargetTexture {
  43214. private _internalTextures;
  43215. private _textures;
  43216. private _multiRenderTargetOptions;
  43217. /**
  43218. * Get if draw buffers are currently supported by the used hardware and browser.
  43219. */
  43220. readonly isSupported: boolean;
  43221. /**
  43222. * Get the list of textures generated by the multi render target.
  43223. */
  43224. readonly textures: Texture[];
  43225. /**
  43226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43227. */
  43228. readonly depthTexture: Texture;
  43229. /**
  43230. * Set the wrapping mode on U of all the textures we are rendering to.
  43231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43232. */
  43233. wrapU: number;
  43234. /**
  43235. * Set the wrapping mode on V of all the textures we are rendering to.
  43236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43237. */
  43238. wrapV: number;
  43239. /**
  43240. * Instantiate a new multi render target texture.
  43241. * A multi render target, like a render target provides the ability to render to a texture.
  43242. * Unlike the render target, it can render to several draw buffers in one draw.
  43243. * This is specially interesting in deferred rendering or for any effects requiring more than
  43244. * just one color from a single pass.
  43245. * @param name Define the name of the texture
  43246. * @param size Define the size of the buffers to render to
  43247. * @param count Define the number of target we are rendering into
  43248. * @param scene Define the scene the texture belongs to
  43249. * @param options Define the options used to create the multi render target
  43250. */
  43251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43252. /** @hidden */
  43253. _rebuild(): void;
  43254. private _createInternalTextures;
  43255. private _createTextures;
  43256. /**
  43257. * Define the number of samples used if MSAA is enabled.
  43258. */
  43259. samples: number;
  43260. /**
  43261. * Resize all the textures in the multi render target.
  43262. * Be carrefull as it will recreate all the data in the new texture.
  43263. * @param size Define the new size
  43264. */
  43265. resize(size: any): void;
  43266. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43267. /**
  43268. * Dispose the render targets and their associated resources
  43269. */
  43270. dispose(): void;
  43271. /**
  43272. * Release all the underlying texture used as draw buffers.
  43273. */
  43274. releaseInternalTextures(): void;
  43275. }
  43276. }
  43277. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43279. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43280. import { Nullable } from "babylonjs/types";
  43281. module "babylonjs/Engines/engine" {
  43282. interface Engine {
  43283. /**
  43284. * Unbind a list of render target textures from the webGL context
  43285. * This is used only when drawBuffer extension or webGL2 are active
  43286. * @param textures defines the render target textures to unbind
  43287. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43288. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43289. */
  43290. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43291. /**
  43292. * Create a multi render target texture
  43293. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43294. * @param size defines the size of the texture
  43295. * @param options defines the creation options
  43296. * @returns the cube texture as an InternalTexture
  43297. */
  43298. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43299. /**
  43300. * Update the sample count for a given multiple render target texture
  43301. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43302. * @param textures defines the textures to update
  43303. * @param samples defines the sample count to set
  43304. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43305. */
  43306. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43307. }
  43308. }
  43309. }
  43310. declare module "babylonjs/Engines/Extensions/index" {
  43311. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43312. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43313. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43314. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43315. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43316. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43317. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43318. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43319. }
  43320. declare module "babylonjs/Engines/index" {
  43321. export * from "babylonjs/Engines/constants";
  43322. export * from "babylonjs/Engines/engine";
  43323. export * from "babylonjs/Engines/engineStore";
  43324. export * from "babylonjs/Engines/nullEngine";
  43325. export * from "babylonjs/Engines/Extensions/index";
  43326. export * from "babylonjs/Engines/IPipelineContext";
  43327. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43328. }
  43329. declare module "babylonjs/Events/clipboardEvents" {
  43330. /**
  43331. * Gather the list of clipboard event types as constants.
  43332. */
  43333. export class ClipboardEventTypes {
  43334. /**
  43335. * The clipboard event is fired when a copy command is active (pressed).
  43336. */
  43337. static readonly COPY: number;
  43338. /**
  43339. * The clipboard event is fired when a cut command is active (pressed).
  43340. */
  43341. static readonly CUT: number;
  43342. /**
  43343. * The clipboard event is fired when a paste command is active (pressed).
  43344. */
  43345. static readonly PASTE: number;
  43346. }
  43347. /**
  43348. * This class is used to store clipboard related info for the onClipboardObservable event.
  43349. */
  43350. export class ClipboardInfo {
  43351. /**
  43352. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43353. */
  43354. type: number;
  43355. /**
  43356. * Defines the related dom event
  43357. */
  43358. event: ClipboardEvent;
  43359. /**
  43360. *Creates an instance of ClipboardInfo.
  43361. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43362. * @param event Defines the related dom event
  43363. */
  43364. constructor(
  43365. /**
  43366. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43367. */
  43368. type: number,
  43369. /**
  43370. * Defines the related dom event
  43371. */
  43372. event: ClipboardEvent);
  43373. /**
  43374. * Get the clipboard event's type from the keycode.
  43375. * @param keyCode Defines the keyCode for the current keyboard event.
  43376. * @return {number}
  43377. */
  43378. static GetTypeFromCharacter(keyCode: number): number;
  43379. }
  43380. }
  43381. declare module "babylonjs/Events/index" {
  43382. export * from "babylonjs/Events/keyboardEvents";
  43383. export * from "babylonjs/Events/pointerEvents";
  43384. export * from "babylonjs/Events/clipboardEvents";
  43385. }
  43386. declare module "babylonjs/Loading/sceneLoader" {
  43387. import { Observable } from "babylonjs/Misc/observable";
  43388. import { Nullable } from "babylonjs/types";
  43389. import { Scene } from "babylonjs/scene";
  43390. import { Engine } from "babylonjs/Engines/engine";
  43391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43392. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43393. import { AssetContainer } from "babylonjs/assetContainer";
  43394. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43395. import { Skeleton } from "babylonjs/Bones/skeleton";
  43396. /**
  43397. * Class used to represent data loading progression
  43398. */
  43399. export class SceneLoaderProgressEvent {
  43400. /** defines if data length to load can be evaluated */
  43401. readonly lengthComputable: boolean;
  43402. /** defines the loaded data length */
  43403. readonly loaded: number;
  43404. /** defines the data length to load */
  43405. readonly total: number;
  43406. /**
  43407. * Create a new progress event
  43408. * @param lengthComputable defines if data length to load can be evaluated
  43409. * @param loaded defines the loaded data length
  43410. * @param total defines the data length to load
  43411. */
  43412. constructor(
  43413. /** defines if data length to load can be evaluated */
  43414. lengthComputable: boolean,
  43415. /** defines the loaded data length */
  43416. loaded: number,
  43417. /** defines the data length to load */
  43418. total: number);
  43419. /**
  43420. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43421. * @param event defines the source event
  43422. * @returns a new SceneLoaderProgressEvent
  43423. */
  43424. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43425. }
  43426. /**
  43427. * Interface used by SceneLoader plugins to define supported file extensions
  43428. */
  43429. export interface ISceneLoaderPluginExtensions {
  43430. /**
  43431. * Defines the list of supported extensions
  43432. */
  43433. [extension: string]: {
  43434. isBinary: boolean;
  43435. };
  43436. }
  43437. /**
  43438. * Interface used by SceneLoader plugin factory
  43439. */
  43440. export interface ISceneLoaderPluginFactory {
  43441. /**
  43442. * Defines the name of the factory
  43443. */
  43444. name: string;
  43445. /**
  43446. * Function called to create a new plugin
  43447. * @return the new plugin
  43448. */
  43449. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43450. /**
  43451. * Boolean indicating if the plugin can direct load specific data
  43452. */
  43453. canDirectLoad?: (data: string) => boolean;
  43454. }
  43455. /**
  43456. * Interface used to define a SceneLoader plugin
  43457. */
  43458. export interface ISceneLoaderPlugin {
  43459. /**
  43460. * The friendly name of this plugin.
  43461. */
  43462. name: string;
  43463. /**
  43464. * The file extensions supported by this plugin.
  43465. */
  43466. extensions: string | ISceneLoaderPluginExtensions;
  43467. /**
  43468. * Import meshes into a scene.
  43469. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43470. * @param scene The scene to import into
  43471. * @param data The data to import
  43472. * @param rootUrl The root url for scene and resources
  43473. * @param meshes The meshes array to import into
  43474. * @param particleSystems The particle systems array to import into
  43475. * @param skeletons The skeletons array to import into
  43476. * @param onError The callback when import fails
  43477. * @returns True if successful or false otherwise
  43478. */
  43479. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43480. /**
  43481. * Load into a scene.
  43482. * @param scene The scene to load into
  43483. * @param data The data to import
  43484. * @param rootUrl The root url for scene and resources
  43485. * @param onError The callback when import fails
  43486. * @returns true if successful or false otherwise
  43487. */
  43488. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43489. /**
  43490. * The callback that returns true if the data can be directly loaded.
  43491. */
  43492. canDirectLoad?: (data: string) => boolean;
  43493. /**
  43494. * The callback that allows custom handling of the root url based on the response url.
  43495. */
  43496. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43497. /**
  43498. * Load into an asset container.
  43499. * @param scene The scene to load into
  43500. * @param data The data to import
  43501. * @param rootUrl The root url for scene and resources
  43502. * @param onError The callback when import fails
  43503. * @returns The loaded asset container
  43504. */
  43505. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43506. }
  43507. /**
  43508. * Interface used to define an async SceneLoader plugin
  43509. */
  43510. export interface ISceneLoaderPluginAsync {
  43511. /**
  43512. * The friendly name of this plugin.
  43513. */
  43514. name: string;
  43515. /**
  43516. * The file extensions supported by this plugin.
  43517. */
  43518. extensions: string | ISceneLoaderPluginExtensions;
  43519. /**
  43520. * Import meshes into a scene.
  43521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43522. * @param scene The scene to import into
  43523. * @param data The data to import
  43524. * @param rootUrl The root url for scene and resources
  43525. * @param onProgress The callback when the load progresses
  43526. * @param fileName Defines the name of the file to load
  43527. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43528. */
  43529. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43530. meshes: AbstractMesh[];
  43531. particleSystems: IParticleSystem[];
  43532. skeletons: Skeleton[];
  43533. animationGroups: AnimationGroup[];
  43534. }>;
  43535. /**
  43536. * Load into a scene.
  43537. * @param scene The scene to load into
  43538. * @param data The data to import
  43539. * @param rootUrl The root url for scene and resources
  43540. * @param onProgress The callback when the load progresses
  43541. * @param fileName Defines the name of the file to load
  43542. * @returns Nothing
  43543. */
  43544. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43545. /**
  43546. * The callback that returns true if the data can be directly loaded.
  43547. */
  43548. canDirectLoad?: (data: string) => boolean;
  43549. /**
  43550. * The callback that allows custom handling of the root url based on the response url.
  43551. */
  43552. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43553. /**
  43554. * Load into an asset container.
  43555. * @param scene The scene to load into
  43556. * @param data The data to import
  43557. * @param rootUrl The root url for scene and resources
  43558. * @param onProgress The callback when the load progresses
  43559. * @param fileName Defines the name of the file to load
  43560. * @returns The loaded asset container
  43561. */
  43562. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43563. }
  43564. /**
  43565. * Class used to load scene from various file formats using registered plugins
  43566. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43567. */
  43568. export class SceneLoader {
  43569. /**
  43570. * No logging while loading
  43571. */
  43572. static readonly NO_LOGGING: number;
  43573. /**
  43574. * Minimal logging while loading
  43575. */
  43576. static readonly MINIMAL_LOGGING: number;
  43577. /**
  43578. * Summary logging while loading
  43579. */
  43580. static readonly SUMMARY_LOGGING: number;
  43581. /**
  43582. * Detailled logging while loading
  43583. */
  43584. static readonly DETAILED_LOGGING: number;
  43585. /**
  43586. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43587. */
  43588. static ForceFullSceneLoadingForIncremental: boolean;
  43589. /**
  43590. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43591. */
  43592. static ShowLoadingScreen: boolean;
  43593. /**
  43594. * Defines the current logging level (while loading the scene)
  43595. * @ignorenaming
  43596. */
  43597. static loggingLevel: number;
  43598. /**
  43599. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43600. */
  43601. static CleanBoneMatrixWeights: boolean;
  43602. /**
  43603. * Event raised when a plugin is used to load a scene
  43604. */
  43605. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43606. private static _registeredPlugins;
  43607. private static _getDefaultPlugin;
  43608. private static _getPluginForExtension;
  43609. private static _getPluginForDirectLoad;
  43610. private static _getPluginForFilename;
  43611. private static _getDirectLoad;
  43612. private static _loadData;
  43613. private static _getFileInfo;
  43614. /**
  43615. * Gets a plugin that can load the given extension
  43616. * @param extension defines the extension to load
  43617. * @returns a plugin or null if none works
  43618. */
  43619. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43620. /**
  43621. * Gets a boolean indicating that the given extension can be loaded
  43622. * @param extension defines the extension to load
  43623. * @returns true if the extension is supported
  43624. */
  43625. static IsPluginForExtensionAvailable(extension: string): boolean;
  43626. /**
  43627. * Adds a new plugin to the list of registered plugins
  43628. * @param plugin defines the plugin to add
  43629. */
  43630. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43631. /**
  43632. * Import meshes into a scene
  43633. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43634. * @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)
  43635. * @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)
  43636. * @param scene the instance of BABYLON.Scene to append to
  43637. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43638. * @param onProgress a callback with a progress event for each file being loaded
  43639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The loaded plugin
  43642. */
  43643. 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>;
  43644. /**
  43645. * Import meshes into a scene
  43646. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43647. * @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)
  43648. * @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)
  43649. * @param scene the instance of BABYLON.Scene to append to
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param pluginExtension the extension used to determine the plugin
  43652. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43653. */
  43654. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43655. meshes: AbstractMesh[];
  43656. particleSystems: IParticleSystem[];
  43657. skeletons: Skeleton[];
  43658. animationGroups: AnimationGroup[];
  43659. }>;
  43660. /**
  43661. * Load a scene
  43662. * @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)
  43663. * @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)
  43664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43665. * @param onSuccess a callback with the scene when import succeeds
  43666. * @param onProgress a callback with a progress event for each file being loaded
  43667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43668. * @param pluginExtension the extension used to determine the plugin
  43669. * @returns The loaded plugin
  43670. */
  43671. 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>;
  43672. /**
  43673. * Load a scene
  43674. * @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)
  43675. * @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)
  43676. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param pluginExtension the extension used to determine the plugin
  43679. * @returns The loaded scene
  43680. */
  43681. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43682. /**
  43683. * Append a scene
  43684. * @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)
  43685. * @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)
  43686. * @param scene is the instance of BABYLON.Scene to append to
  43687. * @param onSuccess a callback with the scene when import succeeds
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43690. * @param pluginExtension the extension used to determine the plugin
  43691. * @returns The loaded plugin
  43692. */
  43693. 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>;
  43694. /**
  43695. * Append a scene
  43696. * @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)
  43697. * @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)
  43698. * @param scene is the instance of BABYLON.Scene to append to
  43699. * @param onProgress a callback with a progress event for each file being loaded
  43700. * @param pluginExtension the extension used to determine the plugin
  43701. * @returns The given scene
  43702. */
  43703. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43704. /**
  43705. * Load a scene into an asset container
  43706. * @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)
  43707. * @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)
  43708. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43709. * @param onSuccess a callback with the scene when import succeeds
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43712. * @param pluginExtension the extension used to determine the plugin
  43713. * @returns The loaded plugin
  43714. */
  43715. 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>;
  43716. /**
  43717. * Load a scene into an asset container
  43718. * @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)
  43719. * @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)
  43720. * @param scene is the instance of Scene to append to
  43721. * @param onProgress a callback with a progress event for each file being loaded
  43722. * @param pluginExtension the extension used to determine the plugin
  43723. * @returns The loaded asset container
  43724. */
  43725. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43726. }
  43727. }
  43728. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43729. import { Scene } from "babylonjs/scene";
  43730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43731. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43732. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43733. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43734. /**
  43735. * Google Daydream controller
  43736. */
  43737. export class DaydreamController extends WebVRController {
  43738. /**
  43739. * Base Url for the controller model.
  43740. */
  43741. static MODEL_BASE_URL: string;
  43742. /**
  43743. * File name for the controller model.
  43744. */
  43745. static MODEL_FILENAME: string;
  43746. /**
  43747. * Gamepad Id prefix used to identify Daydream Controller.
  43748. */
  43749. static readonly GAMEPAD_ID_PREFIX: string;
  43750. /**
  43751. * Creates a new DaydreamController from a gamepad
  43752. * @param vrGamepad the gamepad that the controller should be created from
  43753. */
  43754. constructor(vrGamepad: any);
  43755. /**
  43756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43757. * @param scene scene in which to add meshes
  43758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43759. */
  43760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43761. /**
  43762. * Called once for each button that changed state since the last frame
  43763. * @param buttonIdx Which button index changed
  43764. * @param state New state of the button
  43765. * @param changes Which properties on the state changed since last frame
  43766. */
  43767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43768. }
  43769. }
  43770. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43771. import { Scene } from "babylonjs/scene";
  43772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43773. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43774. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43775. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43776. /**
  43777. * Gear VR Controller
  43778. */
  43779. export class GearVRController extends WebVRController {
  43780. /**
  43781. * Base Url for the controller model.
  43782. */
  43783. static MODEL_BASE_URL: string;
  43784. /**
  43785. * File name for the controller model.
  43786. */
  43787. static MODEL_FILENAME: string;
  43788. /**
  43789. * Gamepad Id prefix used to identify this controller.
  43790. */
  43791. static readonly GAMEPAD_ID_PREFIX: string;
  43792. private readonly _buttonIndexToObservableNameMap;
  43793. /**
  43794. * Creates a new GearVRController from a gamepad
  43795. * @param vrGamepad the gamepad that the controller should be created from
  43796. */
  43797. constructor(vrGamepad: any);
  43798. /**
  43799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43800. * @param scene scene in which to add meshes
  43801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43802. */
  43803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43804. /**
  43805. * Called once for each button that changed state since the last frame
  43806. * @param buttonIdx Which button index changed
  43807. * @param state New state of the button
  43808. * @param changes Which properties on the state changed since last frame
  43809. */
  43810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43811. }
  43812. }
  43813. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43814. import { Scene } from "babylonjs/scene";
  43815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43816. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43817. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43818. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43819. /**
  43820. * Generic Controller
  43821. */
  43822. export class GenericController extends WebVRController {
  43823. /**
  43824. * Base Url for the controller model.
  43825. */
  43826. static readonly MODEL_BASE_URL: string;
  43827. /**
  43828. * File name for the controller model.
  43829. */
  43830. static readonly MODEL_FILENAME: string;
  43831. /**
  43832. * Creates a new GenericController from a gamepad
  43833. * @param vrGamepad the gamepad that the controller should be created from
  43834. */
  43835. constructor(vrGamepad: any);
  43836. /**
  43837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43838. * @param scene scene in which to add meshes
  43839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43840. */
  43841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43842. /**
  43843. * Called once for each button that changed state since the last frame
  43844. * @param buttonIdx Which button index changed
  43845. * @param state New state of the button
  43846. * @param changes Which properties on the state changed since last frame
  43847. */
  43848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43849. }
  43850. }
  43851. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43852. import { Observable } from "babylonjs/Misc/observable";
  43853. import { Scene } from "babylonjs/scene";
  43854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43855. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43856. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43857. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43858. /**
  43859. * Oculus Touch Controller
  43860. */
  43861. export class OculusTouchController extends WebVRController {
  43862. /**
  43863. * Base Url for the controller model.
  43864. */
  43865. static MODEL_BASE_URL: string;
  43866. /**
  43867. * File name for the left controller model.
  43868. */
  43869. static MODEL_LEFT_FILENAME: string;
  43870. /**
  43871. * File name for the right controller model.
  43872. */
  43873. static MODEL_RIGHT_FILENAME: string;
  43874. /**
  43875. * Fired when the secondary trigger on this controller is modified
  43876. */
  43877. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43878. /**
  43879. * Fired when the thumb rest on this controller is modified
  43880. */
  43881. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43882. /**
  43883. * Creates a new OculusTouchController from a gamepad
  43884. * @param vrGamepad the gamepad that the controller should be created from
  43885. */
  43886. constructor(vrGamepad: any);
  43887. /**
  43888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43889. * @param scene scene in which to add meshes
  43890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43891. */
  43892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43893. /**
  43894. * Fired when the A button on this controller is modified
  43895. */
  43896. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the B button on this controller is modified
  43899. */
  43900. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the X button on this controller is modified
  43903. */
  43904. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Fired when the Y button on this controller is modified
  43907. */
  43908. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43909. /**
  43910. * Called once for each button that changed state since the last frame
  43911. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43912. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43913. * 2) secondary trigger (same)
  43914. * 3) A (right) X (left), touch, pressed = value
  43915. * 4) B / Y
  43916. * 5) thumb rest
  43917. * @param buttonIdx Which button index changed
  43918. * @param state New state of the button
  43919. * @param changes Which properties on the state changed since last frame
  43920. */
  43921. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43922. }
  43923. }
  43924. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43925. import { Scene } from "babylonjs/scene";
  43926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43927. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43928. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43929. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43930. import { Observable } from "babylonjs/Misc/observable";
  43931. /**
  43932. * Vive Controller
  43933. */
  43934. export class ViveController extends WebVRController {
  43935. /**
  43936. * Base Url for the controller model.
  43937. */
  43938. static MODEL_BASE_URL: string;
  43939. /**
  43940. * File name for the controller model.
  43941. */
  43942. static MODEL_FILENAME: string;
  43943. /**
  43944. * Creates a new ViveController from a gamepad
  43945. * @param vrGamepad the gamepad that the controller should be created from
  43946. */
  43947. constructor(vrGamepad: any);
  43948. /**
  43949. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43950. * @param scene scene in which to add meshes
  43951. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43952. */
  43953. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43954. /**
  43955. * Fired when the left button on this controller is modified
  43956. */
  43957. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Fired when the right button on this controller is modified
  43960. */
  43961. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43962. /**
  43963. * Fired when the menu button on this controller is modified
  43964. */
  43965. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Called once for each button that changed state since the last frame
  43968. * Vive mapping:
  43969. * 0: touchpad
  43970. * 1: trigger
  43971. * 2: left AND right buttons
  43972. * 3: menu button
  43973. * @param buttonIdx Which button index changed
  43974. * @param state New state of the button
  43975. * @param changes Which properties on the state changed since last frame
  43976. */
  43977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43978. }
  43979. }
  43980. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43981. import { Observable } from "babylonjs/Misc/observable";
  43982. import { Scene } from "babylonjs/scene";
  43983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43984. import { Ray } from "babylonjs/Culling/ray";
  43985. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43986. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43987. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43988. /**
  43989. * Defines the WindowsMotionController object that the state of the windows motion controller
  43990. */
  43991. export class WindowsMotionController extends WebVRController {
  43992. /**
  43993. * The base url used to load the left and right controller models
  43994. */
  43995. static MODEL_BASE_URL: string;
  43996. /**
  43997. * The name of the left controller model file
  43998. */
  43999. static MODEL_LEFT_FILENAME: string;
  44000. /**
  44001. * The name of the right controller model file
  44002. */
  44003. static MODEL_RIGHT_FILENAME: string;
  44004. /**
  44005. * The controller name prefix for this controller type
  44006. */
  44007. static readonly GAMEPAD_ID_PREFIX: string;
  44008. /**
  44009. * The controller id pattern for this controller type
  44010. */
  44011. private static readonly GAMEPAD_ID_PATTERN;
  44012. private _loadedMeshInfo;
  44013. private readonly _mapping;
  44014. /**
  44015. * Fired when the trackpad on this controller is clicked
  44016. */
  44017. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when the trackpad on this controller is modified
  44020. */
  44021. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44022. /**
  44023. * The current x and y values of this controller's trackpad
  44024. */
  44025. trackpad: StickValues;
  44026. /**
  44027. * Creates a new WindowsMotionController from a gamepad
  44028. * @param vrGamepad the gamepad that the controller should be created from
  44029. */
  44030. constructor(vrGamepad: any);
  44031. /**
  44032. * Fired when the trigger on this controller is modified
  44033. */
  44034. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Fired when the menu button on this controller is modified
  44037. */
  44038. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the grip button on this controller is modified
  44041. */
  44042. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Fired when the thumbstick button on this controller is modified
  44045. */
  44046. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44047. /**
  44048. * Fired when the touchpad button on this controller is modified
  44049. */
  44050. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44051. /**
  44052. * Fired when the touchpad values on this controller are modified
  44053. */
  44054. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44055. private _updateTrackpad;
  44056. /**
  44057. * Called once per frame by the engine.
  44058. */
  44059. update(): void;
  44060. /**
  44061. * Called once for each button that changed state since the last frame
  44062. * @param buttonIdx Which button index changed
  44063. * @param state New state of the button
  44064. * @param changes Which properties on the state changed since last frame
  44065. */
  44066. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44067. /**
  44068. * Moves the buttons on the controller mesh based on their current state
  44069. * @param buttonName the name of the button to move
  44070. * @param buttonValue the value of the button which determines the buttons new position
  44071. */
  44072. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44073. /**
  44074. * Moves the axis on the controller mesh based on its current state
  44075. * @param axis the index of the axis
  44076. * @param axisValue the value of the axis which determines the meshes new position
  44077. * @hidden
  44078. */
  44079. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44080. /**
  44081. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44082. * @param scene scene in which to add meshes
  44083. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44084. */
  44085. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44086. /**
  44087. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44088. * can be transformed by button presses and axes values, based on this._mapping.
  44089. *
  44090. * @param scene scene in which the meshes exist
  44091. * @param meshes list of meshes that make up the controller model to process
  44092. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44093. */
  44094. private processModel;
  44095. private createMeshInfo;
  44096. /**
  44097. * Gets the ray of the controller in the direction the controller is pointing
  44098. * @param length the length the resulting ray should be
  44099. * @returns a ray in the direction the controller is pointing
  44100. */
  44101. getForwardRay(length?: number): Ray;
  44102. /**
  44103. * Disposes of the controller
  44104. */
  44105. dispose(): void;
  44106. }
  44107. }
  44108. declare module "babylonjs/Gamepads/Controllers/index" {
  44109. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44110. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44111. export * from "babylonjs/Gamepads/Controllers/genericController";
  44112. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44113. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44114. export * from "babylonjs/Gamepads/Controllers/viveController";
  44115. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44116. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44117. }
  44118. declare module "babylonjs/Gamepads/index" {
  44119. export * from "babylonjs/Gamepads/Controllers/index";
  44120. export * from "babylonjs/Gamepads/gamepad";
  44121. export * from "babylonjs/Gamepads/gamepadManager";
  44122. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44123. export * from "babylonjs/Gamepads/xboxGamepad";
  44124. }
  44125. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44126. import { Observable } from "babylonjs/Misc/observable";
  44127. import { Nullable } from "babylonjs/types";
  44128. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44130. import { Mesh } from "babylonjs/Meshes/mesh";
  44131. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44132. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44133. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44134. /**
  44135. * Single axis scale gizmo
  44136. */
  44137. export class AxisScaleGizmo extends Gizmo {
  44138. private _coloredMaterial;
  44139. /**
  44140. * Drag behavior responsible for the gizmos dragging interactions
  44141. */
  44142. dragBehavior: PointerDragBehavior;
  44143. private _pointerObserver;
  44144. /**
  44145. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44146. */
  44147. snapDistance: number;
  44148. /**
  44149. * Event that fires each time the gizmo snaps to a new location.
  44150. * * snapDistance is the the change in distance
  44151. */
  44152. onSnapObservable: Observable<{
  44153. snapDistance: number;
  44154. }>;
  44155. /**
  44156. * If the scaling operation should be done on all axis (default: false)
  44157. */
  44158. uniformScaling: boolean;
  44159. /**
  44160. * Creates an AxisScaleGizmo
  44161. * @param gizmoLayer The utility layer the gizmo will be added to
  44162. * @param dragAxis The axis which the gizmo will be able to scale on
  44163. * @param color The color of the gizmo
  44164. */
  44165. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44167. /**
  44168. * Disposes of the gizmo
  44169. */
  44170. dispose(): void;
  44171. /**
  44172. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44173. * @param mesh The mesh to replace the default mesh of the gizmo
  44174. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44175. */
  44176. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44177. }
  44178. }
  44179. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44180. import { Observable } from "babylonjs/Misc/observable";
  44181. import { Nullable } from "babylonjs/types";
  44182. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44184. import { Mesh } from "babylonjs/Meshes/mesh";
  44185. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44186. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44187. import "babylonjs/Meshes/Builders/boxBuilder";
  44188. /**
  44189. * Bounding box gizmo
  44190. */
  44191. export class BoundingBoxGizmo extends Gizmo {
  44192. private _lineBoundingBox;
  44193. private _rotateSpheresParent;
  44194. private _scaleBoxesParent;
  44195. private _boundingDimensions;
  44196. private _renderObserver;
  44197. private _pointerObserver;
  44198. private _scaleDragSpeed;
  44199. private _tmpQuaternion;
  44200. private _tmpVector;
  44201. private _tmpRotationMatrix;
  44202. /**
  44203. * 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)
  44204. */
  44205. ignoreChildren: boolean;
  44206. /**
  44207. * 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)
  44208. */
  44209. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44210. /**
  44211. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44212. */
  44213. rotationSphereSize: number;
  44214. /**
  44215. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44216. */
  44217. scaleBoxSize: number;
  44218. /**
  44219. * 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)
  44220. */
  44221. fixedDragMeshScreenSize: boolean;
  44222. /**
  44223. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44224. */
  44225. fixedDragMeshScreenSizeDistanceFactor: number;
  44226. /**
  44227. * Fired when a rotation sphere or scale box is dragged
  44228. */
  44229. onDragStartObservable: Observable<{}>;
  44230. /**
  44231. * Fired when a scale box is dragged
  44232. */
  44233. onScaleBoxDragObservable: Observable<{}>;
  44234. /**
  44235. * Fired when a scale box drag is ended
  44236. */
  44237. onScaleBoxDragEndObservable: Observable<{}>;
  44238. /**
  44239. * Fired when a rotation sphere is dragged
  44240. */
  44241. onRotationSphereDragObservable: Observable<{}>;
  44242. /**
  44243. * Fired when a rotation sphere drag is ended
  44244. */
  44245. onRotationSphereDragEndObservable: Observable<{}>;
  44246. /**
  44247. * 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)
  44248. */
  44249. scalePivot: Nullable<Vector3>;
  44250. /**
  44251. * Mesh used as a pivot to rotate the attached mesh
  44252. */
  44253. private _anchorMesh;
  44254. private _existingMeshScale;
  44255. private _dragMesh;
  44256. private pointerDragBehavior;
  44257. private coloredMaterial;
  44258. private hoverColoredMaterial;
  44259. /**
  44260. * Sets the color of the bounding box gizmo
  44261. * @param color the color to set
  44262. */
  44263. setColor(color: Color3): void;
  44264. /**
  44265. * Creates an BoundingBoxGizmo
  44266. * @param gizmoLayer The utility layer the gizmo will be added to
  44267. * @param color The color of the gizmo
  44268. */
  44269. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44270. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44271. private _selectNode;
  44272. /**
  44273. * Updates the bounding box information for the Gizmo
  44274. */
  44275. updateBoundingBox(): void;
  44276. private _updateRotationSpheres;
  44277. private _updateScaleBoxes;
  44278. /**
  44279. * Enables rotation on the specified axis and disables rotation on the others
  44280. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44281. */
  44282. setEnabledRotationAxis(axis: string): void;
  44283. /**
  44284. * Enables/disables scaling
  44285. * @param enable if scaling should be enabled
  44286. */
  44287. setEnabledScaling(enable: boolean): void;
  44288. private _updateDummy;
  44289. /**
  44290. * Enables a pointer drag behavior on the bounding box of the gizmo
  44291. */
  44292. enableDragBehavior(): void;
  44293. /**
  44294. * Disposes of the gizmo
  44295. */
  44296. dispose(): void;
  44297. /**
  44298. * 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)
  44299. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44300. * @returns the bounding box mesh with the passed in mesh as a child
  44301. */
  44302. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44303. /**
  44304. * CustomMeshes are not supported by this gizmo
  44305. * @param mesh The mesh to replace the default mesh of the gizmo
  44306. */
  44307. setCustomMesh(mesh: Mesh): void;
  44308. }
  44309. }
  44310. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44311. import { Observable } from "babylonjs/Misc/observable";
  44312. import { Nullable } from "babylonjs/types";
  44313. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44315. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44316. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44317. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44318. import "babylonjs/Meshes/Builders/linesBuilder";
  44319. /**
  44320. * Single plane rotation gizmo
  44321. */
  44322. export class PlaneRotationGizmo extends Gizmo {
  44323. /**
  44324. * Drag behavior responsible for the gizmos dragging interactions
  44325. */
  44326. dragBehavior: PointerDragBehavior;
  44327. private _pointerObserver;
  44328. /**
  44329. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44330. */
  44331. snapDistance: number;
  44332. /**
  44333. * Event that fires each time the gizmo snaps to a new location.
  44334. * * snapDistance is the the change in distance
  44335. */
  44336. onSnapObservable: Observable<{
  44337. snapDistance: number;
  44338. }>;
  44339. /**
  44340. * Creates a PlaneRotationGizmo
  44341. * @param gizmoLayer The utility layer the gizmo will be added to
  44342. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44343. * @param color The color of the gizmo
  44344. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44345. */
  44346. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44347. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44348. /**
  44349. * Disposes of the gizmo
  44350. */
  44351. dispose(): void;
  44352. }
  44353. }
  44354. declare module "babylonjs/Gizmos/rotationGizmo" {
  44355. import { Observable } from "babylonjs/Misc/observable";
  44356. import { Nullable } from "babylonjs/types";
  44357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44358. import { Mesh } from "babylonjs/Meshes/mesh";
  44359. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44360. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44361. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44362. /**
  44363. * Gizmo that enables rotating a mesh along 3 axis
  44364. */
  44365. export class RotationGizmo extends Gizmo {
  44366. /**
  44367. * Internal gizmo used for interactions on the x axis
  44368. */
  44369. xGizmo: PlaneRotationGizmo;
  44370. /**
  44371. * Internal gizmo used for interactions on the y axis
  44372. */
  44373. yGizmo: PlaneRotationGizmo;
  44374. /**
  44375. * Internal gizmo used for interactions on the z axis
  44376. */
  44377. zGizmo: PlaneRotationGizmo;
  44378. /** Fires an event when any of it's sub gizmos are dragged */
  44379. onDragStartObservable: Observable<{}>;
  44380. /** Fires an event when any of it's sub gizmos are released from dragging */
  44381. onDragEndObservable: Observable<{}>;
  44382. attachedMesh: Nullable<AbstractMesh>;
  44383. /**
  44384. * Creates a RotationGizmo
  44385. * @param gizmoLayer The utility layer the gizmo will be added to
  44386. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44387. */
  44388. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44389. updateGizmoRotationToMatchAttachedMesh: boolean;
  44390. /**
  44391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44392. */
  44393. snapDistance: number;
  44394. /**
  44395. * Ratio for the scale of the gizmo (Default: 1)
  44396. */
  44397. scaleRatio: number;
  44398. /**
  44399. * Disposes of the gizmo
  44400. */
  44401. dispose(): void;
  44402. /**
  44403. * CustomMeshes are not supported by this gizmo
  44404. * @param mesh The mesh to replace the default mesh of the gizmo
  44405. */
  44406. setCustomMesh(mesh: Mesh): void;
  44407. }
  44408. }
  44409. declare module "babylonjs/Gizmos/positionGizmo" {
  44410. import { Observable } from "babylonjs/Misc/observable";
  44411. import { Nullable } from "babylonjs/types";
  44412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44413. import { Mesh } from "babylonjs/Meshes/mesh";
  44414. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44415. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44417. /**
  44418. * Gizmo that enables dragging a mesh along 3 axis
  44419. */
  44420. export class PositionGizmo extends Gizmo {
  44421. /**
  44422. * Internal gizmo used for interactions on the x axis
  44423. */
  44424. xGizmo: AxisDragGizmo;
  44425. /**
  44426. * Internal gizmo used for interactions on the y axis
  44427. */
  44428. yGizmo: AxisDragGizmo;
  44429. /**
  44430. * Internal gizmo used for interactions on the z axis
  44431. */
  44432. zGizmo: AxisDragGizmo;
  44433. /** Fires an event when any of it's sub gizmos are dragged */
  44434. onDragStartObservable: Observable<{}>;
  44435. /** Fires an event when any of it's sub gizmos are released from dragging */
  44436. onDragEndObservable: Observable<{}>;
  44437. attachedMesh: Nullable<AbstractMesh>;
  44438. /**
  44439. * Creates a PositionGizmo
  44440. * @param gizmoLayer The utility layer the gizmo will be added to
  44441. */
  44442. constructor(gizmoLayer?: UtilityLayerRenderer);
  44443. updateGizmoRotationToMatchAttachedMesh: boolean;
  44444. /**
  44445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44446. */
  44447. snapDistance: number;
  44448. /**
  44449. * Ratio for the scale of the gizmo (Default: 1)
  44450. */
  44451. scaleRatio: number;
  44452. /**
  44453. * Disposes of the gizmo
  44454. */
  44455. dispose(): void;
  44456. /**
  44457. * CustomMeshes are not supported by this gizmo
  44458. * @param mesh The mesh to replace the default mesh of the gizmo
  44459. */
  44460. setCustomMesh(mesh: Mesh): void;
  44461. }
  44462. }
  44463. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44464. import { Scene } from "babylonjs/scene";
  44465. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44466. import { Mesh } from "babylonjs/Meshes/mesh";
  44467. import { Nullable } from "babylonjs/types";
  44468. /**
  44469. * Class containing static functions to help procedurally build meshes
  44470. */
  44471. export class PolyhedronBuilder {
  44472. /**
  44473. * Creates a polyhedron mesh
  44474. * * 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
  44475. * * The parameter `size` (positive float, default 1) sets the polygon size
  44476. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44477. * * 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`
  44478. * * 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
  44479. * * 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)`)
  44480. * * 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
  44481. * * 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
  44482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44485. * @param name defines the name of the mesh
  44486. * @param options defines the options used to create the mesh
  44487. * @param scene defines the hosting scene
  44488. * @returns the polyhedron mesh
  44489. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44490. */
  44491. static CreatePolyhedron(name: string, options: {
  44492. type?: number;
  44493. size?: number;
  44494. sizeX?: number;
  44495. sizeY?: number;
  44496. sizeZ?: number;
  44497. custom?: any;
  44498. faceUV?: Vector4[];
  44499. faceColors?: Color4[];
  44500. flat?: boolean;
  44501. updatable?: boolean;
  44502. sideOrientation?: number;
  44503. frontUVs?: Vector4;
  44504. backUVs?: Vector4;
  44505. }, scene?: Nullable<Scene>): Mesh;
  44506. }
  44507. }
  44508. declare module "babylonjs/Gizmos/scaleGizmo" {
  44509. import { Observable } from "babylonjs/Misc/observable";
  44510. import { Nullable } from "babylonjs/types";
  44511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44513. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44515. /**
  44516. * Gizmo that enables scaling a mesh along 3 axis
  44517. */
  44518. export class ScaleGizmo extends Gizmo {
  44519. /**
  44520. * Internal gizmo used for interactions on the x axis
  44521. */
  44522. xGizmo: AxisScaleGizmo;
  44523. /**
  44524. * Internal gizmo used for interactions on the y axis
  44525. */
  44526. yGizmo: AxisScaleGizmo;
  44527. /**
  44528. * Internal gizmo used for interactions on the z axis
  44529. */
  44530. zGizmo: AxisScaleGizmo;
  44531. /**
  44532. * Internal gizmo used to scale all axis equally
  44533. */
  44534. uniformScaleGizmo: AxisScaleGizmo;
  44535. /** Fires an event when any of it's sub gizmos are dragged */
  44536. onDragStartObservable: Observable<{}>;
  44537. /** Fires an event when any of it's sub gizmos are released from dragging */
  44538. onDragEndObservable: Observable<{}>;
  44539. attachedMesh: Nullable<AbstractMesh>;
  44540. /**
  44541. * Creates a ScaleGizmo
  44542. * @param gizmoLayer The utility layer the gizmo will be added to
  44543. */
  44544. constructor(gizmoLayer?: UtilityLayerRenderer);
  44545. updateGizmoRotationToMatchAttachedMesh: boolean;
  44546. /**
  44547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44548. */
  44549. snapDistance: number;
  44550. /**
  44551. * Ratio for the scale of the gizmo (Default: 1)
  44552. */
  44553. scaleRatio: number;
  44554. /**
  44555. * Disposes of the gizmo
  44556. */
  44557. dispose(): void;
  44558. }
  44559. }
  44560. declare module "babylonjs/Gizmos/gizmoManager" {
  44561. import { Observable } from "babylonjs/Misc/observable";
  44562. import { Nullable } from "babylonjs/types";
  44563. import { Scene, IDisposable } from "babylonjs/scene";
  44564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44565. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44566. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44567. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44568. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44569. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44570. /**
  44571. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44572. */
  44573. export class GizmoManager implements IDisposable {
  44574. private scene;
  44575. /**
  44576. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44577. */
  44578. gizmos: {
  44579. positionGizmo: Nullable<PositionGizmo>;
  44580. rotationGizmo: Nullable<RotationGizmo>;
  44581. scaleGizmo: Nullable<ScaleGizmo>;
  44582. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44583. };
  44584. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44585. clearGizmoOnEmptyPointerEvent: boolean;
  44586. /** Fires an event when the manager is attached to a mesh */
  44587. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44588. private _gizmosEnabled;
  44589. private _pointerObserver;
  44590. private _attachedMesh;
  44591. private _boundingBoxColor;
  44592. private _defaultUtilityLayer;
  44593. private _defaultKeepDepthUtilityLayer;
  44594. /**
  44595. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44596. */
  44597. boundingBoxDragBehavior: SixDofDragBehavior;
  44598. /**
  44599. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44600. */
  44601. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44602. /**
  44603. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44604. */
  44605. usePointerToAttachGizmos: boolean;
  44606. /**
  44607. * Instatiates a gizmo manager
  44608. * @param scene the scene to overlay the gizmos on top of
  44609. */
  44610. constructor(scene: Scene);
  44611. /**
  44612. * Attaches a set of gizmos to the specified mesh
  44613. * @param mesh The mesh the gizmo's should be attached to
  44614. */
  44615. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44616. /**
  44617. * If the position gizmo is enabled
  44618. */
  44619. positionGizmoEnabled: boolean;
  44620. /**
  44621. * If the rotation gizmo is enabled
  44622. */
  44623. rotationGizmoEnabled: boolean;
  44624. /**
  44625. * If the scale gizmo is enabled
  44626. */
  44627. scaleGizmoEnabled: boolean;
  44628. /**
  44629. * If the boundingBox gizmo is enabled
  44630. */
  44631. boundingBoxGizmoEnabled: boolean;
  44632. /**
  44633. * Disposes of the gizmo manager
  44634. */
  44635. dispose(): void;
  44636. }
  44637. }
  44638. declare module "babylonjs/Lights/directionalLight" {
  44639. import { Camera } from "babylonjs/Cameras/camera";
  44640. import { Scene } from "babylonjs/scene";
  44641. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44644. import { Effect } from "babylonjs/Materials/effect";
  44645. /**
  44646. * A directional light is defined by a direction (what a surprise!).
  44647. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44648. * 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.
  44649. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44650. */
  44651. export class DirectionalLight extends ShadowLight {
  44652. private _shadowFrustumSize;
  44653. /**
  44654. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44655. */
  44656. /**
  44657. * Specifies a fix frustum size for the shadow generation.
  44658. */
  44659. shadowFrustumSize: number;
  44660. private _shadowOrthoScale;
  44661. /**
  44662. * Gets the shadow projection scale against the optimal computed one.
  44663. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44664. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44665. */
  44666. /**
  44667. * Sets the shadow projection scale against the optimal computed one.
  44668. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44669. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44670. */
  44671. shadowOrthoScale: number;
  44672. /**
  44673. * Automatically compute the projection matrix to best fit (including all the casters)
  44674. * on each frame.
  44675. */
  44676. autoUpdateExtends: boolean;
  44677. private _orthoLeft;
  44678. private _orthoRight;
  44679. private _orthoTop;
  44680. private _orthoBottom;
  44681. /**
  44682. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44683. * The directional light is emitted from everywhere in the given direction.
  44684. * It can cast shadows.
  44685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44686. * @param name The friendly name of the light
  44687. * @param direction The direction of the light
  44688. * @param scene The scene the light belongs to
  44689. */
  44690. constructor(name: string, direction: Vector3, scene: Scene);
  44691. /**
  44692. * Returns the string "DirectionalLight".
  44693. * @return The class name
  44694. */
  44695. getClassName(): string;
  44696. /**
  44697. * Returns the integer 1.
  44698. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44699. */
  44700. getTypeID(): number;
  44701. /**
  44702. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44703. * Returns the DirectionalLight Shadow projection matrix.
  44704. */
  44705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44706. /**
  44707. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44708. * Returns the DirectionalLight Shadow projection matrix.
  44709. */
  44710. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44711. /**
  44712. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44713. * Returns the DirectionalLight Shadow projection matrix.
  44714. */
  44715. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44716. protected _buildUniformLayout(): void;
  44717. /**
  44718. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44719. * @param effect The effect to update
  44720. * @param lightIndex The index of the light in the effect to update
  44721. * @returns The directional light
  44722. */
  44723. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44724. /**
  44725. * Gets the minZ used for shadow according to both the scene and the light.
  44726. *
  44727. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44728. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44729. * @param activeCamera The camera we are returning the min for
  44730. * @returns the depth min z
  44731. */
  44732. getDepthMinZ(activeCamera: Camera): number;
  44733. /**
  44734. * Gets the maxZ used for shadow according to both the scene and the light.
  44735. *
  44736. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44737. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44738. * @param activeCamera The camera we are returning the max for
  44739. * @returns the depth max z
  44740. */
  44741. getDepthMaxZ(activeCamera: Camera): number;
  44742. /**
  44743. * Prepares the list of defines specific to the light type.
  44744. * @param defines the list of defines
  44745. * @param lightIndex defines the index of the light for the effect
  44746. */
  44747. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44748. }
  44749. }
  44750. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44751. import { Mesh } from "babylonjs/Meshes/mesh";
  44752. /**
  44753. * Class containing static functions to help procedurally build meshes
  44754. */
  44755. export class HemisphereBuilder {
  44756. /**
  44757. * Creates a hemisphere mesh
  44758. * @param name defines the name of the mesh
  44759. * @param options defines the options used to create the mesh
  44760. * @param scene defines the hosting scene
  44761. * @returns the hemisphere mesh
  44762. */
  44763. static CreateHemisphere(name: string, options: {
  44764. segments?: number;
  44765. diameter?: number;
  44766. sideOrientation?: number;
  44767. }, scene: any): Mesh;
  44768. }
  44769. }
  44770. declare module "babylonjs/Lights/spotLight" {
  44771. import { Nullable } from "babylonjs/types";
  44772. import { Scene } from "babylonjs/scene";
  44773. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44775. import { Effect } from "babylonjs/Materials/effect";
  44776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44777. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44778. /**
  44779. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44780. * These values define a cone of light starting from the position, emitting toward the direction.
  44781. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44782. * and the exponent defines the speed of the decay of the light with distance (reach).
  44783. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44784. */
  44785. export class SpotLight extends ShadowLight {
  44786. private _angle;
  44787. private _innerAngle;
  44788. private _cosHalfAngle;
  44789. private _lightAngleScale;
  44790. private _lightAngleOffset;
  44791. /**
  44792. * Gets the cone angle of the spot light in Radians.
  44793. */
  44794. /**
  44795. * Sets the cone angle of the spot light in Radians.
  44796. */
  44797. angle: number;
  44798. /**
  44799. * Only used in gltf falloff mode, this defines the angle where
  44800. * the directional falloff will start before cutting at angle which could be seen
  44801. * as outer angle.
  44802. */
  44803. /**
  44804. * Only used in gltf falloff mode, this defines the angle where
  44805. * the directional falloff will start before cutting at angle which could be seen
  44806. * as outer angle.
  44807. */
  44808. innerAngle: number;
  44809. private _shadowAngleScale;
  44810. /**
  44811. * Allows scaling the angle of the light for shadow generation only.
  44812. */
  44813. /**
  44814. * Allows scaling the angle of the light for shadow generation only.
  44815. */
  44816. shadowAngleScale: number;
  44817. /**
  44818. * The light decay speed with the distance from the emission spot.
  44819. */
  44820. exponent: number;
  44821. private _projectionTextureMatrix;
  44822. /**
  44823. * Allows reading the projecton texture
  44824. */
  44825. readonly projectionTextureMatrix: Matrix;
  44826. protected _projectionTextureLightNear: number;
  44827. /**
  44828. * Gets the near clip of the Spotlight for texture projection.
  44829. */
  44830. /**
  44831. * Sets the near clip of the Spotlight for texture projection.
  44832. */
  44833. projectionTextureLightNear: number;
  44834. protected _projectionTextureLightFar: number;
  44835. /**
  44836. * Gets the far clip of the Spotlight for texture projection.
  44837. */
  44838. /**
  44839. * Sets the far clip of the Spotlight for texture projection.
  44840. */
  44841. projectionTextureLightFar: number;
  44842. protected _projectionTextureUpDirection: Vector3;
  44843. /**
  44844. * Gets the Up vector of the Spotlight for texture projection.
  44845. */
  44846. /**
  44847. * Sets the Up vector of the Spotlight for texture projection.
  44848. */
  44849. projectionTextureUpDirection: Vector3;
  44850. private _projectionTexture;
  44851. /**
  44852. * Gets the projection texture of the light.
  44853. */
  44854. /**
  44855. * Sets the projection texture of the light.
  44856. */
  44857. projectionTexture: Nullable<BaseTexture>;
  44858. private _projectionTextureViewLightDirty;
  44859. private _projectionTextureProjectionLightDirty;
  44860. private _projectionTextureDirty;
  44861. private _projectionTextureViewTargetVector;
  44862. private _projectionTextureViewLightMatrix;
  44863. private _projectionTextureProjectionLightMatrix;
  44864. private _projectionTextureScalingMatrix;
  44865. /**
  44866. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44867. * It can cast shadows.
  44868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44869. * @param name The light friendly name
  44870. * @param position The position of the spot light in the scene
  44871. * @param direction The direction of the light in the scene
  44872. * @param angle The cone angle of the light in Radians
  44873. * @param exponent The light decay speed with the distance from the emission spot
  44874. * @param scene The scene the lights belongs to
  44875. */
  44876. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44877. /**
  44878. * Returns the string "SpotLight".
  44879. * @returns the class name
  44880. */
  44881. getClassName(): string;
  44882. /**
  44883. * Returns the integer 2.
  44884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44885. */
  44886. getTypeID(): number;
  44887. /**
  44888. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44889. */
  44890. protected _setDirection(value: Vector3): void;
  44891. /**
  44892. * Overrides the position setter to recompute the projection texture view light Matrix.
  44893. */
  44894. protected _setPosition(value: Vector3): void;
  44895. /**
  44896. * 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.
  44897. * Returns the SpotLight.
  44898. */
  44899. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44900. protected _computeProjectionTextureViewLightMatrix(): void;
  44901. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44902. /**
  44903. * Main function for light texture projection matrix computing.
  44904. */
  44905. protected _computeProjectionTextureMatrix(): void;
  44906. protected _buildUniformLayout(): void;
  44907. private _computeAngleValues;
  44908. /**
  44909. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44910. * @param effect The effect to update
  44911. * @param lightIndex The index of the light in the effect to update
  44912. * @returns The spot light
  44913. */
  44914. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44915. /**
  44916. * Disposes the light and the associated resources.
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * Prepares the list of defines specific to the light type.
  44921. * @param defines the list of defines
  44922. * @param lightIndex defines the index of the light for the effect
  44923. */
  44924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44925. }
  44926. }
  44927. declare module "babylonjs/Gizmos/lightGizmo" {
  44928. import { Nullable } from "babylonjs/types";
  44929. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44931. import { Light } from "babylonjs/Lights/light";
  44932. /**
  44933. * Gizmo that enables viewing a light
  44934. */
  44935. export class LightGizmo extends Gizmo {
  44936. private _lightMesh;
  44937. private _material;
  44938. private cachedPosition;
  44939. private cachedForward;
  44940. /**
  44941. * Creates a LightGizmo
  44942. * @param gizmoLayer The utility layer the gizmo will be added to
  44943. */
  44944. constructor(gizmoLayer?: UtilityLayerRenderer);
  44945. private _light;
  44946. /**
  44947. * The light that the gizmo is attached to
  44948. */
  44949. light: Nullable<Light>;
  44950. /**
  44951. * @hidden
  44952. * Updates the gizmo to match the attached mesh's position/rotation
  44953. */
  44954. protected _update(): void;
  44955. private static _Scale;
  44956. /**
  44957. * Creates the lines for a light mesh
  44958. */
  44959. private static _createLightLines;
  44960. private static _CreateHemisphericLightMesh;
  44961. private static _CreatePointLightMesh;
  44962. private static _CreateSpotLightMesh;
  44963. private static _CreateDirectionalLightMesh;
  44964. }
  44965. }
  44966. declare module "babylonjs/Gizmos/index" {
  44967. export * from "babylonjs/Gizmos/axisDragGizmo";
  44968. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44969. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44970. export * from "babylonjs/Gizmos/gizmo";
  44971. export * from "babylonjs/Gizmos/gizmoManager";
  44972. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44973. export * from "babylonjs/Gizmos/positionGizmo";
  44974. export * from "babylonjs/Gizmos/rotationGizmo";
  44975. export * from "babylonjs/Gizmos/scaleGizmo";
  44976. export * from "babylonjs/Gizmos/lightGizmo";
  44977. }
  44978. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44979. /** @hidden */
  44980. export var backgroundFragmentDeclaration: {
  44981. name: string;
  44982. shader: string;
  44983. };
  44984. }
  44985. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44986. /** @hidden */
  44987. export var backgroundUboDeclaration: {
  44988. name: string;
  44989. shader: string;
  44990. };
  44991. }
  44992. declare module "babylonjs/Shaders/background.fragment" {
  44993. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44996. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44997. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44998. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44999. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45000. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45001. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45002. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45003. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45004. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45005. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45006. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45007. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45008. /** @hidden */
  45009. export var backgroundPixelShader: {
  45010. name: string;
  45011. shader: string;
  45012. };
  45013. }
  45014. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45015. /** @hidden */
  45016. export var backgroundVertexDeclaration: {
  45017. name: string;
  45018. shader: string;
  45019. };
  45020. }
  45021. declare module "babylonjs/Shaders/background.vertex" {
  45022. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45025. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45032. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45033. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45034. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45035. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45036. /** @hidden */
  45037. export var backgroundVertexShader: {
  45038. name: string;
  45039. shader: string;
  45040. };
  45041. }
  45042. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45043. import { Nullable, int, float } from "babylonjs/types";
  45044. import { Scene } from "babylonjs/scene";
  45045. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45048. import { Mesh } from "babylonjs/Meshes/mesh";
  45049. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45051. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45053. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45054. import "babylonjs/Shaders/background.fragment";
  45055. import "babylonjs/Shaders/background.vertex";
  45056. /**
  45057. * Background material used to create an efficient environement around your scene.
  45058. */
  45059. export class BackgroundMaterial extends PushMaterial {
  45060. /**
  45061. * Standard reflectance value at parallel view angle.
  45062. */
  45063. static StandardReflectance0: number;
  45064. /**
  45065. * Standard reflectance value at grazing angle.
  45066. */
  45067. static StandardReflectance90: number;
  45068. protected _primaryColor: Color3;
  45069. /**
  45070. * Key light Color (multiply against the environement texture)
  45071. */
  45072. primaryColor: Color3;
  45073. protected __perceptualColor: Nullable<Color3>;
  45074. /**
  45075. * Experimental Internal Use Only.
  45076. *
  45077. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45078. * This acts as a helper to set the primary color to a more "human friendly" value.
  45079. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45080. * output color as close as possible from the chosen value.
  45081. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45082. * part of lighting setup.)
  45083. */
  45084. _perceptualColor: Nullable<Color3>;
  45085. protected _primaryColorShadowLevel: float;
  45086. /**
  45087. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45088. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45089. */
  45090. primaryColorShadowLevel: float;
  45091. protected _primaryColorHighlightLevel: float;
  45092. /**
  45093. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45094. * The primary color is used at the level chosen to define what the white area would look.
  45095. */
  45096. primaryColorHighlightLevel: float;
  45097. protected _reflectionTexture: Nullable<BaseTexture>;
  45098. /**
  45099. * Reflection Texture used in the material.
  45100. * Should be author in a specific way for the best result (refer to the documentation).
  45101. */
  45102. reflectionTexture: Nullable<BaseTexture>;
  45103. protected _reflectionBlur: float;
  45104. /**
  45105. * Reflection Texture level of blur.
  45106. *
  45107. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45108. * texture twice.
  45109. */
  45110. reflectionBlur: float;
  45111. protected _diffuseTexture: Nullable<BaseTexture>;
  45112. /**
  45113. * Diffuse Texture used in the material.
  45114. * Should be author in a specific way for the best result (refer to the documentation).
  45115. */
  45116. diffuseTexture: Nullable<BaseTexture>;
  45117. protected _shadowLights: Nullable<IShadowLight[]>;
  45118. /**
  45119. * Specify the list of lights casting shadow on the material.
  45120. * All scene shadow lights will be included if null.
  45121. */
  45122. shadowLights: Nullable<IShadowLight[]>;
  45123. protected _shadowLevel: float;
  45124. /**
  45125. * Helps adjusting the shadow to a softer level if required.
  45126. * 0 means black shadows and 1 means no shadows.
  45127. */
  45128. shadowLevel: float;
  45129. protected _sceneCenter: Vector3;
  45130. /**
  45131. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45132. * It is usually zero but might be interesting to modify according to your setup.
  45133. */
  45134. sceneCenter: Vector3;
  45135. protected _opacityFresnel: boolean;
  45136. /**
  45137. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45138. * This helps ensuring a nice transition when the camera goes under the ground.
  45139. */
  45140. opacityFresnel: boolean;
  45141. protected _reflectionFresnel: boolean;
  45142. /**
  45143. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45144. * This helps adding a mirror texture on the ground.
  45145. */
  45146. reflectionFresnel: boolean;
  45147. protected _reflectionFalloffDistance: number;
  45148. /**
  45149. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45150. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45151. */
  45152. reflectionFalloffDistance: number;
  45153. protected _reflectionAmount: number;
  45154. /**
  45155. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45156. */
  45157. reflectionAmount: number;
  45158. protected _reflectionReflectance0: number;
  45159. /**
  45160. * This specifies the weight of the reflection at grazing angle.
  45161. */
  45162. reflectionReflectance0: number;
  45163. protected _reflectionReflectance90: number;
  45164. /**
  45165. * This specifies the weight of the reflection at a perpendicular point of view.
  45166. */
  45167. reflectionReflectance90: number;
  45168. /**
  45169. * Sets the reflection reflectance fresnel values according to the default standard
  45170. * empirically know to work well :-)
  45171. */
  45172. reflectionStandardFresnelWeight: number;
  45173. protected _useRGBColor: boolean;
  45174. /**
  45175. * Helps to directly use the maps channels instead of their level.
  45176. */
  45177. useRGBColor: boolean;
  45178. protected _enableNoise: boolean;
  45179. /**
  45180. * This helps reducing the banding effect that could occur on the background.
  45181. */
  45182. enableNoise: boolean;
  45183. /**
  45184. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45185. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45186. * Recommended to be keep at 1.0 except for special cases.
  45187. */
  45188. fovMultiplier: number;
  45189. private _fovMultiplier;
  45190. /**
  45191. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45192. */
  45193. useEquirectangularFOV: boolean;
  45194. private _maxSimultaneousLights;
  45195. /**
  45196. * Number of Simultaneous lights allowed on the material.
  45197. */
  45198. maxSimultaneousLights: int;
  45199. /**
  45200. * Default configuration related to image processing available in the Background Material.
  45201. */
  45202. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45203. /**
  45204. * Keep track of the image processing observer to allow dispose and replace.
  45205. */
  45206. private _imageProcessingObserver;
  45207. /**
  45208. * Attaches a new image processing configuration to the PBR Material.
  45209. * @param configuration (if null the scene configuration will be use)
  45210. */
  45211. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45212. /**
  45213. * Gets the image processing configuration used either in this material.
  45214. */
  45215. /**
  45216. * Sets the Default image processing configuration used either in the this material.
  45217. *
  45218. * If sets to null, the scene one is in use.
  45219. */
  45220. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45221. /**
  45222. * Gets wether the color curves effect is enabled.
  45223. */
  45224. /**
  45225. * Sets wether the color curves effect is enabled.
  45226. */
  45227. cameraColorCurvesEnabled: boolean;
  45228. /**
  45229. * Gets wether the color grading effect is enabled.
  45230. */
  45231. /**
  45232. * Gets wether the color grading effect is enabled.
  45233. */
  45234. cameraColorGradingEnabled: boolean;
  45235. /**
  45236. * Gets wether tonemapping is enabled or not.
  45237. */
  45238. /**
  45239. * Sets wether tonemapping is enabled or not
  45240. */
  45241. cameraToneMappingEnabled: boolean;
  45242. /**
  45243. * The camera exposure used on this material.
  45244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45245. * This corresponds to a photographic exposure.
  45246. */
  45247. /**
  45248. * The camera exposure used on this material.
  45249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45250. * This corresponds to a photographic exposure.
  45251. */
  45252. cameraExposure: float;
  45253. /**
  45254. * Gets The camera contrast used on this material.
  45255. */
  45256. /**
  45257. * Sets The camera contrast used on this material.
  45258. */
  45259. cameraContrast: float;
  45260. /**
  45261. * Gets the Color Grading 2D Lookup Texture.
  45262. */
  45263. /**
  45264. * Sets the Color Grading 2D Lookup Texture.
  45265. */
  45266. cameraColorGradingTexture: Nullable<BaseTexture>;
  45267. /**
  45268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45270. * 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;
  45271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45272. */
  45273. /**
  45274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45276. * 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;
  45277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45278. */
  45279. cameraColorCurves: Nullable<ColorCurves>;
  45280. /**
  45281. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45282. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45283. */
  45284. switchToBGR: boolean;
  45285. private _renderTargets;
  45286. private _reflectionControls;
  45287. private _white;
  45288. private _primaryShadowColor;
  45289. private _primaryHighlightColor;
  45290. /**
  45291. * Instantiates a Background Material in the given scene
  45292. * @param name The friendly name of the material
  45293. * @param scene The scene to add the material to
  45294. */
  45295. constructor(name: string, scene: Scene);
  45296. /**
  45297. * Gets a boolean indicating that current material needs to register RTT
  45298. */
  45299. readonly hasRenderTargetTextures: boolean;
  45300. /**
  45301. * The entire material has been created in order to prevent overdraw.
  45302. * @returns false
  45303. */
  45304. needAlphaTesting(): boolean;
  45305. /**
  45306. * The entire material has been created in order to prevent overdraw.
  45307. * @returns true if blending is enable
  45308. */
  45309. needAlphaBlending(): boolean;
  45310. /**
  45311. * Checks wether the material is ready to be rendered for a given mesh.
  45312. * @param mesh The mesh to render
  45313. * @param subMesh The submesh to check against
  45314. * @param useInstances Specify wether or not the material is used with instances
  45315. * @returns true if all the dependencies are ready (Textures, Effects...)
  45316. */
  45317. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45318. /**
  45319. * Compute the primary color according to the chosen perceptual color.
  45320. */
  45321. private _computePrimaryColorFromPerceptualColor;
  45322. /**
  45323. * Compute the highlights and shadow colors according to their chosen levels.
  45324. */
  45325. private _computePrimaryColors;
  45326. /**
  45327. * Build the uniform buffer used in the material.
  45328. */
  45329. buildUniformLayout(): void;
  45330. /**
  45331. * Unbind the material.
  45332. */
  45333. unbind(): void;
  45334. /**
  45335. * Bind only the world matrix to the material.
  45336. * @param world The world matrix to bind.
  45337. */
  45338. bindOnlyWorldMatrix(world: Matrix): void;
  45339. /**
  45340. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45341. * @param world The world matrix to bind.
  45342. * @param subMesh The submesh to bind for.
  45343. */
  45344. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45345. /**
  45346. * Dispose the material.
  45347. * @param forceDisposeEffect Force disposal of the associated effect.
  45348. * @param forceDisposeTextures Force disposal of the associated textures.
  45349. */
  45350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45351. /**
  45352. * Clones the material.
  45353. * @param name The cloned name.
  45354. * @returns The cloned material.
  45355. */
  45356. clone(name: string): BackgroundMaterial;
  45357. /**
  45358. * Serializes the current material to its JSON representation.
  45359. * @returns The JSON representation.
  45360. */
  45361. serialize(): any;
  45362. /**
  45363. * Gets the class name of the material
  45364. * @returns "BackgroundMaterial"
  45365. */
  45366. getClassName(): string;
  45367. /**
  45368. * Parse a JSON input to create back a background material.
  45369. * @param source The JSON data to parse
  45370. * @param scene The scene to create the parsed material in
  45371. * @param rootUrl The root url of the assets the material depends upon
  45372. * @returns the instantiated BackgroundMaterial.
  45373. */
  45374. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45375. }
  45376. }
  45377. declare module "babylonjs/Helpers/environmentHelper" {
  45378. import { Observable } from "babylonjs/Misc/observable";
  45379. import { Nullable } from "babylonjs/types";
  45380. import { Scene } from "babylonjs/scene";
  45381. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45383. import { Mesh } from "babylonjs/Meshes/mesh";
  45384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45385. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45386. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45387. import "babylonjs/Meshes/Builders/planeBuilder";
  45388. import "babylonjs/Meshes/Builders/boxBuilder";
  45389. /**
  45390. * Represents the different options available during the creation of
  45391. * a Environment helper.
  45392. *
  45393. * This can control the default ground, skybox and image processing setup of your scene.
  45394. */
  45395. export interface IEnvironmentHelperOptions {
  45396. /**
  45397. * Specifies wether or not to create a ground.
  45398. * True by default.
  45399. */
  45400. createGround: boolean;
  45401. /**
  45402. * Specifies the ground size.
  45403. * 15 by default.
  45404. */
  45405. groundSize: number;
  45406. /**
  45407. * The texture used on the ground for the main color.
  45408. * Comes from the BabylonJS CDN by default.
  45409. *
  45410. * Remarks: Can be either a texture or a url.
  45411. */
  45412. groundTexture: string | BaseTexture;
  45413. /**
  45414. * The color mixed in the ground texture by default.
  45415. * BabylonJS clearColor by default.
  45416. */
  45417. groundColor: Color3;
  45418. /**
  45419. * Specifies the ground opacity.
  45420. * 1 by default.
  45421. */
  45422. groundOpacity: number;
  45423. /**
  45424. * Enables the ground to receive shadows.
  45425. * True by default.
  45426. */
  45427. enableGroundShadow: boolean;
  45428. /**
  45429. * Helps preventing the shadow to be fully black on the ground.
  45430. * 0.5 by default.
  45431. */
  45432. groundShadowLevel: number;
  45433. /**
  45434. * Creates a mirror texture attach to the ground.
  45435. * false by default.
  45436. */
  45437. enableGroundMirror: boolean;
  45438. /**
  45439. * Specifies the ground mirror size ratio.
  45440. * 0.3 by default as the default kernel is 64.
  45441. */
  45442. groundMirrorSizeRatio: number;
  45443. /**
  45444. * Specifies the ground mirror blur kernel size.
  45445. * 64 by default.
  45446. */
  45447. groundMirrorBlurKernel: number;
  45448. /**
  45449. * Specifies the ground mirror visibility amount.
  45450. * 1 by default
  45451. */
  45452. groundMirrorAmount: number;
  45453. /**
  45454. * Specifies the ground mirror reflectance weight.
  45455. * This uses the standard weight of the background material to setup the fresnel effect
  45456. * of the mirror.
  45457. * 1 by default.
  45458. */
  45459. groundMirrorFresnelWeight: number;
  45460. /**
  45461. * Specifies the ground mirror Falloff distance.
  45462. * This can helps reducing the size of the reflection.
  45463. * 0 by Default.
  45464. */
  45465. groundMirrorFallOffDistance: number;
  45466. /**
  45467. * Specifies the ground mirror texture type.
  45468. * Unsigned Int by Default.
  45469. */
  45470. groundMirrorTextureType: number;
  45471. /**
  45472. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45473. * the shown objects.
  45474. */
  45475. groundYBias: number;
  45476. /**
  45477. * Specifies wether or not to create a skybox.
  45478. * True by default.
  45479. */
  45480. createSkybox: boolean;
  45481. /**
  45482. * Specifies the skybox size.
  45483. * 20 by default.
  45484. */
  45485. skyboxSize: number;
  45486. /**
  45487. * The texture used on the skybox for the main color.
  45488. * Comes from the BabylonJS CDN by default.
  45489. *
  45490. * Remarks: Can be either a texture or a url.
  45491. */
  45492. skyboxTexture: string | BaseTexture;
  45493. /**
  45494. * The color mixed in the skybox texture by default.
  45495. * BabylonJS clearColor by default.
  45496. */
  45497. skyboxColor: Color3;
  45498. /**
  45499. * The background rotation around the Y axis of the scene.
  45500. * This helps aligning the key lights of your scene with the background.
  45501. * 0 by default.
  45502. */
  45503. backgroundYRotation: number;
  45504. /**
  45505. * Compute automatically the size of the elements to best fit with the scene.
  45506. */
  45507. sizeAuto: boolean;
  45508. /**
  45509. * Default position of the rootMesh if autoSize is not true.
  45510. */
  45511. rootPosition: Vector3;
  45512. /**
  45513. * Sets up the image processing in the scene.
  45514. * true by default.
  45515. */
  45516. setupImageProcessing: boolean;
  45517. /**
  45518. * The texture used as your environment texture in the scene.
  45519. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45520. *
  45521. * Remarks: Can be either a texture or a url.
  45522. */
  45523. environmentTexture: string | BaseTexture;
  45524. /**
  45525. * The value of the exposure to apply to the scene.
  45526. * 0.6 by default if setupImageProcessing is true.
  45527. */
  45528. cameraExposure: number;
  45529. /**
  45530. * The value of the contrast to apply to the scene.
  45531. * 1.6 by default if setupImageProcessing is true.
  45532. */
  45533. cameraContrast: number;
  45534. /**
  45535. * Specifies wether or not tonemapping should be enabled in the scene.
  45536. * true by default if setupImageProcessing is true.
  45537. */
  45538. toneMappingEnabled: boolean;
  45539. }
  45540. /**
  45541. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45542. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45543. * It also helps with the default setup of your imageProcessing configuration.
  45544. */
  45545. export class EnvironmentHelper {
  45546. /**
  45547. * Default ground texture URL.
  45548. */
  45549. private static _groundTextureCDNUrl;
  45550. /**
  45551. * Default skybox texture URL.
  45552. */
  45553. private static _skyboxTextureCDNUrl;
  45554. /**
  45555. * Default environment texture URL.
  45556. */
  45557. private static _environmentTextureCDNUrl;
  45558. /**
  45559. * Creates the default options for the helper.
  45560. */
  45561. private static _getDefaultOptions;
  45562. private _rootMesh;
  45563. /**
  45564. * Gets the root mesh created by the helper.
  45565. */
  45566. readonly rootMesh: Mesh;
  45567. private _skybox;
  45568. /**
  45569. * Gets the skybox created by the helper.
  45570. */
  45571. readonly skybox: Nullable<Mesh>;
  45572. private _skyboxTexture;
  45573. /**
  45574. * Gets the skybox texture created by the helper.
  45575. */
  45576. readonly skyboxTexture: Nullable<BaseTexture>;
  45577. private _skyboxMaterial;
  45578. /**
  45579. * Gets the skybox material created by the helper.
  45580. */
  45581. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45582. private _ground;
  45583. /**
  45584. * Gets the ground mesh created by the helper.
  45585. */
  45586. readonly ground: Nullable<Mesh>;
  45587. private _groundTexture;
  45588. /**
  45589. * Gets the ground texture created by the helper.
  45590. */
  45591. readonly groundTexture: Nullable<BaseTexture>;
  45592. private _groundMirror;
  45593. /**
  45594. * Gets the ground mirror created by the helper.
  45595. */
  45596. readonly groundMirror: Nullable<MirrorTexture>;
  45597. /**
  45598. * Gets the ground mirror render list to helps pushing the meshes
  45599. * you wish in the ground reflection.
  45600. */
  45601. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45602. private _groundMaterial;
  45603. /**
  45604. * Gets the ground material created by the helper.
  45605. */
  45606. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45607. /**
  45608. * Stores the creation options.
  45609. */
  45610. private readonly _scene;
  45611. private _options;
  45612. /**
  45613. * This observable will be notified with any error during the creation of the environment,
  45614. * mainly texture creation errors.
  45615. */
  45616. onErrorObservable: Observable<{
  45617. message?: string;
  45618. exception?: any;
  45619. }>;
  45620. /**
  45621. * constructor
  45622. * @param options Defines the options we want to customize the helper
  45623. * @param scene The scene to add the material to
  45624. */
  45625. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45626. /**
  45627. * Updates the background according to the new options
  45628. * @param options
  45629. */
  45630. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45631. /**
  45632. * Sets the primary color of all the available elements.
  45633. * @param color the main color to affect to the ground and the background
  45634. */
  45635. setMainColor(color: Color3): void;
  45636. /**
  45637. * Setup the image processing according to the specified options.
  45638. */
  45639. private _setupImageProcessing;
  45640. /**
  45641. * Setup the environment texture according to the specified options.
  45642. */
  45643. private _setupEnvironmentTexture;
  45644. /**
  45645. * Setup the background according to the specified options.
  45646. */
  45647. private _setupBackground;
  45648. /**
  45649. * Get the scene sizes according to the setup.
  45650. */
  45651. private _getSceneSize;
  45652. /**
  45653. * Setup the ground according to the specified options.
  45654. */
  45655. private _setupGround;
  45656. /**
  45657. * Setup the ground material according to the specified options.
  45658. */
  45659. private _setupGroundMaterial;
  45660. /**
  45661. * Setup the ground diffuse texture according to the specified options.
  45662. */
  45663. private _setupGroundDiffuseTexture;
  45664. /**
  45665. * Setup the ground mirror texture according to the specified options.
  45666. */
  45667. private _setupGroundMirrorTexture;
  45668. /**
  45669. * Setup the ground to receive the mirror texture.
  45670. */
  45671. private _setupMirrorInGroundMaterial;
  45672. /**
  45673. * Setup the skybox according to the specified options.
  45674. */
  45675. private _setupSkybox;
  45676. /**
  45677. * Setup the skybox material according to the specified options.
  45678. */
  45679. private _setupSkyboxMaterial;
  45680. /**
  45681. * Setup the skybox reflection texture according to the specified options.
  45682. */
  45683. private _setupSkyboxReflectionTexture;
  45684. private _errorHandler;
  45685. /**
  45686. * Dispose all the elements created by the Helper.
  45687. */
  45688. dispose(): void;
  45689. }
  45690. }
  45691. declare module "babylonjs/Helpers/photoDome" {
  45692. import { Observable } from "babylonjs/Misc/observable";
  45693. import { Nullable } from "babylonjs/types";
  45694. import { Scene } from "babylonjs/scene";
  45695. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45696. import { Mesh } from "babylonjs/Meshes/mesh";
  45697. import { Texture } from "babylonjs/Materials/Textures/texture";
  45698. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45699. import "babylonjs/Meshes/Builders/sphereBuilder";
  45700. /**
  45701. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45702. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45703. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45704. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45705. */
  45706. export class PhotoDome extends TransformNode {
  45707. private _useDirectMapping;
  45708. /**
  45709. * The texture being displayed on the sphere
  45710. */
  45711. protected _photoTexture: Texture;
  45712. /**
  45713. * Gets or sets the texture being displayed on the sphere
  45714. */
  45715. photoTexture: Texture;
  45716. /**
  45717. * Observable raised when an error occured while loading the 360 image
  45718. */
  45719. onLoadErrorObservable: Observable<string>;
  45720. /**
  45721. * The skybox material
  45722. */
  45723. protected _material: BackgroundMaterial;
  45724. /**
  45725. * The surface used for the skybox
  45726. */
  45727. protected _mesh: Mesh;
  45728. /**
  45729. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45730. * Also see the options.resolution property.
  45731. */
  45732. fovMultiplier: number;
  45733. /**
  45734. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45735. * @param name Element's name, child elements will append suffixes for their own names.
  45736. * @param urlsOfPhoto defines the url of the photo to display
  45737. * @param options defines an object containing optional or exposed sub element properties
  45738. * @param onError defines a callback called when an error occured while loading the texture
  45739. */
  45740. constructor(name: string, urlOfPhoto: string, options: {
  45741. resolution?: number;
  45742. size?: number;
  45743. useDirectMapping?: boolean;
  45744. faceForward?: boolean;
  45745. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45746. /**
  45747. * Releases resources associated with this node.
  45748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45750. */
  45751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45752. }
  45753. }
  45754. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45755. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45756. /** @hidden */
  45757. export var rgbdDecodePixelShader: {
  45758. name: string;
  45759. shader: string;
  45760. };
  45761. }
  45762. declare module "babylonjs/Misc/brdfTextureTools" {
  45763. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45764. import { Scene } from "babylonjs/scene";
  45765. import "babylonjs/Shaders/rgbdDecode.fragment";
  45766. /**
  45767. * Class used to host texture specific utilities
  45768. */
  45769. export class BRDFTextureTools {
  45770. /**
  45771. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45772. * @param texture the texture to expand.
  45773. */
  45774. private static _ExpandDefaultBRDFTexture;
  45775. /**
  45776. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45777. * @param scene defines the hosting scene
  45778. * @returns the environment BRDF texture
  45779. */
  45780. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45781. private static _environmentBRDFBase64Texture;
  45782. }
  45783. }
  45784. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45785. import { Nullable } from "babylonjs/types";
  45786. import { IAnimatable } from "babylonjs/Misc/tools";
  45787. import { Color3 } from "babylonjs/Maths/math";
  45788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45789. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45790. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45791. import { Engine } from "babylonjs/Engines/engine";
  45792. import { Scene } from "babylonjs/scene";
  45793. /**
  45794. * @hidden
  45795. */
  45796. export interface IMaterialClearCoatDefines {
  45797. CLEARCOAT: boolean;
  45798. CLEARCOAT_DEFAULTIOR: boolean;
  45799. CLEARCOAT_TEXTURE: boolean;
  45800. CLEARCOAT_TEXTUREDIRECTUV: number;
  45801. CLEARCOAT_BUMP: boolean;
  45802. CLEARCOAT_BUMPDIRECTUV: number;
  45803. CLEARCOAT_TINT: boolean;
  45804. CLEARCOAT_TINT_TEXTURE: boolean;
  45805. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45806. /** @hidden */
  45807. _areTexturesDirty: boolean;
  45808. }
  45809. /**
  45810. * Define the code related to the clear coat parameters of the pbr material.
  45811. */
  45812. export class PBRClearCoatConfiguration {
  45813. /**
  45814. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45815. * The default fits with a polyurethane material.
  45816. */
  45817. private static readonly _DefaultIndiceOfRefraction;
  45818. private _isEnabled;
  45819. /**
  45820. * Defines if the clear coat is enabled in the material.
  45821. */
  45822. isEnabled: boolean;
  45823. /**
  45824. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45825. */
  45826. intensity: number;
  45827. /**
  45828. * Defines the clear coat layer roughness.
  45829. */
  45830. roughness: number;
  45831. private _indiceOfRefraction;
  45832. /**
  45833. * Defines the indice of refraction of the clear coat.
  45834. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45835. * The default fits with a polyurethane material.
  45836. * Changing the default value is more performance intensive.
  45837. */
  45838. indiceOfRefraction: number;
  45839. private _texture;
  45840. /**
  45841. * Stores the clear coat values in a texture.
  45842. */
  45843. texture: Nullable<BaseTexture>;
  45844. private _bumpTexture;
  45845. /**
  45846. * Define the clear coat specific bump texture.
  45847. */
  45848. bumpTexture: Nullable<BaseTexture>;
  45849. private _isTintEnabled;
  45850. /**
  45851. * Defines if the clear coat tint is enabled in the material.
  45852. */
  45853. isTintEnabled: boolean;
  45854. /**
  45855. * Defines the clear coat tint of the material.
  45856. * This is only use if tint is enabled
  45857. */
  45858. tintColor: Color3;
  45859. /**
  45860. * Defines the distance at which the tint color should be found in the
  45861. * clear coat media.
  45862. * This is only use if tint is enabled
  45863. */
  45864. tintColorAtDistance: number;
  45865. /**
  45866. * Defines the clear coat layer thickness.
  45867. * This is only use if tint is enabled
  45868. */
  45869. tintThickness: number;
  45870. private _tintTexture;
  45871. /**
  45872. * Stores the clear tint values in a texture.
  45873. * rgb is tint
  45874. * a is a thickness factor
  45875. */
  45876. tintTexture: Nullable<BaseTexture>;
  45877. /** @hidden */
  45878. private _internalMarkAllSubMeshesAsTexturesDirty;
  45879. /** @hidden */
  45880. _markAllSubMeshesAsTexturesDirty(): void;
  45881. /**
  45882. * Instantiate a new istance of clear coat configuration.
  45883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45884. */
  45885. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45886. /**
  45887. * Gets wehter the submesh is ready to be used or not.
  45888. * @param defines the list of "defines" to update.
  45889. * @param scene defines the scene the material belongs to.
  45890. * @param engine defines the engine the material belongs to.
  45891. * @param disableBumpMap defines wether the material disables bump or not.
  45892. * @returns - boolean indicating that the submesh is ready or not.
  45893. */
  45894. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45895. /**
  45896. * Checks to see if a texture is used in the material.
  45897. * @param defines the list of "defines" to update.
  45898. * @param scene defines the scene to the material belongs to.
  45899. */
  45900. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45901. /**
  45902. * Binds the material data.
  45903. * @param uniformBuffer defines the Uniform buffer to fill in.
  45904. * @param scene defines the scene the material belongs to.
  45905. * @param engine defines the engine the material belongs to.
  45906. * @param disableBumpMap defines wether the material disables bump or not.
  45907. * @param isFrozen defines wether the material is frozen or not.
  45908. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45909. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45910. */
  45911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45912. /**
  45913. * Checks to see if a texture is used in the material.
  45914. * @param texture - Base texture to use.
  45915. * @returns - Boolean specifying if a texture is used in the material.
  45916. */
  45917. hasTexture(texture: BaseTexture): boolean;
  45918. /**
  45919. * Returns an array of the actively used textures.
  45920. * @param activeTextures Array of BaseTextures
  45921. */
  45922. getActiveTextures(activeTextures: BaseTexture[]): void;
  45923. /**
  45924. * Returns the animatable textures.
  45925. * @param animatables Array of animatable textures.
  45926. */
  45927. getAnimatables(animatables: IAnimatable[]): void;
  45928. /**
  45929. * Disposes the resources of the material.
  45930. * @param forceDisposeTextures - Forces the disposal of all textures.
  45931. */
  45932. dispose(forceDisposeTextures?: boolean): void;
  45933. /**
  45934. * Get the current class name of the texture useful for serialization or dynamic coding.
  45935. * @returns "PBRClearCoatConfiguration"
  45936. */
  45937. getClassName(): string;
  45938. /**
  45939. * Add fallbacks to the effect fallbacks list.
  45940. * @param defines defines the Base texture to use.
  45941. * @param fallbacks defines the current fallback list.
  45942. * @param currentRank defines the current fallback rank.
  45943. * @returns the new fallback rank.
  45944. */
  45945. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45946. /**
  45947. * Add the required uniforms to the current list.
  45948. * @param uniforms defines the current uniform list.
  45949. */
  45950. static AddUniforms(uniforms: string[]): void;
  45951. /**
  45952. * Add the required samplers to the current list.
  45953. * @param samplers defines the current sampler list.
  45954. */
  45955. static AddSamplers(samplers: string[]): void;
  45956. /**
  45957. * Add the required uniforms to the current buffer.
  45958. * @param uniformBuffer defines the current uniform buffer.
  45959. */
  45960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45961. /**
  45962. * Makes a duplicate of the current configuration into another one.
  45963. * @param clearCoatConfiguration define the config where to copy the info
  45964. */
  45965. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45966. /**
  45967. * Serializes this clear coat configuration.
  45968. * @returns - An object with the serialized config.
  45969. */
  45970. serialize(): any;
  45971. /**
  45972. * Parses a Clear Coat Configuration from a serialized object.
  45973. * @param source - Serialized object.
  45974. */
  45975. parse(source: any): void;
  45976. }
  45977. }
  45978. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45979. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45980. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45982. import { Vector2 } from "babylonjs/Maths/math";
  45983. import { Scene } from "babylonjs/scene";
  45984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45985. import { IAnimatable } from "babylonjs/Misc/tools";
  45986. import { Nullable } from "babylonjs/types";
  45987. /**
  45988. * @hidden
  45989. */
  45990. export interface IMaterialAnisotropicDefines {
  45991. ANISOTROPIC: boolean;
  45992. ANISOTROPIC_TEXTURE: boolean;
  45993. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45994. MAINUV1: boolean;
  45995. _areTexturesDirty: boolean;
  45996. _needUVs: boolean;
  45997. }
  45998. /**
  45999. * Define the code related to the anisotropic parameters of the pbr material.
  46000. */
  46001. export class PBRAnisotropicConfiguration {
  46002. private _isEnabled;
  46003. /**
  46004. * Defines if the anisotropy is enabled in the material.
  46005. */
  46006. isEnabled: boolean;
  46007. /**
  46008. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46009. */
  46010. intensity: number;
  46011. /**
  46012. * Defines if the effect is along the tangents, bitangents or in between.
  46013. * By default, the effect is "strectching" the highlights along the tangents.
  46014. */
  46015. direction: Vector2;
  46016. private _texture;
  46017. /**
  46018. * Stores the anisotropy values in a texture.
  46019. * rg is direction (like normal from -1 to 1)
  46020. * b is a intensity
  46021. */
  46022. texture: Nullable<BaseTexture>;
  46023. /** @hidden */
  46024. private _internalMarkAllSubMeshesAsTexturesDirty;
  46025. /** @hidden */
  46026. _markAllSubMeshesAsTexturesDirty(): void;
  46027. /**
  46028. * Instantiate a new istance of anisotropy configuration.
  46029. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46030. */
  46031. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46032. /**
  46033. * Specifies that the submesh is ready to be used.
  46034. * @param defines the list of "defines" to update.
  46035. * @param scene defines the scene the material belongs to.
  46036. * @returns - boolean indicating that the submesh is ready or not.
  46037. */
  46038. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46039. /**
  46040. * Checks to see if a texture is used in the material.
  46041. * @param defines the list of "defines" to update.
  46042. * @param mesh the mesh we are preparing the defines for.
  46043. * @param scene defines the scene the material belongs to.
  46044. */
  46045. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46046. /**
  46047. * Binds the material data.
  46048. * @param uniformBuffer defines the Uniform buffer to fill in.
  46049. * @param scene defines the scene the material belongs to.
  46050. * @param isFrozen defines wether the material is frozen or not.
  46051. */
  46052. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46053. /**
  46054. * Checks to see if a texture is used in the material.
  46055. * @param texture - Base texture to use.
  46056. * @returns - Boolean specifying if a texture is used in the material.
  46057. */
  46058. hasTexture(texture: BaseTexture): boolean;
  46059. /**
  46060. * Returns an array of the actively used textures.
  46061. * @param activeTextures Array of BaseTextures
  46062. */
  46063. getActiveTextures(activeTextures: BaseTexture[]): void;
  46064. /**
  46065. * Returns the animatable textures.
  46066. * @param animatables Array of animatable textures.
  46067. */
  46068. getAnimatables(animatables: IAnimatable[]): void;
  46069. /**
  46070. * Disposes the resources of the material.
  46071. * @param forceDisposeTextures - Forces the disposal of all textures.
  46072. */
  46073. dispose(forceDisposeTextures?: boolean): void;
  46074. /**
  46075. * Get the current class name of the texture useful for serialization or dynamic coding.
  46076. * @returns "PBRAnisotropicConfiguration"
  46077. */
  46078. getClassName(): string;
  46079. /**
  46080. * Add fallbacks to the effect fallbacks list.
  46081. * @param defines defines the Base texture to use.
  46082. * @param fallbacks defines the current fallback list.
  46083. * @param currentRank defines the current fallback rank.
  46084. * @returns the new fallback rank.
  46085. */
  46086. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46087. /**
  46088. * Add the required uniforms to the current list.
  46089. * @param uniforms defines the current uniform list.
  46090. */
  46091. static AddUniforms(uniforms: string[]): void;
  46092. /**
  46093. * Add the required uniforms to the current buffer.
  46094. * @param uniformBuffer defines the current uniform buffer.
  46095. */
  46096. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46097. /**
  46098. * Add the required samplers to the current list.
  46099. * @param samplers defines the current sampler list.
  46100. */
  46101. static AddSamplers(samplers: string[]): void;
  46102. /**
  46103. * Makes a duplicate of the current configuration into another one.
  46104. * @param anisotropicConfiguration define the config where to copy the info
  46105. */
  46106. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46107. /**
  46108. * Serializes this anisotropy configuration.
  46109. * @returns - An object with the serialized config.
  46110. */
  46111. serialize(): any;
  46112. /**
  46113. * Parses a anisotropy Configuration from a serialized object.
  46114. * @param source - Serialized object.
  46115. */
  46116. parse(source: any): void;
  46117. }
  46118. }
  46119. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46120. /**
  46121. * @hidden
  46122. */
  46123. export interface IMaterialBRDFDefines {
  46124. BRDF_V_HEIGHT_CORRELATED: boolean;
  46125. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46126. SPHERICAL_HARMONICS: boolean;
  46127. /** @hidden */
  46128. _areMiscDirty: boolean;
  46129. }
  46130. /**
  46131. * Define the code related to the BRDF parameters of the pbr material.
  46132. */
  46133. export class PBRBRDFConfiguration {
  46134. /**
  46135. * Default value used for the energy conservation.
  46136. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46137. */
  46138. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46139. /**
  46140. * Default value used for the Smith Visibility Height Correlated mode.
  46141. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46142. */
  46143. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46144. /**
  46145. * Default value used for the IBL diffuse part.
  46146. * This can help switching back to the polynomials mode globally which is a tiny bit
  46147. * less GPU intensive at the drawback of a lower quality.
  46148. */
  46149. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46150. private _useEnergyConservation;
  46151. /**
  46152. * Defines if the material uses energy conservation.
  46153. */
  46154. useEnergyConservation: boolean;
  46155. private _useSmithVisibilityHeightCorrelated;
  46156. /**
  46157. * LEGACY Mode set to false
  46158. * Defines if the material uses height smith correlated visibility term.
  46159. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46160. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46161. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46162. * Not relying on height correlated will also disable energy conservation.
  46163. */
  46164. useSmithVisibilityHeightCorrelated: boolean;
  46165. private _useSphericalHarmonics;
  46166. /**
  46167. * LEGACY Mode set to false
  46168. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46169. * diffuse part of the IBL.
  46170. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46171. * to the ground truth.
  46172. */
  46173. useSphericalHarmonics: boolean;
  46174. /** @hidden */
  46175. private _internalMarkAllSubMeshesAsMiscDirty;
  46176. /** @hidden */
  46177. _markAllSubMeshesAsMiscDirty(): void;
  46178. /**
  46179. * Instantiate a new istance of clear coat configuration.
  46180. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46181. */
  46182. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46183. /**
  46184. * Checks to see if a texture is used in the material.
  46185. * @param defines the list of "defines" to update.
  46186. */
  46187. prepareDefines(defines: IMaterialBRDFDefines): void;
  46188. /**
  46189. * Get the current class name of the texture useful for serialization or dynamic coding.
  46190. * @returns "PBRClearCoatConfiguration"
  46191. */
  46192. getClassName(): string;
  46193. /**
  46194. * Makes a duplicate of the current configuration into another one.
  46195. * @param brdfConfiguration define the config where to copy the info
  46196. */
  46197. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46198. /**
  46199. * Serializes this BRDF configuration.
  46200. * @returns - An object with the serialized config.
  46201. */
  46202. serialize(): any;
  46203. /**
  46204. * Parses a BRDF Configuration from a serialized object.
  46205. * @param source - Serialized object.
  46206. */
  46207. parse(source: any): void;
  46208. }
  46209. }
  46210. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46211. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46213. import { Color3 } from "babylonjs/Maths/math";
  46214. import { Scene } from "babylonjs/scene";
  46215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46216. import { IAnimatable } from "babylonjs/Misc/tools";
  46217. import { Nullable } from "babylonjs/types";
  46218. /**
  46219. * @hidden
  46220. */
  46221. export interface IMaterialSheenDefines {
  46222. SHEEN: boolean;
  46223. SHEEN_TEXTURE: boolean;
  46224. SHEEN_TEXTUREDIRECTUV: number;
  46225. SHEEN_LINKWITHALBEDO: boolean;
  46226. /** @hidden */
  46227. _areTexturesDirty: boolean;
  46228. }
  46229. /**
  46230. * Define the code related to the Sheen parameters of the pbr material.
  46231. */
  46232. export class PBRSheenConfiguration {
  46233. private _isEnabled;
  46234. /**
  46235. * Defines if the material uses sheen.
  46236. */
  46237. isEnabled: boolean;
  46238. private _linkSheenWithAlbedo;
  46239. /**
  46240. * Defines if the sheen is linked to the sheen color.
  46241. */
  46242. linkSheenWithAlbedo: boolean;
  46243. /**
  46244. * Defines the sheen intensity.
  46245. */
  46246. intensity: number;
  46247. /**
  46248. * Defines the sheen color.
  46249. */
  46250. color: Color3;
  46251. private _texture;
  46252. /**
  46253. * Stores the sheen tint values in a texture.
  46254. * rgb is tint
  46255. * a is a intensity
  46256. */
  46257. texture: Nullable<BaseTexture>;
  46258. /** @hidden */
  46259. private _internalMarkAllSubMeshesAsTexturesDirty;
  46260. /** @hidden */
  46261. _markAllSubMeshesAsTexturesDirty(): void;
  46262. /**
  46263. * Instantiate a new istance of clear coat configuration.
  46264. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46265. */
  46266. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46267. /**
  46268. * Specifies that the submesh is ready to be used.
  46269. * @param defines the list of "defines" to update.
  46270. * @param scene defines the scene the material belongs to.
  46271. * @returns - boolean indicating that the submesh is ready or not.
  46272. */
  46273. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46274. /**
  46275. * Checks to see if a texture is used in the material.
  46276. * @param defines the list of "defines" to update.
  46277. * @param scene defines the scene the material belongs to.
  46278. */
  46279. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46280. /**
  46281. * Binds the material data.
  46282. * @param uniformBuffer defines the Uniform buffer to fill in.
  46283. * @param scene defines the scene the material belongs to.
  46284. * @param isFrozen defines wether the material is frozen or not.
  46285. */
  46286. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46287. /**
  46288. * Checks to see if a texture is used in the material.
  46289. * @param texture - Base texture to use.
  46290. * @returns - Boolean specifying if a texture is used in the material.
  46291. */
  46292. hasTexture(texture: BaseTexture): boolean;
  46293. /**
  46294. * Returns an array of the actively used textures.
  46295. * @param activeTextures Array of BaseTextures
  46296. */
  46297. getActiveTextures(activeTextures: BaseTexture[]): void;
  46298. /**
  46299. * Returns the animatable textures.
  46300. * @param animatables Array of animatable textures.
  46301. */
  46302. getAnimatables(animatables: IAnimatable[]): void;
  46303. /**
  46304. * Disposes the resources of the material.
  46305. * @param forceDisposeTextures - Forces the disposal of all textures.
  46306. */
  46307. dispose(forceDisposeTextures?: boolean): void;
  46308. /**
  46309. * Get the current class name of the texture useful for serialization or dynamic coding.
  46310. * @returns "PBRSheenConfiguration"
  46311. */
  46312. getClassName(): string;
  46313. /**
  46314. * Add fallbacks to the effect fallbacks list.
  46315. * @param defines defines the Base texture to use.
  46316. * @param fallbacks defines the current fallback list.
  46317. * @param currentRank defines the current fallback rank.
  46318. * @returns the new fallback rank.
  46319. */
  46320. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46321. /**
  46322. * Add the required uniforms to the current list.
  46323. * @param uniforms defines the current uniform list.
  46324. */
  46325. static AddUniforms(uniforms: string[]): void;
  46326. /**
  46327. * Add the required uniforms to the current buffer.
  46328. * @param uniformBuffer defines the current uniform buffer.
  46329. */
  46330. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46331. /**
  46332. * Add the required samplers to the current list.
  46333. * @param samplers defines the current sampler list.
  46334. */
  46335. static AddSamplers(samplers: string[]): void;
  46336. /**
  46337. * Makes a duplicate of the current configuration into another one.
  46338. * @param sheenConfiguration define the config where to copy the info
  46339. */
  46340. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46341. /**
  46342. * Serializes this BRDF configuration.
  46343. * @returns - An object with the serialized config.
  46344. */
  46345. serialize(): any;
  46346. /**
  46347. * Parses a Sheen Configuration from a serialized object.
  46348. * @param source - Serialized object.
  46349. */
  46350. parse(source: any): void;
  46351. }
  46352. }
  46353. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46354. import { Nullable } from "babylonjs/types";
  46355. import { IAnimatable } from "babylonjs/Misc/tools";
  46356. import { Color3 } from "babylonjs/Maths/math";
  46357. import { SmartArray } from "babylonjs/Misc/smartArray";
  46358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46359. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46360. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46361. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46362. import { Engine } from "babylonjs/Engines/engine";
  46363. import { Scene } from "babylonjs/scene";
  46364. /**
  46365. * @hidden
  46366. */
  46367. export interface IMaterialSubSurfaceDefines {
  46368. SUBSURFACE: boolean;
  46369. SS_REFRACTION: boolean;
  46370. SS_TRANSLUCENCY: boolean;
  46371. SS_SCATERRING: boolean;
  46372. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46373. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46374. SS_REFRACTIONMAP_3D: boolean;
  46375. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46376. SS_LODINREFRACTIONALPHA: boolean;
  46377. SS_GAMMAREFRACTION: boolean;
  46378. SS_RGBDREFRACTION: boolean;
  46379. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46380. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46381. /** @hidden */
  46382. _areTexturesDirty: boolean;
  46383. }
  46384. /**
  46385. * Define the code related to the sub surface parameters of the pbr material.
  46386. */
  46387. export class PBRSubSurfaceConfiguration {
  46388. private _isRefractionEnabled;
  46389. /**
  46390. * Defines if the refraction is enabled in the material.
  46391. */
  46392. isRefractionEnabled: boolean;
  46393. private _isTranslucencyEnabled;
  46394. /**
  46395. * Defines if the translucency is enabled in the material.
  46396. */
  46397. isTranslucencyEnabled: boolean;
  46398. private _isScatteringEnabled;
  46399. /**
  46400. * Defines the refraction intensity of the material.
  46401. * The refraction when enabled replaces the Diffuse part of the material.
  46402. * The intensity helps transitionning between diffuse and refraction.
  46403. */
  46404. refractionIntensity: number;
  46405. /**
  46406. * Defines the translucency intensity of the material.
  46407. * When translucency has been enabled, this defines how much of the "translucency"
  46408. * is addded to the diffuse part of the material.
  46409. */
  46410. translucencyIntensity: number;
  46411. /**
  46412. * Defines the scattering intensity of the material.
  46413. * When scattering has been enabled, this defines how much of the "scattered light"
  46414. * is addded to the diffuse part of the material.
  46415. */
  46416. scatteringIntensity: number;
  46417. private _thicknessTexture;
  46418. /**
  46419. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46420. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46421. * 0 would mean minimumThickness
  46422. * 1 would mean maximumThickness
  46423. * The other channels might be use as a mask to vary the different effects intensity.
  46424. */
  46425. thicknessTexture: Nullable<BaseTexture>;
  46426. private _refractionTexture;
  46427. /**
  46428. * Defines the texture to use for refraction.
  46429. */
  46430. refractionTexture: Nullable<BaseTexture>;
  46431. private _indexOfRefraction;
  46432. /**
  46433. * Defines the indice of refraction used in the material.
  46434. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46435. */
  46436. indexOfRefraction: number;
  46437. private _invertRefractionY;
  46438. /**
  46439. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46440. */
  46441. invertRefractionY: boolean;
  46442. private _linkRefractionWithTransparency;
  46443. /**
  46444. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46445. * Materials half opaque for instance using refraction could benefit from this control.
  46446. */
  46447. linkRefractionWithTransparency: boolean;
  46448. /**
  46449. * Defines the minimum thickness stored in the thickness map.
  46450. * If no thickness map is defined, this value will be used to simulate thickness.
  46451. */
  46452. minimumThickness: number;
  46453. /**
  46454. * Defines the maximum thickness stored in the thickness map.
  46455. */
  46456. maximumThickness: number;
  46457. /**
  46458. * Defines the volume tint of the material.
  46459. * This is used for both translucency and scattering.
  46460. */
  46461. tintColor: Color3;
  46462. /**
  46463. * Defines the distance at which the tint color should be found in the media.
  46464. * This is used for refraction only.
  46465. */
  46466. tintColorAtDistance: number;
  46467. /**
  46468. * Defines how far each channel transmit through the media.
  46469. * It is defined as a color to simplify it selection.
  46470. */
  46471. diffusionDistance: Color3;
  46472. private _useMaskFromThicknessTexture;
  46473. /**
  46474. * Stores the intensity of the different subsurface effects in the thickness texture.
  46475. * * the green channel is the translucency intensity.
  46476. * * the blue channel is the scattering intensity.
  46477. * * the alpha channel is the refraction intensity.
  46478. */
  46479. useMaskFromThicknessTexture: boolean;
  46480. /** @hidden */
  46481. private _internalMarkAllSubMeshesAsTexturesDirty;
  46482. /** @hidden */
  46483. _markAllSubMeshesAsTexturesDirty(): void;
  46484. /**
  46485. * Instantiate a new istance of sub surface configuration.
  46486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46487. */
  46488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46489. /**
  46490. * Gets wehter the submesh is ready to be used or not.
  46491. * @param defines the list of "defines" to update.
  46492. * @param scene defines the scene the material belongs to.
  46493. * @returns - boolean indicating that the submesh is ready or not.
  46494. */
  46495. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46496. /**
  46497. * Checks to see if a texture is used in the material.
  46498. * @param defines the list of "defines" to update.
  46499. * @param scene defines the scene to the material belongs to.
  46500. */
  46501. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46502. /**
  46503. * Binds the material data.
  46504. * @param uniformBuffer defines the Uniform buffer to fill in.
  46505. * @param scene defines the scene the material belongs to.
  46506. * @param engine defines the engine the material belongs to.
  46507. * @param isFrozen defines wether the material is frozen or not.
  46508. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46509. */
  46510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46511. /**
  46512. * Unbinds the material from the mesh.
  46513. * @param activeEffect defines the effect that should be unbound from.
  46514. * @returns true if unbound, otherwise false
  46515. */
  46516. unbind(activeEffect: Effect): boolean;
  46517. /**
  46518. * Returns the texture used for refraction or null if none is used.
  46519. * @param scene defines the scene the material belongs to.
  46520. * @returns - Refraction texture if present. If no refraction texture and refraction
  46521. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46522. */
  46523. private _getRefractionTexture;
  46524. /**
  46525. * Returns true if alpha blending should be disabled.
  46526. */
  46527. readonly disableAlphaBlending: boolean;
  46528. /**
  46529. * Fills the list of render target textures.
  46530. * @param renderTargets the list of render targets to update
  46531. */
  46532. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46533. /**
  46534. * Checks to see if a texture is used in the material.
  46535. * @param texture - Base texture to use.
  46536. * @returns - Boolean specifying if a texture is used in the material.
  46537. */
  46538. hasTexture(texture: BaseTexture): boolean;
  46539. /**
  46540. * Gets a boolean indicating that current material needs to register RTT
  46541. * @returns true if this uses a render target otherwise false.
  46542. */
  46543. hasRenderTargetTextures(): boolean;
  46544. /**
  46545. * Returns an array of the actively used textures.
  46546. * @param activeTextures Array of BaseTextures
  46547. */
  46548. getActiveTextures(activeTextures: BaseTexture[]): void;
  46549. /**
  46550. * Returns the animatable textures.
  46551. * @param animatables Array of animatable textures.
  46552. */
  46553. getAnimatables(animatables: IAnimatable[]): void;
  46554. /**
  46555. * Disposes the resources of the material.
  46556. * @param forceDisposeTextures - Forces the disposal of all textures.
  46557. */
  46558. dispose(forceDisposeTextures?: boolean): void;
  46559. /**
  46560. * Get the current class name of the texture useful for serialization or dynamic coding.
  46561. * @returns "PBRSubSurfaceConfiguration"
  46562. */
  46563. getClassName(): string;
  46564. /**
  46565. * Add fallbacks to the effect fallbacks list.
  46566. * @param defines defines the Base texture to use.
  46567. * @param fallbacks defines the current fallback list.
  46568. * @param currentRank defines the current fallback rank.
  46569. * @returns the new fallback rank.
  46570. */
  46571. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46572. /**
  46573. * Add the required uniforms to the current list.
  46574. * @param uniforms defines the current uniform list.
  46575. */
  46576. static AddUniforms(uniforms: string[]): void;
  46577. /**
  46578. * Add the required samplers to the current list.
  46579. * @param samplers defines the current sampler list.
  46580. */
  46581. static AddSamplers(samplers: string[]): void;
  46582. /**
  46583. * Add the required uniforms to the current buffer.
  46584. * @param uniformBuffer defines the current uniform buffer.
  46585. */
  46586. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46587. /**
  46588. * Makes a duplicate of the current configuration into another one.
  46589. * @param configuration define the config where to copy the info
  46590. */
  46591. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46592. /**
  46593. * Serializes this Sub Surface configuration.
  46594. * @returns - An object with the serialized config.
  46595. */
  46596. serialize(): any;
  46597. /**
  46598. * Parses a Sub Surface Configuration from a serialized object.
  46599. * @param source - Serialized object.
  46600. */
  46601. parse(source: any): void;
  46602. }
  46603. }
  46604. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46605. /** @hidden */
  46606. export var pbrFragmentDeclaration: {
  46607. name: string;
  46608. shader: string;
  46609. };
  46610. }
  46611. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46612. /** @hidden */
  46613. export var pbrUboDeclaration: {
  46614. name: string;
  46615. shader: string;
  46616. };
  46617. }
  46618. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46619. /** @hidden */
  46620. export var pbrFragmentExtraDeclaration: {
  46621. name: string;
  46622. shader: string;
  46623. };
  46624. }
  46625. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46626. /** @hidden */
  46627. export var pbrFragmentSamplersDeclaration: {
  46628. name: string;
  46629. shader: string;
  46630. };
  46631. }
  46632. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46633. /** @hidden */
  46634. export var pbrHelperFunctions: {
  46635. name: string;
  46636. shader: string;
  46637. };
  46638. }
  46639. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46640. /** @hidden */
  46641. export var harmonicsFunctions: {
  46642. name: string;
  46643. shader: string;
  46644. };
  46645. }
  46646. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46647. /** @hidden */
  46648. export var pbrDirectLightingSetupFunctions: {
  46649. name: string;
  46650. shader: string;
  46651. };
  46652. }
  46653. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46654. /** @hidden */
  46655. export var pbrDirectLightingFalloffFunctions: {
  46656. name: string;
  46657. shader: string;
  46658. };
  46659. }
  46660. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46661. /** @hidden */
  46662. export var pbrBRDFFunctions: {
  46663. name: string;
  46664. shader: string;
  46665. };
  46666. }
  46667. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46668. /** @hidden */
  46669. export var pbrDirectLightingFunctions: {
  46670. name: string;
  46671. shader: string;
  46672. };
  46673. }
  46674. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46675. /** @hidden */
  46676. export var pbrIBLFunctions: {
  46677. name: string;
  46678. shader: string;
  46679. };
  46680. }
  46681. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46682. /** @hidden */
  46683. export var pbrDebug: {
  46684. name: string;
  46685. shader: string;
  46686. };
  46687. }
  46688. declare module "babylonjs/Shaders/pbr.fragment" {
  46689. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46690. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46696. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46697. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46698. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46699. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46700. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46701. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46702. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46703. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46707. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46708. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46709. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46710. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46711. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46712. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46713. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46714. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46715. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46716. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46717. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46718. /** @hidden */
  46719. export var pbrPixelShader: {
  46720. name: string;
  46721. shader: string;
  46722. };
  46723. }
  46724. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46725. /** @hidden */
  46726. export var pbrVertexDeclaration: {
  46727. name: string;
  46728. shader: string;
  46729. };
  46730. }
  46731. declare module "babylonjs/Shaders/pbr.vertex" {
  46732. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46733. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46734. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46735. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46736. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46738. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46742. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46743. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46745. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46747. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46748. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46749. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46750. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46751. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46752. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46753. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46754. /** @hidden */
  46755. export var pbrVertexShader: {
  46756. name: string;
  46757. shader: string;
  46758. };
  46759. }
  46760. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46761. import { IAnimatable } from "babylonjs/Misc/tools";
  46762. import { Nullable } from "babylonjs/types";
  46763. import { Scene } from "babylonjs/scene";
  46764. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46767. import { Mesh } from "babylonjs/Meshes/mesh";
  46768. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46769. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46770. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46771. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46772. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46773. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46774. import { Material } from "babylonjs/Materials/material";
  46775. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46776. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46778. import "babylonjs/Shaders/pbr.fragment";
  46779. import "babylonjs/Shaders/pbr.vertex";
  46780. /**
  46781. * Manages the defines for the PBR Material.
  46782. * @hidden
  46783. */
  46784. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46785. PBR: boolean;
  46786. MAINUV1: boolean;
  46787. MAINUV2: boolean;
  46788. UV1: boolean;
  46789. UV2: boolean;
  46790. ALBEDO: boolean;
  46791. ALBEDODIRECTUV: number;
  46792. VERTEXCOLOR: boolean;
  46793. AMBIENT: boolean;
  46794. AMBIENTDIRECTUV: number;
  46795. AMBIENTINGRAYSCALE: boolean;
  46796. OPACITY: boolean;
  46797. VERTEXALPHA: boolean;
  46798. OPACITYDIRECTUV: number;
  46799. OPACITYRGB: boolean;
  46800. ALPHATEST: boolean;
  46801. DEPTHPREPASS: boolean;
  46802. ALPHABLEND: boolean;
  46803. ALPHAFROMALBEDO: boolean;
  46804. ALPHATESTVALUE: string;
  46805. SPECULAROVERALPHA: boolean;
  46806. RADIANCEOVERALPHA: boolean;
  46807. ALPHAFRESNEL: boolean;
  46808. LINEARALPHAFRESNEL: boolean;
  46809. PREMULTIPLYALPHA: boolean;
  46810. EMISSIVE: boolean;
  46811. EMISSIVEDIRECTUV: number;
  46812. REFLECTIVITY: boolean;
  46813. REFLECTIVITYDIRECTUV: number;
  46814. SPECULARTERM: boolean;
  46815. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46816. MICROSURFACEAUTOMATIC: boolean;
  46817. LODBASEDMICROSFURACE: boolean;
  46818. MICROSURFACEMAP: boolean;
  46819. MICROSURFACEMAPDIRECTUV: number;
  46820. METALLICWORKFLOW: boolean;
  46821. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46822. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46823. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46824. AOSTOREINMETALMAPRED: boolean;
  46825. ENVIRONMENTBRDF: boolean;
  46826. ENVIRONMENTBRDF_RGBD: boolean;
  46827. NORMAL: boolean;
  46828. TANGENT: boolean;
  46829. BUMP: boolean;
  46830. BUMPDIRECTUV: number;
  46831. OBJECTSPACE_NORMALMAP: boolean;
  46832. PARALLAX: boolean;
  46833. PARALLAXOCCLUSION: boolean;
  46834. NORMALXYSCALE: boolean;
  46835. LIGHTMAP: boolean;
  46836. LIGHTMAPDIRECTUV: number;
  46837. USELIGHTMAPASSHADOWMAP: boolean;
  46838. GAMMALIGHTMAP: boolean;
  46839. REFLECTION: boolean;
  46840. REFLECTIONMAP_3D: boolean;
  46841. REFLECTIONMAP_SPHERICAL: boolean;
  46842. REFLECTIONMAP_PLANAR: boolean;
  46843. REFLECTIONMAP_CUBIC: boolean;
  46844. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46845. REFLECTIONMAP_PROJECTION: boolean;
  46846. REFLECTIONMAP_SKYBOX: boolean;
  46847. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46848. REFLECTIONMAP_EXPLICIT: boolean;
  46849. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46850. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46851. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46852. INVERTCUBICMAP: boolean;
  46853. USESPHERICALFROMREFLECTIONMAP: boolean;
  46854. SPHERICAL_HARMONICS: boolean;
  46855. USESPHERICALINVERTEX: boolean;
  46856. REFLECTIONMAP_OPPOSITEZ: boolean;
  46857. LODINREFLECTIONALPHA: boolean;
  46858. GAMMAREFLECTION: boolean;
  46859. RGBDREFLECTION: boolean;
  46860. RADIANCEOCCLUSION: boolean;
  46861. HORIZONOCCLUSION: boolean;
  46862. INSTANCES: boolean;
  46863. NUM_BONE_INFLUENCERS: number;
  46864. BonesPerMesh: number;
  46865. BONETEXTURE: boolean;
  46866. NONUNIFORMSCALING: boolean;
  46867. MORPHTARGETS: boolean;
  46868. MORPHTARGETS_NORMAL: boolean;
  46869. MORPHTARGETS_TANGENT: boolean;
  46870. NUM_MORPH_INFLUENCERS: number;
  46871. IMAGEPROCESSING: boolean;
  46872. VIGNETTE: boolean;
  46873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46874. VIGNETTEBLENDMODEOPAQUE: boolean;
  46875. TONEMAPPING: boolean;
  46876. TONEMAPPING_ACES: boolean;
  46877. CONTRAST: boolean;
  46878. COLORCURVES: boolean;
  46879. COLORGRADING: boolean;
  46880. COLORGRADING3D: boolean;
  46881. SAMPLER3DGREENDEPTH: boolean;
  46882. SAMPLER3DBGRMAP: boolean;
  46883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46884. EXPOSURE: boolean;
  46885. MULTIVIEW: boolean;
  46886. USEPHYSICALLIGHTFALLOFF: boolean;
  46887. USEGLTFLIGHTFALLOFF: boolean;
  46888. TWOSIDEDLIGHTING: boolean;
  46889. SHADOWFLOAT: boolean;
  46890. CLIPPLANE: boolean;
  46891. CLIPPLANE2: boolean;
  46892. CLIPPLANE3: boolean;
  46893. CLIPPLANE4: boolean;
  46894. POINTSIZE: boolean;
  46895. FOG: boolean;
  46896. LOGARITHMICDEPTH: boolean;
  46897. FORCENORMALFORWARD: boolean;
  46898. SPECULARAA: boolean;
  46899. CLEARCOAT: boolean;
  46900. CLEARCOAT_DEFAULTIOR: boolean;
  46901. CLEARCOAT_TEXTURE: boolean;
  46902. CLEARCOAT_TEXTUREDIRECTUV: number;
  46903. CLEARCOAT_BUMP: boolean;
  46904. CLEARCOAT_BUMPDIRECTUV: number;
  46905. CLEARCOAT_TINT: boolean;
  46906. CLEARCOAT_TINT_TEXTURE: boolean;
  46907. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46908. ANISOTROPIC: boolean;
  46909. ANISOTROPIC_TEXTURE: boolean;
  46910. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46911. BRDF_V_HEIGHT_CORRELATED: boolean;
  46912. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46913. SHEEN: boolean;
  46914. SHEEN_TEXTURE: boolean;
  46915. SHEEN_TEXTUREDIRECTUV: number;
  46916. SHEEN_LINKWITHALBEDO: boolean;
  46917. SUBSURFACE: boolean;
  46918. SS_REFRACTION: boolean;
  46919. SS_TRANSLUCENCY: boolean;
  46920. SS_SCATERRING: boolean;
  46921. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46922. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46923. SS_REFRACTIONMAP_3D: boolean;
  46924. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46925. SS_LODINREFRACTIONALPHA: boolean;
  46926. SS_GAMMAREFRACTION: boolean;
  46927. SS_RGBDREFRACTION: boolean;
  46928. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46929. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46930. UNLIT: boolean;
  46931. DEBUGMODE: number;
  46932. /**
  46933. * Initializes the PBR Material defines.
  46934. */
  46935. constructor();
  46936. /**
  46937. * Resets the PBR Material defines.
  46938. */
  46939. reset(): void;
  46940. }
  46941. /**
  46942. * The Physically based material base class of BJS.
  46943. *
  46944. * This offers the main features of a standard PBR material.
  46945. * For more information, please refer to the documentation :
  46946. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46947. */
  46948. export abstract class PBRBaseMaterial extends PushMaterial {
  46949. /**
  46950. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46951. */
  46952. static readonly PBRMATERIAL_OPAQUE: number;
  46953. /**
  46954. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46955. */
  46956. static readonly PBRMATERIAL_ALPHATEST: number;
  46957. /**
  46958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46959. */
  46960. static readonly PBRMATERIAL_ALPHABLEND: number;
  46961. /**
  46962. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46963. * They are also discarded below the alpha cutoff threshold to improve performances.
  46964. */
  46965. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46966. /**
  46967. * Defines the default value of how much AO map is occluding the analytical lights
  46968. * (point spot...).
  46969. */
  46970. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46971. /**
  46972. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46973. */
  46974. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46975. /**
  46976. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46977. * to enhance interoperability with other engines.
  46978. */
  46979. static readonly LIGHTFALLOFF_GLTF: number;
  46980. /**
  46981. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46982. * to enhance interoperability with other materials.
  46983. */
  46984. static readonly LIGHTFALLOFF_STANDARD: number;
  46985. /**
  46986. * Intensity of the direct lights e.g. the four lights available in your scene.
  46987. * This impacts both the direct diffuse and specular highlights.
  46988. */
  46989. protected _directIntensity: number;
  46990. /**
  46991. * Intensity of the emissive part of the material.
  46992. * This helps controlling the emissive effect without modifying the emissive color.
  46993. */
  46994. protected _emissiveIntensity: number;
  46995. /**
  46996. * Intensity of the environment e.g. how much the environment will light the object
  46997. * either through harmonics for rough material or through the refelction for shiny ones.
  46998. */
  46999. protected _environmentIntensity: number;
  47000. /**
  47001. * This is a special control allowing the reduction of the specular highlights coming from the
  47002. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47003. */
  47004. protected _specularIntensity: number;
  47005. /**
  47006. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47007. */
  47008. private _lightingInfos;
  47009. /**
  47010. * Debug Control allowing disabling the bump map on this material.
  47011. */
  47012. protected _disableBumpMap: boolean;
  47013. /**
  47014. * AKA Diffuse Texture in standard nomenclature.
  47015. */
  47016. protected _albedoTexture: Nullable<BaseTexture>;
  47017. /**
  47018. * AKA Occlusion Texture in other nomenclature.
  47019. */
  47020. protected _ambientTexture: Nullable<BaseTexture>;
  47021. /**
  47022. * AKA Occlusion Texture Intensity in other nomenclature.
  47023. */
  47024. protected _ambientTextureStrength: number;
  47025. /**
  47026. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47027. * 1 means it completely occludes it
  47028. * 0 mean it has no impact
  47029. */
  47030. protected _ambientTextureImpactOnAnalyticalLights: number;
  47031. /**
  47032. * Stores the alpha values in a texture.
  47033. */
  47034. protected _opacityTexture: Nullable<BaseTexture>;
  47035. /**
  47036. * Stores the reflection values in a texture.
  47037. */
  47038. protected _reflectionTexture: Nullable<BaseTexture>;
  47039. /**
  47040. * Stores the emissive values in a texture.
  47041. */
  47042. protected _emissiveTexture: Nullable<BaseTexture>;
  47043. /**
  47044. * AKA Specular texture in other nomenclature.
  47045. */
  47046. protected _reflectivityTexture: Nullable<BaseTexture>;
  47047. /**
  47048. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47049. */
  47050. protected _metallicTexture: Nullable<BaseTexture>;
  47051. /**
  47052. * Specifies the metallic scalar of the metallic/roughness workflow.
  47053. * Can also be used to scale the metalness values of the metallic texture.
  47054. */
  47055. protected _metallic: Nullable<number>;
  47056. /**
  47057. * Specifies the roughness scalar of the metallic/roughness workflow.
  47058. * Can also be used to scale the roughness values of the metallic texture.
  47059. */
  47060. protected _roughness: Nullable<number>;
  47061. /**
  47062. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47063. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47064. */
  47065. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47066. /**
  47067. * Stores surface normal data used to displace a mesh in a texture.
  47068. */
  47069. protected _bumpTexture: Nullable<BaseTexture>;
  47070. /**
  47071. * Stores the pre-calculated light information of a mesh in a texture.
  47072. */
  47073. protected _lightmapTexture: Nullable<BaseTexture>;
  47074. /**
  47075. * The color of a material in ambient lighting.
  47076. */
  47077. protected _ambientColor: Color3;
  47078. /**
  47079. * AKA Diffuse Color in other nomenclature.
  47080. */
  47081. protected _albedoColor: Color3;
  47082. /**
  47083. * AKA Specular Color in other nomenclature.
  47084. */
  47085. protected _reflectivityColor: Color3;
  47086. /**
  47087. * The color applied when light is reflected from a material.
  47088. */
  47089. protected _reflectionColor: Color3;
  47090. /**
  47091. * The color applied when light is emitted from a material.
  47092. */
  47093. protected _emissiveColor: Color3;
  47094. /**
  47095. * AKA Glossiness in other nomenclature.
  47096. */
  47097. protected _microSurface: number;
  47098. /**
  47099. * Specifies that the material will use the light map as a show map.
  47100. */
  47101. protected _useLightmapAsShadowmap: boolean;
  47102. /**
  47103. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47104. * makes the reflect vector face the model (under horizon).
  47105. */
  47106. protected _useHorizonOcclusion: boolean;
  47107. /**
  47108. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47109. * too much the area relying on ambient texture to define their ambient occlusion.
  47110. */
  47111. protected _useRadianceOcclusion: boolean;
  47112. /**
  47113. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47114. */
  47115. protected _useAlphaFromAlbedoTexture: boolean;
  47116. /**
  47117. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47118. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47119. */
  47120. protected _useSpecularOverAlpha: boolean;
  47121. /**
  47122. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47123. */
  47124. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47125. /**
  47126. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47127. */
  47128. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47129. /**
  47130. * Specifies if the metallic texture contains the roughness information in its green channel.
  47131. */
  47132. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47133. /**
  47134. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47135. */
  47136. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47137. /**
  47138. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47139. */
  47140. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47141. /**
  47142. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47143. */
  47144. protected _useAmbientInGrayScale: boolean;
  47145. /**
  47146. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47147. * The material will try to infer what glossiness each pixel should be.
  47148. */
  47149. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47150. /**
  47151. * Defines the falloff type used in this material.
  47152. * It by default is Physical.
  47153. */
  47154. protected _lightFalloff: number;
  47155. /**
  47156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47158. */
  47159. protected _useRadianceOverAlpha: boolean;
  47160. /**
  47161. * Allows using an object space normal map (instead of tangent space).
  47162. */
  47163. protected _useObjectSpaceNormalMap: boolean;
  47164. /**
  47165. * Allows using the bump map in parallax mode.
  47166. */
  47167. protected _useParallax: boolean;
  47168. /**
  47169. * Allows using the bump map in parallax occlusion mode.
  47170. */
  47171. protected _useParallaxOcclusion: boolean;
  47172. /**
  47173. * Controls the scale bias of the parallax mode.
  47174. */
  47175. protected _parallaxScaleBias: number;
  47176. /**
  47177. * If sets to true, disables all the lights affecting the material.
  47178. */
  47179. protected _disableLighting: boolean;
  47180. /**
  47181. * Number of Simultaneous lights allowed on the material.
  47182. */
  47183. protected _maxSimultaneousLights: number;
  47184. /**
  47185. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47186. */
  47187. protected _invertNormalMapX: boolean;
  47188. /**
  47189. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47190. */
  47191. protected _invertNormalMapY: boolean;
  47192. /**
  47193. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47194. */
  47195. protected _twoSidedLighting: boolean;
  47196. /**
  47197. * Defines the alpha limits in alpha test mode.
  47198. */
  47199. protected _alphaCutOff: number;
  47200. /**
  47201. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47202. */
  47203. protected _forceAlphaTest: boolean;
  47204. /**
  47205. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47206. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47207. */
  47208. protected _useAlphaFresnel: boolean;
  47209. /**
  47210. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47211. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47212. */
  47213. protected _useLinearAlphaFresnel: boolean;
  47214. /**
  47215. * The transparency mode of the material.
  47216. */
  47217. protected _transparencyMode: Nullable<number>;
  47218. /**
  47219. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47220. * from cos thetav and roughness:
  47221. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47222. */
  47223. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47224. /**
  47225. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47226. */
  47227. protected _forceIrradianceInFragment: boolean;
  47228. /**
  47229. * Force normal to face away from face.
  47230. */
  47231. protected _forceNormalForward: boolean;
  47232. /**
  47233. * Enables specular anti aliasing in the PBR shader.
  47234. * It will both interacts on the Geometry for analytical and IBL lighting.
  47235. * It also prefilter the roughness map based on the bump values.
  47236. */
  47237. protected _enableSpecularAntiAliasing: boolean;
  47238. /**
  47239. * Default configuration related to image processing available in the PBR Material.
  47240. */
  47241. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47242. /**
  47243. * Keep track of the image processing observer to allow dispose and replace.
  47244. */
  47245. private _imageProcessingObserver;
  47246. /**
  47247. * Attaches a new image processing configuration to the PBR Material.
  47248. * @param configuration
  47249. */
  47250. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47251. /**
  47252. * Stores the available render targets.
  47253. */
  47254. private _renderTargets;
  47255. /**
  47256. * Sets the global ambient color for the material used in lighting calculations.
  47257. */
  47258. private _globalAmbientColor;
  47259. /**
  47260. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47261. */
  47262. private _useLogarithmicDepth;
  47263. /**
  47264. * If set to true, no lighting calculations will be applied.
  47265. */
  47266. private _unlit;
  47267. private _debugMode;
  47268. /**
  47269. * @hidden
  47270. * This is reserved for the inspector.
  47271. * Defines the material debug mode.
  47272. * It helps seeing only some components of the material while troubleshooting.
  47273. */
  47274. debugMode: number;
  47275. /**
  47276. * @hidden
  47277. * This is reserved for the inspector.
  47278. * Specify from where on screen the debug mode should start.
  47279. * The value goes from -1 (full screen) to 1 (not visible)
  47280. * It helps with side by side comparison against the final render
  47281. * This defaults to -1
  47282. */
  47283. private debugLimit;
  47284. /**
  47285. * @hidden
  47286. * This is reserved for the inspector.
  47287. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47288. * You can use the factor to better multiply the final value.
  47289. */
  47290. private debugFactor;
  47291. /**
  47292. * Defines the clear coat layer parameters for the material.
  47293. */
  47294. readonly clearCoat: PBRClearCoatConfiguration;
  47295. /**
  47296. * Defines the anisotropic parameters for the material.
  47297. */
  47298. readonly anisotropy: PBRAnisotropicConfiguration;
  47299. /**
  47300. * Defines the BRDF parameters for the material.
  47301. */
  47302. readonly brdf: PBRBRDFConfiguration;
  47303. /**
  47304. * Defines the Sheen parameters for the material.
  47305. */
  47306. readonly sheen: PBRSheenConfiguration;
  47307. /**
  47308. * Defines the SubSurface parameters for the material.
  47309. */
  47310. readonly subSurface: PBRSubSurfaceConfiguration;
  47311. /**
  47312. * Custom callback helping to override the default shader used in the material.
  47313. */
  47314. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47315. /**
  47316. * Instantiates a new PBRMaterial instance.
  47317. *
  47318. * @param name The material name
  47319. * @param scene The scene the material will be use in.
  47320. */
  47321. constructor(name: string, scene: Scene);
  47322. /**
  47323. * Gets a boolean indicating that current material needs to register RTT
  47324. */
  47325. readonly hasRenderTargetTextures: boolean;
  47326. /**
  47327. * Gets the name of the material class.
  47328. */
  47329. getClassName(): string;
  47330. /**
  47331. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47332. */
  47333. /**
  47334. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47335. */
  47336. useLogarithmicDepth: boolean;
  47337. /**
  47338. * Gets the current transparency mode.
  47339. */
  47340. /**
  47341. * Sets the transparency mode of the material.
  47342. *
  47343. * | Value | Type | Description |
  47344. * | ----- | ----------------------------------- | ----------- |
  47345. * | 0 | OPAQUE | |
  47346. * | 1 | ALPHATEST | |
  47347. * | 2 | ALPHABLEND | |
  47348. * | 3 | ALPHATESTANDBLEND | |
  47349. *
  47350. */
  47351. transparencyMode: Nullable<number>;
  47352. /**
  47353. * Returns true if alpha blending should be disabled.
  47354. */
  47355. private readonly _disableAlphaBlending;
  47356. /**
  47357. * Specifies whether or not this material should be rendered in alpha blend mode.
  47358. */
  47359. needAlphaBlending(): boolean;
  47360. /**
  47361. * Specifies if the mesh will require alpha blending.
  47362. * @param mesh - BJS mesh.
  47363. */
  47364. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47365. /**
  47366. * Specifies whether or not this material should be rendered in alpha test mode.
  47367. */
  47368. needAlphaTesting(): boolean;
  47369. /**
  47370. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47371. */
  47372. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47373. /**
  47374. * Gets the texture used for the alpha test.
  47375. */
  47376. getAlphaTestTexture(): Nullable<BaseTexture>;
  47377. /**
  47378. * Specifies that the submesh is ready to be used.
  47379. * @param mesh - BJS mesh.
  47380. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47381. * @param useInstances - Specifies that instances should be used.
  47382. * @returns - boolean indicating that the submesh is ready or not.
  47383. */
  47384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47385. /**
  47386. * Specifies if the material uses metallic roughness workflow.
  47387. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47388. */
  47389. isMetallicWorkflow(): boolean;
  47390. private _prepareEffect;
  47391. private _prepareDefines;
  47392. /**
  47393. * Force shader compilation
  47394. */
  47395. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47396. clipPlane: boolean;
  47397. }>): void;
  47398. /**
  47399. * Initializes the uniform buffer layout for the shader.
  47400. */
  47401. buildUniformLayout(): void;
  47402. /**
  47403. * Unbinds the material from the mesh
  47404. */
  47405. unbind(): void;
  47406. /**
  47407. * Binds the submesh data.
  47408. * @param world - The world matrix.
  47409. * @param mesh - The BJS mesh.
  47410. * @param subMesh - A submesh of the BJS mesh.
  47411. */
  47412. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47413. /**
  47414. * Returns the animatable textures.
  47415. * @returns - Array of animatable textures.
  47416. */
  47417. getAnimatables(): IAnimatable[];
  47418. /**
  47419. * Returns the texture used for reflections.
  47420. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47421. */
  47422. private _getReflectionTexture;
  47423. /**
  47424. * Returns an array of the actively used textures.
  47425. * @returns - Array of BaseTextures
  47426. */
  47427. getActiveTextures(): BaseTexture[];
  47428. /**
  47429. * Checks to see if a texture is used in the material.
  47430. * @param texture - Base texture to use.
  47431. * @returns - Boolean specifying if a texture is used in the material.
  47432. */
  47433. hasTexture(texture: BaseTexture): boolean;
  47434. /**
  47435. * Disposes the resources of the material.
  47436. * @param forceDisposeEffect - Forces the disposal of effects.
  47437. * @param forceDisposeTextures - Forces the disposal of all textures.
  47438. */
  47439. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47443. import { Nullable } from "babylonjs/types";
  47444. import { Scene } from "babylonjs/scene";
  47445. import { Color3 } from "babylonjs/Maths/math";
  47446. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47447. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47449. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47450. /**
  47451. * The Physically based material of BJS.
  47452. *
  47453. * This offers the main features of a standard PBR material.
  47454. * For more information, please refer to the documentation :
  47455. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47456. */
  47457. export class PBRMaterial extends PBRBaseMaterial {
  47458. /**
  47459. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47460. */
  47461. static readonly PBRMATERIAL_OPAQUE: number;
  47462. /**
  47463. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47464. */
  47465. static readonly PBRMATERIAL_ALPHATEST: number;
  47466. /**
  47467. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47468. */
  47469. static readonly PBRMATERIAL_ALPHABLEND: number;
  47470. /**
  47471. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47472. * They are also discarded below the alpha cutoff threshold to improve performances.
  47473. */
  47474. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47475. /**
  47476. * Defines the default value of how much AO map is occluding the analytical lights
  47477. * (point spot...).
  47478. */
  47479. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47480. /**
  47481. * Intensity of the direct lights e.g. the four lights available in your scene.
  47482. * This impacts both the direct diffuse and specular highlights.
  47483. */
  47484. directIntensity: number;
  47485. /**
  47486. * Intensity of the emissive part of the material.
  47487. * This helps controlling the emissive effect without modifying the emissive color.
  47488. */
  47489. emissiveIntensity: number;
  47490. /**
  47491. * Intensity of the environment e.g. how much the environment will light the object
  47492. * either through harmonics for rough material or through the refelction for shiny ones.
  47493. */
  47494. environmentIntensity: number;
  47495. /**
  47496. * This is a special control allowing the reduction of the specular highlights coming from the
  47497. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47498. */
  47499. specularIntensity: number;
  47500. /**
  47501. * Debug Control allowing disabling the bump map on this material.
  47502. */
  47503. disableBumpMap: boolean;
  47504. /**
  47505. * AKA Diffuse Texture in standard nomenclature.
  47506. */
  47507. albedoTexture: BaseTexture;
  47508. /**
  47509. * AKA Occlusion Texture in other nomenclature.
  47510. */
  47511. ambientTexture: BaseTexture;
  47512. /**
  47513. * AKA Occlusion Texture Intensity in other nomenclature.
  47514. */
  47515. ambientTextureStrength: number;
  47516. /**
  47517. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47518. * 1 means it completely occludes it
  47519. * 0 mean it has no impact
  47520. */
  47521. ambientTextureImpactOnAnalyticalLights: number;
  47522. /**
  47523. * Stores the alpha values in a texture.
  47524. */
  47525. opacityTexture: BaseTexture;
  47526. /**
  47527. * Stores the reflection values in a texture.
  47528. */
  47529. reflectionTexture: Nullable<BaseTexture>;
  47530. /**
  47531. * Stores the emissive values in a texture.
  47532. */
  47533. emissiveTexture: BaseTexture;
  47534. /**
  47535. * AKA Specular texture in other nomenclature.
  47536. */
  47537. reflectivityTexture: BaseTexture;
  47538. /**
  47539. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47540. */
  47541. metallicTexture: BaseTexture;
  47542. /**
  47543. * Specifies the metallic scalar of the metallic/roughness workflow.
  47544. * Can also be used to scale the metalness values of the metallic texture.
  47545. */
  47546. metallic: Nullable<number>;
  47547. /**
  47548. * Specifies the roughness scalar of the metallic/roughness workflow.
  47549. * Can also be used to scale the roughness values of the metallic texture.
  47550. */
  47551. roughness: Nullable<number>;
  47552. /**
  47553. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47554. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47555. */
  47556. microSurfaceTexture: BaseTexture;
  47557. /**
  47558. * Stores surface normal data used to displace a mesh in a texture.
  47559. */
  47560. bumpTexture: BaseTexture;
  47561. /**
  47562. * Stores the pre-calculated light information of a mesh in a texture.
  47563. */
  47564. lightmapTexture: BaseTexture;
  47565. /**
  47566. * Stores the refracted light information in a texture.
  47567. */
  47568. refractionTexture: Nullable<BaseTexture>;
  47569. /**
  47570. * The color of a material in ambient lighting.
  47571. */
  47572. ambientColor: Color3;
  47573. /**
  47574. * AKA Diffuse Color in other nomenclature.
  47575. */
  47576. albedoColor: Color3;
  47577. /**
  47578. * AKA Specular Color in other nomenclature.
  47579. */
  47580. reflectivityColor: Color3;
  47581. /**
  47582. * The color reflected from the material.
  47583. */
  47584. reflectionColor: Color3;
  47585. /**
  47586. * The color emitted from the material.
  47587. */
  47588. emissiveColor: Color3;
  47589. /**
  47590. * AKA Glossiness in other nomenclature.
  47591. */
  47592. microSurface: number;
  47593. /**
  47594. * source material index of refraction (IOR)' / 'destination material IOR.
  47595. */
  47596. indexOfRefraction: number;
  47597. /**
  47598. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47599. */
  47600. invertRefractionY: boolean;
  47601. /**
  47602. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47603. * Materials half opaque for instance using refraction could benefit from this control.
  47604. */
  47605. linkRefractionWithTransparency: boolean;
  47606. /**
  47607. * If true, the light map contains occlusion information instead of lighting info.
  47608. */
  47609. useLightmapAsShadowmap: boolean;
  47610. /**
  47611. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47612. */
  47613. useAlphaFromAlbedoTexture: boolean;
  47614. /**
  47615. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47616. */
  47617. forceAlphaTest: boolean;
  47618. /**
  47619. * Defines the alpha limits in alpha test mode.
  47620. */
  47621. alphaCutOff: number;
  47622. /**
  47623. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47624. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47625. */
  47626. useSpecularOverAlpha: boolean;
  47627. /**
  47628. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47629. */
  47630. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47631. /**
  47632. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47633. */
  47634. useRoughnessFromMetallicTextureAlpha: boolean;
  47635. /**
  47636. * Specifies if the metallic texture contains the roughness information in its green channel.
  47637. */
  47638. useRoughnessFromMetallicTextureGreen: boolean;
  47639. /**
  47640. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47641. */
  47642. useMetallnessFromMetallicTextureBlue: boolean;
  47643. /**
  47644. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47645. */
  47646. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47647. /**
  47648. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47649. */
  47650. useAmbientInGrayScale: boolean;
  47651. /**
  47652. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47653. * The material will try to infer what glossiness each pixel should be.
  47654. */
  47655. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47656. /**
  47657. * BJS is using an harcoded light falloff based on a manually sets up range.
  47658. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47659. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47660. */
  47661. /**
  47662. * BJS is using an harcoded light falloff based on a manually sets up range.
  47663. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47664. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47665. */
  47666. usePhysicalLightFalloff: boolean;
  47667. /**
  47668. * In order to support the falloff compatibility with gltf, a special mode has been added
  47669. * to reproduce the gltf light falloff.
  47670. */
  47671. /**
  47672. * In order to support the falloff compatibility with gltf, a special mode has been added
  47673. * to reproduce the gltf light falloff.
  47674. */
  47675. useGLTFLightFalloff: boolean;
  47676. /**
  47677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47679. */
  47680. useRadianceOverAlpha: boolean;
  47681. /**
  47682. * Allows using an object space normal map (instead of tangent space).
  47683. */
  47684. useObjectSpaceNormalMap: boolean;
  47685. /**
  47686. * Allows using the bump map in parallax mode.
  47687. */
  47688. useParallax: boolean;
  47689. /**
  47690. * Allows using the bump map in parallax occlusion mode.
  47691. */
  47692. useParallaxOcclusion: boolean;
  47693. /**
  47694. * Controls the scale bias of the parallax mode.
  47695. */
  47696. parallaxScaleBias: number;
  47697. /**
  47698. * If sets to true, disables all the lights affecting the material.
  47699. */
  47700. disableLighting: boolean;
  47701. /**
  47702. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47703. */
  47704. forceIrradianceInFragment: boolean;
  47705. /**
  47706. * Number of Simultaneous lights allowed on the material.
  47707. */
  47708. maxSimultaneousLights: number;
  47709. /**
  47710. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47711. */
  47712. invertNormalMapX: boolean;
  47713. /**
  47714. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47715. */
  47716. invertNormalMapY: boolean;
  47717. /**
  47718. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47719. */
  47720. twoSidedLighting: boolean;
  47721. /**
  47722. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47723. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47724. */
  47725. useAlphaFresnel: boolean;
  47726. /**
  47727. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47728. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47729. */
  47730. useLinearAlphaFresnel: boolean;
  47731. /**
  47732. * Let user defines the brdf lookup texture used for IBL.
  47733. * A default 8bit version is embedded but you could point at :
  47734. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47735. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47736. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47737. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47738. */
  47739. environmentBRDFTexture: Nullable<BaseTexture>;
  47740. /**
  47741. * Force normal to face away from face.
  47742. */
  47743. forceNormalForward: boolean;
  47744. /**
  47745. * Enables specular anti aliasing in the PBR shader.
  47746. * It will both interacts on the Geometry for analytical and IBL lighting.
  47747. * It also prefilter the roughness map based on the bump values.
  47748. */
  47749. enableSpecularAntiAliasing: boolean;
  47750. /**
  47751. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47752. * makes the reflect vector face the model (under horizon).
  47753. */
  47754. useHorizonOcclusion: boolean;
  47755. /**
  47756. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47757. * too much the area relying on ambient texture to define their ambient occlusion.
  47758. */
  47759. useRadianceOcclusion: boolean;
  47760. /**
  47761. * If set to true, no lighting calculations will be applied.
  47762. */
  47763. unlit: boolean;
  47764. /**
  47765. * Gets the image processing configuration used either in this material.
  47766. */
  47767. /**
  47768. * Sets the Default image processing configuration used either in the this material.
  47769. *
  47770. * If sets to null, the scene one is in use.
  47771. */
  47772. imageProcessingConfiguration: ImageProcessingConfiguration;
  47773. /**
  47774. * Gets wether the color curves effect is enabled.
  47775. */
  47776. /**
  47777. * Sets wether the color curves effect is enabled.
  47778. */
  47779. cameraColorCurvesEnabled: boolean;
  47780. /**
  47781. * Gets wether the color grading effect is enabled.
  47782. */
  47783. /**
  47784. * Gets wether the color grading effect is enabled.
  47785. */
  47786. cameraColorGradingEnabled: boolean;
  47787. /**
  47788. * Gets wether tonemapping is enabled or not.
  47789. */
  47790. /**
  47791. * Sets wether tonemapping is enabled or not
  47792. */
  47793. cameraToneMappingEnabled: boolean;
  47794. /**
  47795. * The camera exposure used on this material.
  47796. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47797. * This corresponds to a photographic exposure.
  47798. */
  47799. /**
  47800. * The camera exposure used on this material.
  47801. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47802. * This corresponds to a photographic exposure.
  47803. */
  47804. cameraExposure: number;
  47805. /**
  47806. * Gets The camera contrast used on this material.
  47807. */
  47808. /**
  47809. * Sets The camera contrast used on this material.
  47810. */
  47811. cameraContrast: number;
  47812. /**
  47813. * Gets the Color Grading 2D Lookup Texture.
  47814. */
  47815. /**
  47816. * Sets the Color Grading 2D Lookup Texture.
  47817. */
  47818. cameraColorGradingTexture: Nullable<BaseTexture>;
  47819. /**
  47820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47822. * 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;
  47823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47824. */
  47825. /**
  47826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47828. * 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;
  47829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47830. */
  47831. cameraColorCurves: Nullable<ColorCurves>;
  47832. /**
  47833. * Instantiates a new PBRMaterial instance.
  47834. *
  47835. * @param name The material name
  47836. * @param scene The scene the material will be use in.
  47837. */
  47838. constructor(name: string, scene: Scene);
  47839. /**
  47840. * Returns the name of this material class.
  47841. */
  47842. getClassName(): string;
  47843. /**
  47844. * Makes a duplicate of the current material.
  47845. * @param name - name to use for the new material.
  47846. */
  47847. clone(name: string): PBRMaterial;
  47848. /**
  47849. * Serializes this PBR Material.
  47850. * @returns - An object with the serialized material.
  47851. */
  47852. serialize(): any;
  47853. /**
  47854. * Parses a PBR Material from a serialized object.
  47855. * @param source - Serialized object.
  47856. * @param scene - BJS scene instance.
  47857. * @param rootUrl - url for the scene object
  47858. * @returns - PBRMaterial
  47859. */
  47860. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47861. }
  47862. }
  47863. declare module "babylonjs/Misc/dds" {
  47864. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47865. import { Engine } from "babylonjs/Engines/engine";
  47866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Scene } from "babylonjs/scene";
  47869. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47870. /**
  47871. * Direct draw surface info
  47872. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47873. */
  47874. export interface DDSInfo {
  47875. /**
  47876. * Width of the texture
  47877. */
  47878. width: number;
  47879. /**
  47880. * Width of the texture
  47881. */
  47882. height: number;
  47883. /**
  47884. * Number of Mipmaps for the texture
  47885. * @see https://en.wikipedia.org/wiki/Mipmap
  47886. */
  47887. mipmapCount: number;
  47888. /**
  47889. * If the textures format is a known fourCC format
  47890. * @see https://www.fourcc.org/
  47891. */
  47892. isFourCC: boolean;
  47893. /**
  47894. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47895. */
  47896. isRGB: boolean;
  47897. /**
  47898. * If the texture is a lumincance format
  47899. */
  47900. isLuminance: boolean;
  47901. /**
  47902. * If this is a cube texture
  47903. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47904. */
  47905. isCube: boolean;
  47906. /**
  47907. * If the texture is a compressed format eg. FOURCC_DXT1
  47908. */
  47909. isCompressed: boolean;
  47910. /**
  47911. * The dxgiFormat of the texture
  47912. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47913. */
  47914. dxgiFormat: number;
  47915. /**
  47916. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47917. */
  47918. textureType: number;
  47919. /**
  47920. * Sphericle polynomial created for the dds texture
  47921. */
  47922. sphericalPolynomial?: SphericalPolynomial;
  47923. }
  47924. /**
  47925. * Class used to provide DDS decompression tools
  47926. */
  47927. export class DDSTools {
  47928. /**
  47929. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47930. */
  47931. static StoreLODInAlphaChannel: boolean;
  47932. /**
  47933. * Gets DDS information from an array buffer
  47934. * @param arrayBuffer defines the array buffer to read data from
  47935. * @returns the DDS information
  47936. */
  47937. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47938. private static _FloatView;
  47939. private static _Int32View;
  47940. private static _ToHalfFloat;
  47941. private static _FromHalfFloat;
  47942. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47943. private static _GetHalfFloatRGBAArrayBuffer;
  47944. private static _GetFloatRGBAArrayBuffer;
  47945. private static _GetFloatAsUIntRGBAArrayBuffer;
  47946. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47947. private static _GetRGBAArrayBuffer;
  47948. private static _ExtractLongWordOrder;
  47949. private static _GetRGBArrayBuffer;
  47950. private static _GetLuminanceArrayBuffer;
  47951. /**
  47952. * Uploads DDS Levels to a Babylon Texture
  47953. * @hidden
  47954. */
  47955. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47956. }
  47957. module "babylonjs/Engines/engine" {
  47958. interface Engine {
  47959. /**
  47960. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47961. * @param rootUrl defines the url where the file to load is located
  47962. * @param scene defines the current scene
  47963. * @param lodScale defines scale to apply to the mip map selection
  47964. * @param lodOffset defines offset to apply to the mip map selection
  47965. * @param onLoad defines an optional callback raised when the texture is loaded
  47966. * @param onError defines an optional callback raised if there is an issue to load the texture
  47967. * @param format defines the format of the data
  47968. * @param forcedExtension defines the extension to use to pick the right loader
  47969. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47970. * @returns the cube texture as an InternalTexture
  47971. */
  47972. 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;
  47973. }
  47974. }
  47975. }
  47976. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47977. import { Nullable } from "babylonjs/types";
  47978. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47979. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47980. /**
  47981. * Implementation of the DDS Texture Loader.
  47982. * @hidden
  47983. */
  47984. export class _DDSTextureLoader implements IInternalTextureLoader {
  47985. /**
  47986. * Defines wether the loader supports cascade loading the different faces.
  47987. */
  47988. readonly supportCascades: boolean;
  47989. /**
  47990. * This returns if the loader support the current file information.
  47991. * @param extension defines the file extension of the file being loaded
  47992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47993. * @param fallback defines the fallback internal texture if any
  47994. * @param isBase64 defines whether the texture is encoded as a base64
  47995. * @param isBuffer defines whether the texture data are stored as a buffer
  47996. * @returns true if the loader can load the specified file
  47997. */
  47998. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47999. /**
  48000. * Transform the url before loading if required.
  48001. * @param rootUrl the url of the texture
  48002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48003. * @returns the transformed texture
  48004. */
  48005. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48006. /**
  48007. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48008. * @param rootUrl the url of the texture
  48009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48010. * @returns the fallback texture
  48011. */
  48012. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48013. /**
  48014. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48015. * @param data contains the texture data
  48016. * @param texture defines the BabylonJS internal texture
  48017. * @param createPolynomials will be true if polynomials have been requested
  48018. * @param onLoad defines the callback to trigger once the texture is ready
  48019. * @param onError defines the callback to trigger in case of error
  48020. */
  48021. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48022. /**
  48023. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48024. * @param data contains the texture data
  48025. * @param texture defines the BabylonJS internal texture
  48026. * @param callback defines the method to call once ready to upload
  48027. */
  48028. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48029. }
  48030. }
  48031. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48032. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48033. /** @hidden */
  48034. export var rgbdEncodePixelShader: {
  48035. name: string;
  48036. shader: string;
  48037. };
  48038. }
  48039. declare module "babylonjs/Misc/environmentTextureTools" {
  48040. import { Nullable } from "babylonjs/types";
  48041. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48043. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48044. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48045. import "babylonjs/Shaders/rgbdEncode.fragment";
  48046. import "babylonjs/Shaders/rgbdDecode.fragment";
  48047. /**
  48048. * Raw texture data and descriptor sufficient for WebGL texture upload
  48049. */
  48050. export interface EnvironmentTextureInfo {
  48051. /**
  48052. * Version of the environment map
  48053. */
  48054. version: number;
  48055. /**
  48056. * Width of image
  48057. */
  48058. width: number;
  48059. /**
  48060. * Irradiance information stored in the file.
  48061. */
  48062. irradiance: any;
  48063. /**
  48064. * Specular information stored in the file.
  48065. */
  48066. specular: any;
  48067. }
  48068. /**
  48069. * Sets of helpers addressing the serialization and deserialization of environment texture
  48070. * stored in a BabylonJS env file.
  48071. * Those files are usually stored as .env files.
  48072. */
  48073. export class EnvironmentTextureTools {
  48074. /**
  48075. * Magic number identifying the env file.
  48076. */
  48077. private static _MagicBytes;
  48078. /**
  48079. * Gets the environment info from an env file.
  48080. * @param data The array buffer containing the .env bytes.
  48081. * @returns the environment file info (the json header) if successfully parsed.
  48082. */
  48083. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48084. /**
  48085. * Creates an environment texture from a loaded cube texture.
  48086. * @param texture defines the cube texture to convert in env file
  48087. * @return a promise containing the environment data if succesfull.
  48088. */
  48089. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48090. /**
  48091. * Creates a JSON representation of the spherical data.
  48092. * @param texture defines the texture containing the polynomials
  48093. * @return the JSON representation of the spherical info
  48094. */
  48095. private static _CreateEnvTextureIrradiance;
  48096. /**
  48097. * Uploads the texture info contained in the env file to the GPU.
  48098. * @param texture defines the internal texture to upload to
  48099. * @param arrayBuffer defines the buffer cotaining the data to load
  48100. * @param info defines the texture info retrieved through the GetEnvInfo method
  48101. * @returns a promise
  48102. */
  48103. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48104. /**
  48105. * Uploads the levels of image data to the GPU.
  48106. * @param texture defines the internal texture to upload to
  48107. * @param imageData defines the array buffer views of image data [mipmap][face]
  48108. * @returns a promise
  48109. */
  48110. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48111. /**
  48112. * Uploads spherical polynomials information to the texture.
  48113. * @param texture defines the texture we are trying to upload the information to
  48114. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48115. */
  48116. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48117. /** @hidden */
  48118. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48119. }
  48120. }
  48121. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48122. import { Nullable } from "babylonjs/types";
  48123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48124. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48125. /**
  48126. * Implementation of the ENV Texture Loader.
  48127. * @hidden
  48128. */
  48129. export class _ENVTextureLoader implements IInternalTextureLoader {
  48130. /**
  48131. * Defines wether the loader supports cascade loading the different faces.
  48132. */
  48133. readonly supportCascades: boolean;
  48134. /**
  48135. * This returns if the loader support the current file information.
  48136. * @param extension defines the file extension of the file being loaded
  48137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48138. * @param fallback defines the fallback internal texture if any
  48139. * @param isBase64 defines whether the texture is encoded as a base64
  48140. * @param isBuffer defines whether the texture data are stored as a buffer
  48141. * @returns true if the loader can load the specified file
  48142. */
  48143. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48144. /**
  48145. * Transform the url before loading if required.
  48146. * @param rootUrl the url of the texture
  48147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48148. * @returns the transformed texture
  48149. */
  48150. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48151. /**
  48152. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48153. * @param rootUrl the url of the texture
  48154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48155. * @returns the fallback texture
  48156. */
  48157. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48158. /**
  48159. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48160. * @param data contains the texture data
  48161. * @param texture defines the BabylonJS internal texture
  48162. * @param createPolynomials will be true if polynomials have been requested
  48163. * @param onLoad defines the callback to trigger once the texture is ready
  48164. * @param onError defines the callback to trigger in case of error
  48165. */
  48166. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48167. /**
  48168. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48169. * @param data contains the texture data
  48170. * @param texture defines the BabylonJS internal texture
  48171. * @param callback defines the method to call once ready to upload
  48172. */
  48173. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48174. }
  48175. }
  48176. declare module "babylonjs/Misc/khronosTextureContainer" {
  48177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48178. /**
  48179. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48180. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48181. */
  48182. export class KhronosTextureContainer {
  48183. /** contents of the KTX container file */
  48184. arrayBuffer: any;
  48185. private static HEADER_LEN;
  48186. private static COMPRESSED_2D;
  48187. private static COMPRESSED_3D;
  48188. private static TEX_2D;
  48189. private static TEX_3D;
  48190. /**
  48191. * Gets the openGL type
  48192. */
  48193. glType: number;
  48194. /**
  48195. * Gets the openGL type size
  48196. */
  48197. glTypeSize: number;
  48198. /**
  48199. * Gets the openGL format
  48200. */
  48201. glFormat: number;
  48202. /**
  48203. * Gets the openGL internal format
  48204. */
  48205. glInternalFormat: number;
  48206. /**
  48207. * Gets the base internal format
  48208. */
  48209. glBaseInternalFormat: number;
  48210. /**
  48211. * Gets image width in pixel
  48212. */
  48213. pixelWidth: number;
  48214. /**
  48215. * Gets image height in pixel
  48216. */
  48217. pixelHeight: number;
  48218. /**
  48219. * Gets image depth in pixels
  48220. */
  48221. pixelDepth: number;
  48222. /**
  48223. * Gets the number of array elements
  48224. */
  48225. numberOfArrayElements: number;
  48226. /**
  48227. * Gets the number of faces
  48228. */
  48229. numberOfFaces: number;
  48230. /**
  48231. * Gets the number of mipmap levels
  48232. */
  48233. numberOfMipmapLevels: number;
  48234. /**
  48235. * Gets the bytes of key value data
  48236. */
  48237. bytesOfKeyValueData: number;
  48238. /**
  48239. * Gets the load type
  48240. */
  48241. loadType: number;
  48242. /**
  48243. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48244. */
  48245. isInvalid: boolean;
  48246. /**
  48247. * Creates a new KhronosTextureContainer
  48248. * @param arrayBuffer contents of the KTX container file
  48249. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48250. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48251. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48252. */
  48253. constructor(
  48254. /** contents of the KTX container file */
  48255. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48256. /**
  48257. * Uploads KTX content to a Babylon Texture.
  48258. * It is assumed that the texture has already been created & is currently bound
  48259. * @hidden
  48260. */
  48261. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48262. private _upload2DCompressedLevels;
  48263. }
  48264. }
  48265. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48266. import { Nullable } from "babylonjs/types";
  48267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48268. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48269. /**
  48270. * Implementation of the KTX Texture Loader.
  48271. * @hidden
  48272. */
  48273. export class _KTXTextureLoader implements IInternalTextureLoader {
  48274. /**
  48275. * Defines wether the loader supports cascade loading the different faces.
  48276. */
  48277. readonly supportCascades: boolean;
  48278. /**
  48279. * This returns if the loader support the current file information.
  48280. * @param extension defines the file extension of the file being loaded
  48281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48282. * @param fallback defines the fallback internal texture if any
  48283. * @param isBase64 defines whether the texture is encoded as a base64
  48284. * @param isBuffer defines whether the texture data are stored as a buffer
  48285. * @returns true if the loader can load the specified file
  48286. */
  48287. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48288. /**
  48289. * Transform the url before loading if required.
  48290. * @param rootUrl the url of the texture
  48291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48292. * @returns the transformed texture
  48293. */
  48294. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48295. /**
  48296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48297. * @param rootUrl the url of the texture
  48298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48299. * @returns the fallback texture
  48300. */
  48301. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48302. /**
  48303. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48304. * @param data contains the texture data
  48305. * @param texture defines the BabylonJS internal texture
  48306. * @param createPolynomials will be true if polynomials have been requested
  48307. * @param onLoad defines the callback to trigger once the texture is ready
  48308. * @param onError defines the callback to trigger in case of error
  48309. */
  48310. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48311. /**
  48312. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48313. * @param data contains the texture data
  48314. * @param texture defines the BabylonJS internal texture
  48315. * @param callback defines the method to call once ready to upload
  48316. */
  48317. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48318. }
  48319. }
  48320. declare module "babylonjs/Helpers/sceneHelpers" {
  48321. import { Nullable } from "babylonjs/types";
  48322. import { Mesh } from "babylonjs/Meshes/mesh";
  48323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48324. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48325. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48326. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48327. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48328. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48329. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48330. import "babylonjs/Meshes/Builders/boxBuilder";
  48331. /** @hidden */
  48332. export var _forceSceneHelpersToBundle: boolean;
  48333. module "babylonjs/scene" {
  48334. interface Scene {
  48335. /**
  48336. * Creates a default light for the scene.
  48337. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48338. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48339. */
  48340. createDefaultLight(replace?: boolean): void;
  48341. /**
  48342. * Creates a default camera for the scene.
  48343. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48344. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48345. * @param replace has default false, when true replaces the active camera in the scene
  48346. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48347. */
  48348. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48349. /**
  48350. * Creates a default camera and a default light.
  48351. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48352. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48353. * @param replace has the default false, when true replaces the active camera/light in the scene
  48354. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48355. */
  48356. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48357. /**
  48358. * Creates a new sky box
  48359. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48360. * @param environmentTexture defines the texture to use as environment texture
  48361. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48362. * @param scale defines the overall scale of the skybox
  48363. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48364. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48365. * @returns a new mesh holding the sky box
  48366. */
  48367. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48368. /**
  48369. * Creates a new environment
  48370. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48371. * @param options defines the options you can use to configure the environment
  48372. * @returns the new EnvironmentHelper
  48373. */
  48374. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48375. /**
  48376. * Creates a new VREXperienceHelper
  48377. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48378. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48379. * @returns a new VREXperienceHelper
  48380. */
  48381. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48382. /**
  48383. * Creates a new XREXperienceHelper
  48384. * @see http://doc.babylonjs.com/how_to/webxr
  48385. * @returns a promise for a new XREXperienceHelper
  48386. */
  48387. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48388. }
  48389. }
  48390. }
  48391. declare module "babylonjs/Helpers/videoDome" {
  48392. import { Scene } from "babylonjs/scene";
  48393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48394. import { Mesh } from "babylonjs/Meshes/mesh";
  48395. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48396. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48397. import "babylonjs/Meshes/Builders/sphereBuilder";
  48398. /**
  48399. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48400. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48401. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48402. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48403. */
  48404. export class VideoDome extends TransformNode {
  48405. /**
  48406. * Define the video source as a Monoscopic panoramic 360 video.
  48407. */
  48408. static readonly MODE_MONOSCOPIC: number;
  48409. /**
  48410. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48411. */
  48412. static readonly MODE_TOPBOTTOM: number;
  48413. /**
  48414. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48415. */
  48416. static readonly MODE_SIDEBYSIDE: number;
  48417. private _useDirectMapping;
  48418. /**
  48419. * The video texture being displayed on the sphere
  48420. */
  48421. protected _videoTexture: VideoTexture;
  48422. /**
  48423. * Gets the video texture being displayed on the sphere
  48424. */
  48425. readonly videoTexture: VideoTexture;
  48426. /**
  48427. * The skybox material
  48428. */
  48429. protected _material: BackgroundMaterial;
  48430. /**
  48431. * The surface used for the skybox
  48432. */
  48433. protected _mesh: Mesh;
  48434. /**
  48435. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48436. * Also see the options.resolution property.
  48437. */
  48438. fovMultiplier: number;
  48439. private _videoMode;
  48440. /**
  48441. * Gets or set the current video mode for the video. It can be:
  48442. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48443. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48444. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48445. */
  48446. videoMode: number;
  48447. /**
  48448. * Oberserver used in Stereoscopic VR Mode.
  48449. */
  48450. private _onBeforeCameraRenderObserver;
  48451. /**
  48452. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48453. * @param name Element's name, child elements will append suffixes for their own names.
  48454. * @param urlsOrVideo defines the url(s) or the video element to use
  48455. * @param options An object containing optional or exposed sub element properties
  48456. */
  48457. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48458. resolution?: number;
  48459. clickToPlay?: boolean;
  48460. autoPlay?: boolean;
  48461. loop?: boolean;
  48462. size?: number;
  48463. poster?: string;
  48464. faceForward?: boolean;
  48465. useDirectMapping?: boolean;
  48466. }, scene: Scene);
  48467. private _changeVideoMode;
  48468. /**
  48469. * Releases resources associated with this node.
  48470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48472. */
  48473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Helpers/index" {
  48477. export * from "babylonjs/Helpers/environmentHelper";
  48478. export * from "babylonjs/Helpers/photoDome";
  48479. export * from "babylonjs/Helpers/sceneHelpers";
  48480. export * from "babylonjs/Helpers/videoDome";
  48481. }
  48482. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48483. import { PerfCounter } from "babylonjs/Misc/tools";
  48484. import { IDisposable } from "babylonjs/scene";
  48485. import { Engine } from "babylonjs/Engines/engine";
  48486. /**
  48487. * This class can be used to get instrumentation data from a Babylon engine
  48488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48489. */
  48490. export class EngineInstrumentation implements IDisposable {
  48491. /**
  48492. * Define the instrumented engine.
  48493. */
  48494. engine: Engine;
  48495. private _captureGPUFrameTime;
  48496. private _gpuFrameTimeToken;
  48497. private _gpuFrameTime;
  48498. private _captureShaderCompilationTime;
  48499. private _shaderCompilationTime;
  48500. private _onBeginFrameObserver;
  48501. private _onEndFrameObserver;
  48502. private _onBeforeShaderCompilationObserver;
  48503. private _onAfterShaderCompilationObserver;
  48504. /**
  48505. * Gets the perf counter used for GPU frame time
  48506. */
  48507. readonly gpuFrameTimeCounter: PerfCounter;
  48508. /**
  48509. * Gets the GPU frame time capture status
  48510. */
  48511. /**
  48512. * Enable or disable the GPU frame time capture
  48513. */
  48514. captureGPUFrameTime: boolean;
  48515. /**
  48516. * Gets the perf counter used for shader compilation time
  48517. */
  48518. readonly shaderCompilationTimeCounter: PerfCounter;
  48519. /**
  48520. * Gets the shader compilation time capture status
  48521. */
  48522. /**
  48523. * Enable or disable the shader compilation time capture
  48524. */
  48525. captureShaderCompilationTime: boolean;
  48526. /**
  48527. * Instantiates a new engine instrumentation.
  48528. * This class can be used to get instrumentation data from a Babylon engine
  48529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48530. * @param engine Defines the engine to instrument
  48531. */
  48532. constructor(
  48533. /**
  48534. * Define the instrumented engine.
  48535. */
  48536. engine: Engine);
  48537. /**
  48538. * Dispose and release associated resources.
  48539. */
  48540. dispose(): void;
  48541. }
  48542. }
  48543. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48544. import { PerfCounter } from "babylonjs/Misc/tools";
  48545. import { Scene, IDisposable } from "babylonjs/scene";
  48546. /**
  48547. * This class can be used to get instrumentation data from a Babylon engine
  48548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48549. */
  48550. export class SceneInstrumentation implements IDisposable {
  48551. /**
  48552. * Defines the scene to instrument
  48553. */
  48554. scene: Scene;
  48555. private _captureActiveMeshesEvaluationTime;
  48556. private _activeMeshesEvaluationTime;
  48557. private _captureRenderTargetsRenderTime;
  48558. private _renderTargetsRenderTime;
  48559. private _captureFrameTime;
  48560. private _frameTime;
  48561. private _captureRenderTime;
  48562. private _renderTime;
  48563. private _captureInterFrameTime;
  48564. private _interFrameTime;
  48565. private _captureParticlesRenderTime;
  48566. private _particlesRenderTime;
  48567. private _captureSpritesRenderTime;
  48568. private _spritesRenderTime;
  48569. private _capturePhysicsTime;
  48570. private _physicsTime;
  48571. private _captureAnimationsTime;
  48572. private _animationsTime;
  48573. private _captureCameraRenderTime;
  48574. private _cameraRenderTime;
  48575. private _onBeforeActiveMeshesEvaluationObserver;
  48576. private _onAfterActiveMeshesEvaluationObserver;
  48577. private _onBeforeRenderTargetsRenderObserver;
  48578. private _onAfterRenderTargetsRenderObserver;
  48579. private _onAfterRenderObserver;
  48580. private _onBeforeDrawPhaseObserver;
  48581. private _onAfterDrawPhaseObserver;
  48582. private _onBeforeAnimationsObserver;
  48583. private _onBeforeParticlesRenderingObserver;
  48584. private _onAfterParticlesRenderingObserver;
  48585. private _onBeforeSpritesRenderingObserver;
  48586. private _onAfterSpritesRenderingObserver;
  48587. private _onBeforePhysicsObserver;
  48588. private _onAfterPhysicsObserver;
  48589. private _onAfterAnimationsObserver;
  48590. private _onBeforeCameraRenderObserver;
  48591. private _onAfterCameraRenderObserver;
  48592. /**
  48593. * Gets the perf counter used for active meshes evaluation time
  48594. */
  48595. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48596. /**
  48597. * Gets the active meshes evaluation time capture status
  48598. */
  48599. /**
  48600. * Enable or disable the active meshes evaluation time capture
  48601. */
  48602. captureActiveMeshesEvaluationTime: boolean;
  48603. /**
  48604. * Gets the perf counter used for render targets render time
  48605. */
  48606. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48607. /**
  48608. * Gets the render targets render time capture status
  48609. */
  48610. /**
  48611. * Enable or disable the render targets render time capture
  48612. */
  48613. captureRenderTargetsRenderTime: boolean;
  48614. /**
  48615. * Gets the perf counter used for particles render time
  48616. */
  48617. readonly particlesRenderTimeCounter: PerfCounter;
  48618. /**
  48619. * Gets the particles render time capture status
  48620. */
  48621. /**
  48622. * Enable or disable the particles render time capture
  48623. */
  48624. captureParticlesRenderTime: boolean;
  48625. /**
  48626. * Gets the perf counter used for sprites render time
  48627. */
  48628. readonly spritesRenderTimeCounter: PerfCounter;
  48629. /**
  48630. * Gets the sprites render time capture status
  48631. */
  48632. /**
  48633. * Enable or disable the sprites render time capture
  48634. */
  48635. captureSpritesRenderTime: boolean;
  48636. /**
  48637. * Gets the perf counter used for physics time
  48638. */
  48639. readonly physicsTimeCounter: PerfCounter;
  48640. /**
  48641. * Gets the physics time capture status
  48642. */
  48643. /**
  48644. * Enable or disable the physics time capture
  48645. */
  48646. capturePhysicsTime: boolean;
  48647. /**
  48648. * Gets the perf counter used for animations time
  48649. */
  48650. readonly animationsTimeCounter: PerfCounter;
  48651. /**
  48652. * Gets the animations time capture status
  48653. */
  48654. /**
  48655. * Enable or disable the animations time capture
  48656. */
  48657. captureAnimationsTime: boolean;
  48658. /**
  48659. * Gets the perf counter used for frame time capture
  48660. */
  48661. readonly frameTimeCounter: PerfCounter;
  48662. /**
  48663. * Gets the frame time capture status
  48664. */
  48665. /**
  48666. * Enable or disable the frame time capture
  48667. */
  48668. captureFrameTime: boolean;
  48669. /**
  48670. * Gets the perf counter used for inter-frames time capture
  48671. */
  48672. readonly interFrameTimeCounter: PerfCounter;
  48673. /**
  48674. * Gets the inter-frames time capture status
  48675. */
  48676. /**
  48677. * Enable or disable the inter-frames time capture
  48678. */
  48679. captureInterFrameTime: boolean;
  48680. /**
  48681. * Gets the perf counter used for render time capture
  48682. */
  48683. readonly renderTimeCounter: PerfCounter;
  48684. /**
  48685. * Gets the render time capture status
  48686. */
  48687. /**
  48688. * Enable or disable the render time capture
  48689. */
  48690. captureRenderTime: boolean;
  48691. /**
  48692. * Gets the perf counter used for camera render time capture
  48693. */
  48694. readonly cameraRenderTimeCounter: PerfCounter;
  48695. /**
  48696. * Gets the camera render time capture status
  48697. */
  48698. /**
  48699. * Enable or disable the camera render time capture
  48700. */
  48701. captureCameraRenderTime: boolean;
  48702. /**
  48703. * Gets the perf counter used for draw calls
  48704. */
  48705. readonly drawCallsCounter: PerfCounter;
  48706. /**
  48707. * Instantiates a new scene instrumentation.
  48708. * This class can be used to get instrumentation data from a Babylon engine
  48709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48710. * @param scene Defines the scene to instrument
  48711. */
  48712. constructor(
  48713. /**
  48714. * Defines the scene to instrument
  48715. */
  48716. scene: Scene);
  48717. /**
  48718. * Dispose and release associated resources.
  48719. */
  48720. dispose(): void;
  48721. }
  48722. }
  48723. declare module "babylonjs/Instrumentation/index" {
  48724. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48725. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48726. export * from "babylonjs/Instrumentation/timeToken";
  48727. }
  48728. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48729. /** @hidden */
  48730. export var glowMapGenerationPixelShader: {
  48731. name: string;
  48732. shader: string;
  48733. };
  48734. }
  48735. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48736. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48737. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48739. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48741. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48742. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48743. /** @hidden */
  48744. export var glowMapGenerationVertexShader: {
  48745. name: string;
  48746. shader: string;
  48747. };
  48748. }
  48749. declare module "babylonjs/Layers/effectLayer" {
  48750. import { Observable } from "babylonjs/Misc/observable";
  48751. import { Nullable } from "babylonjs/types";
  48752. import { Camera } from "babylonjs/Cameras/camera";
  48753. import { Scene } from "babylonjs/scene";
  48754. import { Color4, ISize } from "babylonjs/Maths/math";
  48755. import { Engine } from "babylonjs/Engines/engine";
  48756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48758. import { Mesh } from "babylonjs/Meshes/mesh";
  48759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48761. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48762. import { Effect } from "babylonjs/Materials/effect";
  48763. import { Material } from "babylonjs/Materials/material";
  48764. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48765. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48766. /**
  48767. * Effect layer options. This helps customizing the behaviour
  48768. * of the effect layer.
  48769. */
  48770. export interface IEffectLayerOptions {
  48771. /**
  48772. * Multiplication factor apply to the canvas size to compute the render target size
  48773. * used to generated the objects (the smaller the faster).
  48774. */
  48775. mainTextureRatio: number;
  48776. /**
  48777. * Enforces a fixed size texture to ensure effect stability across devices.
  48778. */
  48779. mainTextureFixedSize?: number;
  48780. /**
  48781. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48782. */
  48783. alphaBlendingMode: number;
  48784. /**
  48785. * The camera attached to the layer.
  48786. */
  48787. camera: Nullable<Camera>;
  48788. /**
  48789. * The rendering group to draw the layer in.
  48790. */
  48791. renderingGroupId: number;
  48792. }
  48793. /**
  48794. * The effect layer Helps adding post process effect blended with the main pass.
  48795. *
  48796. * This can be for instance use to generate glow or higlight effects on the scene.
  48797. *
  48798. * The effect layer class can not be used directly and is intented to inherited from to be
  48799. * customized per effects.
  48800. */
  48801. export abstract class EffectLayer {
  48802. private _vertexBuffers;
  48803. private _indexBuffer;
  48804. private _cachedDefines;
  48805. private _effectLayerMapGenerationEffect;
  48806. private _effectLayerOptions;
  48807. private _mergeEffect;
  48808. protected _scene: Scene;
  48809. protected _engine: Engine;
  48810. protected _maxSize: number;
  48811. protected _mainTextureDesiredSize: ISize;
  48812. protected _mainTexture: RenderTargetTexture;
  48813. protected _shouldRender: boolean;
  48814. protected _postProcesses: PostProcess[];
  48815. protected _textures: BaseTexture[];
  48816. protected _emissiveTextureAndColor: {
  48817. texture: Nullable<BaseTexture>;
  48818. color: Color4;
  48819. };
  48820. /**
  48821. * The name of the layer
  48822. */
  48823. name: string;
  48824. /**
  48825. * The clear color of the texture used to generate the glow map.
  48826. */
  48827. neutralColor: Color4;
  48828. /**
  48829. * Specifies wether the highlight layer is enabled or not.
  48830. */
  48831. isEnabled: boolean;
  48832. /**
  48833. * Gets the camera attached to the layer.
  48834. */
  48835. readonly camera: Nullable<Camera>;
  48836. /**
  48837. * Gets the rendering group id the layer should render in.
  48838. */
  48839. readonly renderingGroupId: number;
  48840. /**
  48841. * An event triggered when the effect layer has been disposed.
  48842. */
  48843. onDisposeObservable: Observable<EffectLayer>;
  48844. /**
  48845. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48846. */
  48847. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48848. /**
  48849. * An event triggered when the generated texture is being merged in the scene.
  48850. */
  48851. onBeforeComposeObservable: Observable<EffectLayer>;
  48852. /**
  48853. * An event triggered when the generated texture has been merged in the scene.
  48854. */
  48855. onAfterComposeObservable: Observable<EffectLayer>;
  48856. /**
  48857. * An event triggered when the efffect layer changes its size.
  48858. */
  48859. onSizeChangedObservable: Observable<EffectLayer>;
  48860. /** @hidden */
  48861. static _SceneComponentInitialization: (scene: Scene) => void;
  48862. /**
  48863. * Instantiates a new effect Layer and references it in the scene.
  48864. * @param name The name of the layer
  48865. * @param scene The scene to use the layer in
  48866. */
  48867. constructor(
  48868. /** The Friendly of the effect in the scene */
  48869. name: string, scene: Scene);
  48870. /**
  48871. * Get the effect name of the layer.
  48872. * @return The effect name
  48873. */
  48874. abstract getEffectName(): string;
  48875. /**
  48876. * Checks for the readiness of the element composing the layer.
  48877. * @param subMesh the mesh to check for
  48878. * @param useInstances specify wether or not to use instances to render the mesh
  48879. * @return true if ready otherwise, false
  48880. */
  48881. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48882. /**
  48883. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48884. * @returns true if the effect requires stencil during the main canvas render pass.
  48885. */
  48886. abstract needStencil(): boolean;
  48887. /**
  48888. * Create the merge effect. This is the shader use to blit the information back
  48889. * to the main canvas at the end of the scene rendering.
  48890. * @returns The effect containing the shader used to merge the effect on the main canvas
  48891. */
  48892. protected abstract _createMergeEffect(): Effect;
  48893. /**
  48894. * Creates the render target textures and post processes used in the effect layer.
  48895. */
  48896. protected abstract _createTextureAndPostProcesses(): void;
  48897. /**
  48898. * Implementation specific of rendering the generating effect on the main canvas.
  48899. * @param effect The effect used to render through
  48900. */
  48901. protected abstract _internalRender(effect: Effect): void;
  48902. /**
  48903. * Sets the required values for both the emissive texture and and the main color.
  48904. */
  48905. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48906. /**
  48907. * Free any resources and references associated to a mesh.
  48908. * Internal use
  48909. * @param mesh The mesh to free.
  48910. */
  48911. abstract _disposeMesh(mesh: Mesh): void;
  48912. /**
  48913. * Serializes this layer (Glow or Highlight for example)
  48914. * @returns a serialized layer object
  48915. */
  48916. abstract serialize?(): any;
  48917. /**
  48918. * Initializes the effect layer with the required options.
  48919. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48920. */
  48921. protected _init(options: Partial<IEffectLayerOptions>): void;
  48922. /**
  48923. * Generates the index buffer of the full screen quad blending to the main canvas.
  48924. */
  48925. private _generateIndexBuffer;
  48926. /**
  48927. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48928. */
  48929. private _generateVertexBuffer;
  48930. /**
  48931. * Sets the main texture desired size which is the closest power of two
  48932. * of the engine canvas size.
  48933. */
  48934. private _setMainTextureSize;
  48935. /**
  48936. * Creates the main texture for the effect layer.
  48937. */
  48938. protected _createMainTexture(): void;
  48939. /**
  48940. * Adds specific effects defines.
  48941. * @param defines The defines to add specifics to.
  48942. */
  48943. protected _addCustomEffectDefines(defines: string[]): void;
  48944. /**
  48945. * Checks for the readiness of the element composing the layer.
  48946. * @param subMesh the mesh to check for
  48947. * @param useInstances specify wether or not to use instances to render the mesh
  48948. * @param emissiveTexture the associated emissive texture used to generate the glow
  48949. * @return true if ready otherwise, false
  48950. */
  48951. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48952. /**
  48953. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48954. */
  48955. render(): void;
  48956. /**
  48957. * Determine if a given mesh will be used in the current effect.
  48958. * @param mesh mesh to test
  48959. * @returns true if the mesh will be used
  48960. */
  48961. hasMesh(mesh: AbstractMesh): boolean;
  48962. /**
  48963. * Returns true if the layer contains information to display, otherwise false.
  48964. * @returns true if the glow layer should be rendered
  48965. */
  48966. shouldRender(): boolean;
  48967. /**
  48968. * Returns true if the mesh should render, otherwise false.
  48969. * @param mesh The mesh to render
  48970. * @returns true if it should render otherwise false
  48971. */
  48972. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48973. /**
  48974. * Returns true if the mesh can be rendered, otherwise false.
  48975. * @param mesh The mesh to render
  48976. * @param material The material used on the mesh
  48977. * @returns true if it can be rendered otherwise false
  48978. */
  48979. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48980. /**
  48981. * Returns true if the mesh should render, otherwise false.
  48982. * @param mesh The mesh to render
  48983. * @returns true if it should render otherwise false
  48984. */
  48985. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48986. /**
  48987. * Renders the submesh passed in parameter to the generation map.
  48988. */
  48989. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48990. /**
  48991. * Rebuild the required buffers.
  48992. * @hidden Internal use only.
  48993. */
  48994. _rebuild(): void;
  48995. /**
  48996. * Dispose only the render target textures and post process.
  48997. */
  48998. private _disposeTextureAndPostProcesses;
  48999. /**
  49000. * Dispose the highlight layer and free resources.
  49001. */
  49002. dispose(): void;
  49003. /**
  49004. * Gets the class name of the effect layer
  49005. * @returns the string with the class name of the effect layer
  49006. */
  49007. getClassName(): string;
  49008. /**
  49009. * Creates an effect layer from parsed effect layer data
  49010. * @param parsedEffectLayer defines effect layer data
  49011. * @param scene defines the current scene
  49012. * @param rootUrl defines the root URL containing the effect layer information
  49013. * @returns a parsed effect Layer
  49014. */
  49015. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49016. }
  49017. }
  49018. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49019. import { Scene } from "babylonjs/scene";
  49020. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49021. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49022. import { AbstractScene } from "babylonjs/abstractScene";
  49023. module "babylonjs/abstractScene" {
  49024. interface AbstractScene {
  49025. /**
  49026. * The list of effect layers (highlights/glow) added to the scene
  49027. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49028. * @see http://doc.babylonjs.com/how_to/glow_layer
  49029. */
  49030. effectLayers: Array<EffectLayer>;
  49031. /**
  49032. * Removes the given effect layer from this scene.
  49033. * @param toRemove defines the effect layer to remove
  49034. * @returns the index of the removed effect layer
  49035. */
  49036. removeEffectLayer(toRemove: EffectLayer): number;
  49037. /**
  49038. * Adds the given effect layer to this scene
  49039. * @param newEffectLayer defines the effect layer to add
  49040. */
  49041. addEffectLayer(newEffectLayer: EffectLayer): void;
  49042. }
  49043. }
  49044. /**
  49045. * Defines the layer scene component responsible to manage any effect layers
  49046. * in a given scene.
  49047. */
  49048. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49049. /**
  49050. * The component name helpfull to identify the component in the list of scene components.
  49051. */
  49052. readonly name: string;
  49053. /**
  49054. * The scene the component belongs to.
  49055. */
  49056. scene: Scene;
  49057. private _engine;
  49058. private _renderEffects;
  49059. private _needStencil;
  49060. private _previousStencilState;
  49061. /**
  49062. * Creates a new instance of the component for the given scene
  49063. * @param scene Defines the scene to register the component in
  49064. */
  49065. constructor(scene: Scene);
  49066. /**
  49067. * Registers the component in a given scene
  49068. */
  49069. register(): void;
  49070. /**
  49071. * Rebuilds the elements related to this component in case of
  49072. * context lost for instance.
  49073. */
  49074. rebuild(): void;
  49075. /**
  49076. * Serializes the component data to the specified json object
  49077. * @param serializationObject The object to serialize to
  49078. */
  49079. serialize(serializationObject: any): void;
  49080. /**
  49081. * Adds all the element from the container to the scene
  49082. * @param container the container holding the elements
  49083. */
  49084. addFromContainer(container: AbstractScene): void;
  49085. /**
  49086. * Removes all the elements in the container from the scene
  49087. * @param container contains the elements to remove
  49088. * @param dispose if the removed element should be disposed (default: false)
  49089. */
  49090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49091. /**
  49092. * Disposes the component and the associated ressources.
  49093. */
  49094. dispose(): void;
  49095. private _isReadyForMesh;
  49096. private _renderMainTexture;
  49097. private _setStencil;
  49098. private _setStencilBack;
  49099. private _draw;
  49100. private _drawCamera;
  49101. private _drawRenderingGroup;
  49102. }
  49103. }
  49104. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49105. /** @hidden */
  49106. export var glowMapMergePixelShader: {
  49107. name: string;
  49108. shader: string;
  49109. };
  49110. }
  49111. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49112. /** @hidden */
  49113. export var glowMapMergeVertexShader: {
  49114. name: string;
  49115. shader: string;
  49116. };
  49117. }
  49118. declare module "babylonjs/Layers/glowLayer" {
  49119. import { Nullable } from "babylonjs/types";
  49120. import { Camera } from "babylonjs/Cameras/camera";
  49121. import { Scene } from "babylonjs/scene";
  49122. import { Color4 } from "babylonjs/Maths/math";
  49123. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49125. import { Mesh } from "babylonjs/Meshes/mesh";
  49126. import { Texture } from "babylonjs/Materials/Textures/texture";
  49127. import { Effect } from "babylonjs/Materials/effect";
  49128. import { Material } from "babylonjs/Materials/material";
  49129. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49130. import "babylonjs/Shaders/glowMapMerge.fragment";
  49131. import "babylonjs/Shaders/glowMapMerge.vertex";
  49132. import "babylonjs/Layers/effectLayerSceneComponent";
  49133. module "babylonjs/abstractScene" {
  49134. interface AbstractScene {
  49135. /**
  49136. * Return a the first highlight layer of the scene with a given name.
  49137. * @param name The name of the highlight layer to look for.
  49138. * @return The highlight layer if found otherwise null.
  49139. */
  49140. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49141. }
  49142. }
  49143. /**
  49144. * Glow layer options. This helps customizing the behaviour
  49145. * of the glow layer.
  49146. */
  49147. export interface IGlowLayerOptions {
  49148. /**
  49149. * Multiplication factor apply to the canvas size to compute the render target size
  49150. * used to generated the glowing objects (the smaller the faster).
  49151. */
  49152. mainTextureRatio: number;
  49153. /**
  49154. * Enforces a fixed size texture to ensure resize independant blur.
  49155. */
  49156. mainTextureFixedSize?: number;
  49157. /**
  49158. * How big is the kernel of the blur texture.
  49159. */
  49160. blurKernelSize: number;
  49161. /**
  49162. * The camera attached to the layer.
  49163. */
  49164. camera: Nullable<Camera>;
  49165. /**
  49166. * Enable MSAA by chosing the number of samples.
  49167. */
  49168. mainTextureSamples?: number;
  49169. /**
  49170. * The rendering group to draw the layer in.
  49171. */
  49172. renderingGroupId: number;
  49173. }
  49174. /**
  49175. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49176. *
  49177. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49178. * glowy meshes to your scene.
  49179. *
  49180. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49181. */
  49182. export class GlowLayer extends EffectLayer {
  49183. /**
  49184. * Effect Name of the layer.
  49185. */
  49186. static readonly EffectName: string;
  49187. /**
  49188. * The default blur kernel size used for the glow.
  49189. */
  49190. static DefaultBlurKernelSize: number;
  49191. /**
  49192. * The default texture size ratio used for the glow.
  49193. */
  49194. static DefaultTextureRatio: number;
  49195. /**
  49196. * Sets the kernel size of the blur.
  49197. */
  49198. /**
  49199. * Gets the kernel size of the blur.
  49200. */
  49201. blurKernelSize: number;
  49202. /**
  49203. * Sets the glow intensity.
  49204. */
  49205. /**
  49206. * Gets the glow intensity.
  49207. */
  49208. intensity: number;
  49209. private _options;
  49210. private _intensity;
  49211. private _horizontalBlurPostprocess1;
  49212. private _verticalBlurPostprocess1;
  49213. private _horizontalBlurPostprocess2;
  49214. private _verticalBlurPostprocess2;
  49215. private _blurTexture1;
  49216. private _blurTexture2;
  49217. private _postProcesses1;
  49218. private _postProcesses2;
  49219. private _includedOnlyMeshes;
  49220. private _excludedMeshes;
  49221. /**
  49222. * Callback used to let the user override the color selection on a per mesh basis
  49223. */
  49224. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49225. /**
  49226. * Callback used to let the user override the texture selection on a per mesh basis
  49227. */
  49228. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49229. /**
  49230. * Instantiates a new glow Layer and references it to the scene.
  49231. * @param name The name of the layer
  49232. * @param scene The scene to use the layer in
  49233. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49234. */
  49235. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49236. /**
  49237. * Get the effect name of the layer.
  49238. * @return The effect name
  49239. */
  49240. getEffectName(): string;
  49241. /**
  49242. * Create the merge effect. This is the shader use to blit the information back
  49243. * to the main canvas at the end of the scene rendering.
  49244. */
  49245. protected _createMergeEffect(): Effect;
  49246. /**
  49247. * Creates the render target textures and post processes used in the glow layer.
  49248. */
  49249. protected _createTextureAndPostProcesses(): void;
  49250. /**
  49251. * Checks for the readiness of the element composing the layer.
  49252. * @param subMesh the mesh to check for
  49253. * @param useInstances specify wether or not to use instances to render the mesh
  49254. * @param emissiveTexture the associated emissive texture used to generate the glow
  49255. * @return true if ready otherwise, false
  49256. */
  49257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49258. /**
  49259. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49260. */
  49261. needStencil(): boolean;
  49262. /**
  49263. * Returns true if the mesh can be rendered, otherwise false.
  49264. * @param mesh The mesh to render
  49265. * @param material The material used on the mesh
  49266. * @returns true if it can be rendered otherwise false
  49267. */
  49268. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49269. /**
  49270. * Implementation specific of rendering the generating effect on the main canvas.
  49271. * @param effect The effect used to render through
  49272. */
  49273. protected _internalRender(effect: Effect): void;
  49274. /**
  49275. * Sets the required values for both the emissive texture and and the main color.
  49276. */
  49277. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49278. /**
  49279. * Returns true if the mesh should render, otherwise false.
  49280. * @param mesh The mesh to render
  49281. * @returns true if it should render otherwise false
  49282. */
  49283. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49284. /**
  49285. * Adds specific effects defines.
  49286. * @param defines The defines to add specifics to.
  49287. */
  49288. protected _addCustomEffectDefines(defines: string[]): void;
  49289. /**
  49290. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49291. * @param mesh The mesh to exclude from the glow layer
  49292. */
  49293. addExcludedMesh(mesh: Mesh): void;
  49294. /**
  49295. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49296. * @param mesh The mesh to remove
  49297. */
  49298. removeExcludedMesh(mesh: Mesh): void;
  49299. /**
  49300. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49301. * @param mesh The mesh to include in the glow layer
  49302. */
  49303. addIncludedOnlyMesh(mesh: Mesh): void;
  49304. /**
  49305. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49306. * @param mesh The mesh to remove
  49307. */
  49308. removeIncludedOnlyMesh(mesh: Mesh): void;
  49309. /**
  49310. * Determine if a given mesh will be used in the glow layer
  49311. * @param mesh The mesh to test
  49312. * @returns true if the mesh will be highlighted by the current glow layer
  49313. */
  49314. hasMesh(mesh: AbstractMesh): boolean;
  49315. /**
  49316. * Free any resources and references associated to a mesh.
  49317. * Internal use
  49318. * @param mesh The mesh to free.
  49319. * @hidden
  49320. */
  49321. _disposeMesh(mesh: Mesh): void;
  49322. /**
  49323. * Gets the class name of the effect layer
  49324. * @returns the string with the class name of the effect layer
  49325. */
  49326. getClassName(): string;
  49327. /**
  49328. * Serializes this glow layer
  49329. * @returns a serialized glow layer object
  49330. */
  49331. serialize(): any;
  49332. /**
  49333. * Creates a Glow Layer from parsed glow layer data
  49334. * @param parsedGlowLayer defines glow layer data
  49335. * @param scene defines the current scene
  49336. * @param rootUrl defines the root URL containing the glow layer information
  49337. * @returns a parsed Glow Layer
  49338. */
  49339. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49340. }
  49341. }
  49342. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49343. /** @hidden */
  49344. export var glowBlurPostProcessPixelShader: {
  49345. name: string;
  49346. shader: string;
  49347. };
  49348. }
  49349. declare module "babylonjs/Layers/highlightLayer" {
  49350. import { Observable } from "babylonjs/Misc/observable";
  49351. import { Nullable } from "babylonjs/types";
  49352. import { Camera } from "babylonjs/Cameras/camera";
  49353. import { Scene } from "babylonjs/scene";
  49354. import { Color3, Color4 } from "babylonjs/Maths/math";
  49355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49357. import { Mesh } from "babylonjs/Meshes/mesh";
  49358. import { Effect } from "babylonjs/Materials/effect";
  49359. import { Material } from "babylonjs/Materials/material";
  49360. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49361. import "babylonjs/Shaders/glowMapMerge.fragment";
  49362. import "babylonjs/Shaders/glowMapMerge.vertex";
  49363. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49364. module "babylonjs/abstractScene" {
  49365. interface AbstractScene {
  49366. /**
  49367. * Return a the first highlight layer of the scene with a given name.
  49368. * @param name The name of the highlight layer to look for.
  49369. * @return The highlight layer if found otherwise null.
  49370. */
  49371. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49372. }
  49373. }
  49374. /**
  49375. * Highlight layer options. This helps customizing the behaviour
  49376. * of the highlight layer.
  49377. */
  49378. export interface IHighlightLayerOptions {
  49379. /**
  49380. * Multiplication factor apply to the canvas size to compute the render target size
  49381. * used to generated the glowing objects (the smaller the faster).
  49382. */
  49383. mainTextureRatio: number;
  49384. /**
  49385. * Enforces a fixed size texture to ensure resize independant blur.
  49386. */
  49387. mainTextureFixedSize?: number;
  49388. /**
  49389. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49390. * of the picture to blur (the smaller the faster).
  49391. */
  49392. blurTextureSizeRatio: number;
  49393. /**
  49394. * How big in texel of the blur texture is the vertical blur.
  49395. */
  49396. blurVerticalSize: number;
  49397. /**
  49398. * How big in texel of the blur texture is the horizontal blur.
  49399. */
  49400. blurHorizontalSize: number;
  49401. /**
  49402. * Alpha blending mode used to apply the blur. Default is combine.
  49403. */
  49404. alphaBlendingMode: number;
  49405. /**
  49406. * The camera attached to the layer.
  49407. */
  49408. camera: Nullable<Camera>;
  49409. /**
  49410. * Should we display highlight as a solid stroke?
  49411. */
  49412. isStroke?: boolean;
  49413. /**
  49414. * The rendering group to draw the layer in.
  49415. */
  49416. renderingGroupId: number;
  49417. }
  49418. /**
  49419. * The highlight layer Helps adding a glow effect around a mesh.
  49420. *
  49421. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49422. * glowy meshes to your scene.
  49423. *
  49424. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49425. */
  49426. export class HighlightLayer extends EffectLayer {
  49427. name: string;
  49428. /**
  49429. * Effect Name of the highlight layer.
  49430. */
  49431. static readonly EffectName: string;
  49432. /**
  49433. * The neutral color used during the preparation of the glow effect.
  49434. * This is black by default as the blend operation is a blend operation.
  49435. */
  49436. static NeutralColor: Color4;
  49437. /**
  49438. * Stencil value used for glowing meshes.
  49439. */
  49440. static GlowingMeshStencilReference: number;
  49441. /**
  49442. * Stencil value used for the other meshes in the scene.
  49443. */
  49444. static NormalMeshStencilReference: number;
  49445. /**
  49446. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49447. */
  49448. innerGlow: boolean;
  49449. /**
  49450. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49451. */
  49452. outerGlow: boolean;
  49453. /**
  49454. * Specifies the horizontal size of the blur.
  49455. */
  49456. /**
  49457. * Gets the horizontal size of the blur.
  49458. */
  49459. blurHorizontalSize: number;
  49460. /**
  49461. * Specifies the vertical size of the blur.
  49462. */
  49463. /**
  49464. * Gets the vertical size of the blur.
  49465. */
  49466. blurVerticalSize: number;
  49467. /**
  49468. * An event triggered when the highlight layer is being blurred.
  49469. */
  49470. onBeforeBlurObservable: Observable<HighlightLayer>;
  49471. /**
  49472. * An event triggered when the highlight layer has been blurred.
  49473. */
  49474. onAfterBlurObservable: Observable<HighlightLayer>;
  49475. private _instanceGlowingMeshStencilReference;
  49476. private _options;
  49477. private _downSamplePostprocess;
  49478. private _horizontalBlurPostprocess;
  49479. private _verticalBlurPostprocess;
  49480. private _blurTexture;
  49481. private _meshes;
  49482. private _excludedMeshes;
  49483. /**
  49484. * Instantiates a new highlight Layer and references it to the scene..
  49485. * @param name The name of the layer
  49486. * @param scene The scene to use the layer in
  49487. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49488. */
  49489. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49490. /**
  49491. * Get the effect name of the layer.
  49492. * @return The effect name
  49493. */
  49494. getEffectName(): string;
  49495. /**
  49496. * Create the merge effect. This is the shader use to blit the information back
  49497. * to the main canvas at the end of the scene rendering.
  49498. */
  49499. protected _createMergeEffect(): Effect;
  49500. /**
  49501. * Creates the render target textures and post processes used in the highlight layer.
  49502. */
  49503. protected _createTextureAndPostProcesses(): void;
  49504. /**
  49505. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49506. */
  49507. needStencil(): boolean;
  49508. /**
  49509. * Checks for the readiness of the element composing the layer.
  49510. * @param subMesh the mesh to check for
  49511. * @param useInstances specify wether or not to use instances to render the mesh
  49512. * @param emissiveTexture the associated emissive texture used to generate the glow
  49513. * @return true if ready otherwise, false
  49514. */
  49515. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49516. /**
  49517. * Implementation specific of rendering the generating effect on the main canvas.
  49518. * @param effect The effect used to render through
  49519. */
  49520. protected _internalRender(effect: Effect): void;
  49521. /**
  49522. * Returns true if the layer contains information to display, otherwise false.
  49523. */
  49524. shouldRender(): boolean;
  49525. /**
  49526. * Returns true if the mesh should render, otherwise false.
  49527. * @param mesh The mesh to render
  49528. * @returns true if it should render otherwise false
  49529. */
  49530. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49531. /**
  49532. * Sets the required values for both the emissive texture and and the main color.
  49533. */
  49534. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49535. /**
  49536. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49537. * @param mesh The mesh to exclude from the highlight layer
  49538. */
  49539. addExcludedMesh(mesh: Mesh): void;
  49540. /**
  49541. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49542. * @param mesh The mesh to highlight
  49543. */
  49544. removeExcludedMesh(mesh: Mesh): void;
  49545. /**
  49546. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49547. * @param mesh mesh to test
  49548. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49549. */
  49550. hasMesh(mesh: AbstractMesh): boolean;
  49551. /**
  49552. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49553. * @param mesh The mesh to highlight
  49554. * @param color The color of the highlight
  49555. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49556. */
  49557. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49558. /**
  49559. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49560. * @param mesh The mesh to highlight
  49561. */
  49562. removeMesh(mesh: Mesh): void;
  49563. /**
  49564. * Force the stencil to the normal expected value for none glowing parts
  49565. */
  49566. private _defaultStencilReference;
  49567. /**
  49568. * Free any resources and references associated to a mesh.
  49569. * Internal use
  49570. * @param mesh The mesh to free.
  49571. * @hidden
  49572. */
  49573. _disposeMesh(mesh: Mesh): void;
  49574. /**
  49575. * Dispose the highlight layer and free resources.
  49576. */
  49577. dispose(): void;
  49578. /**
  49579. * Gets the class name of the effect layer
  49580. * @returns the string with the class name of the effect layer
  49581. */
  49582. getClassName(): string;
  49583. /**
  49584. * Serializes this Highlight layer
  49585. * @returns a serialized Highlight layer object
  49586. */
  49587. serialize(): any;
  49588. /**
  49589. * Creates a Highlight layer from parsed Highlight layer data
  49590. * @param parsedHightlightLayer defines the Highlight layer data
  49591. * @param scene defines the current scene
  49592. * @param rootUrl defines the root URL containing the Highlight layer information
  49593. * @returns a parsed Highlight layer
  49594. */
  49595. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49596. }
  49597. }
  49598. declare module "babylonjs/Layers/index" {
  49599. export * from "babylonjs/Layers/effectLayer";
  49600. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49601. export * from "babylonjs/Layers/glowLayer";
  49602. export * from "babylonjs/Layers/highlightLayer";
  49603. export * from "babylonjs/Layers/layer";
  49604. export * from "babylonjs/Layers/layerSceneComponent";
  49605. }
  49606. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49607. /** @hidden */
  49608. export var lensFlarePixelShader: {
  49609. name: string;
  49610. shader: string;
  49611. };
  49612. }
  49613. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49614. /** @hidden */
  49615. export var lensFlareVertexShader: {
  49616. name: string;
  49617. shader: string;
  49618. };
  49619. }
  49620. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49621. import { Scene } from "babylonjs/scene";
  49622. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49624. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49625. import "babylonjs/Shaders/lensFlare.fragment";
  49626. import "babylonjs/Shaders/lensFlare.vertex";
  49627. /**
  49628. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49629. * It is usually composed of several `lensFlare`.
  49630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49631. */
  49632. export class LensFlareSystem {
  49633. /**
  49634. * Define the name of the lens flare system
  49635. */
  49636. name: string;
  49637. /**
  49638. * List of lens flares used in this system.
  49639. */
  49640. lensFlares: LensFlare[];
  49641. /**
  49642. * Define a limit from the border the lens flare can be visible.
  49643. */
  49644. borderLimit: number;
  49645. /**
  49646. * Define a viewport border we do not want to see the lens flare in.
  49647. */
  49648. viewportBorder: number;
  49649. /**
  49650. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49651. */
  49652. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49653. /**
  49654. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49655. */
  49656. layerMask: number;
  49657. /**
  49658. * Define the id of the lens flare system in the scene.
  49659. * (equal to name by default)
  49660. */
  49661. id: string;
  49662. private _scene;
  49663. private _emitter;
  49664. private _vertexBuffers;
  49665. private _indexBuffer;
  49666. private _effect;
  49667. private _positionX;
  49668. private _positionY;
  49669. private _isEnabled;
  49670. /** @hidden */
  49671. static _SceneComponentInitialization: (scene: Scene) => void;
  49672. /**
  49673. * Instantiates a lens flare system.
  49674. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49675. * It is usually composed of several `lensFlare`.
  49676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49677. * @param name Define the name of the lens flare system in the scene
  49678. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49679. * @param scene Define the scene the lens flare system belongs to
  49680. */
  49681. constructor(
  49682. /**
  49683. * Define the name of the lens flare system
  49684. */
  49685. name: string, emitter: any, scene: Scene);
  49686. /**
  49687. * Define if the lens flare system is enabled.
  49688. */
  49689. isEnabled: boolean;
  49690. /**
  49691. * Get the scene the effects belongs to.
  49692. * @returns the scene holding the lens flare system
  49693. */
  49694. getScene(): Scene;
  49695. /**
  49696. * Get the emitter of the lens flare system.
  49697. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49698. * @returns the emitter of the lens flare system
  49699. */
  49700. getEmitter(): any;
  49701. /**
  49702. * Set the emitter of the lens flare system.
  49703. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49704. * @param newEmitter Define the new emitter of the system
  49705. */
  49706. setEmitter(newEmitter: any): void;
  49707. /**
  49708. * Get the lens flare system emitter position.
  49709. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49710. * @returns the position
  49711. */
  49712. getEmitterPosition(): Vector3;
  49713. /**
  49714. * @hidden
  49715. */
  49716. computeEffectivePosition(globalViewport: Viewport): boolean;
  49717. /** @hidden */
  49718. _isVisible(): boolean;
  49719. /**
  49720. * @hidden
  49721. */
  49722. render(): boolean;
  49723. /**
  49724. * Dispose and release the lens flare with its associated resources.
  49725. */
  49726. dispose(): void;
  49727. /**
  49728. * Parse a lens flare system from a JSON repressentation
  49729. * @param parsedLensFlareSystem Define the JSON to parse
  49730. * @param scene Define the scene the parsed system should be instantiated in
  49731. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49732. * @returns the parsed system
  49733. */
  49734. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49735. /**
  49736. * Serialize the current Lens Flare System into a JSON representation.
  49737. * @returns the serialized JSON
  49738. */
  49739. serialize(): any;
  49740. }
  49741. }
  49742. declare module "babylonjs/LensFlares/lensFlare" {
  49743. import { Nullable } from "babylonjs/types";
  49744. import { Color3 } from "babylonjs/Maths/math";
  49745. import { Texture } from "babylonjs/Materials/Textures/texture";
  49746. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49747. /**
  49748. * This represents one of the lens effect in a `lensFlareSystem`.
  49749. * It controls one of the indiviual texture used in the effect.
  49750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49751. */
  49752. export class LensFlare {
  49753. /**
  49754. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49755. */
  49756. size: number;
  49757. /**
  49758. * 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.
  49759. */
  49760. position: number;
  49761. /**
  49762. * Define the lens color.
  49763. */
  49764. color: Color3;
  49765. /**
  49766. * Define the lens texture.
  49767. */
  49768. texture: Nullable<Texture>;
  49769. /**
  49770. * Define the alpha mode to render this particular lens.
  49771. */
  49772. alphaMode: number;
  49773. private _system;
  49774. /**
  49775. * Creates a new Lens Flare.
  49776. * This represents one of the lens effect in a `lensFlareSystem`.
  49777. * It controls one of the indiviual texture used in the effect.
  49778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49779. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49780. * @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.
  49781. * @param color Define the lens color
  49782. * @param imgUrl Define the lens texture url
  49783. * @param system Define the `lensFlareSystem` this flare is part of
  49784. * @returns The newly created Lens Flare
  49785. */
  49786. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49787. /**
  49788. * Instantiates a new Lens Flare.
  49789. * This represents one of the lens effect in a `lensFlareSystem`.
  49790. * It controls one of the indiviual texture used in the effect.
  49791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49792. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49793. * @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.
  49794. * @param color Define the lens color
  49795. * @param imgUrl Define the lens texture url
  49796. * @param system Define the `lensFlareSystem` this flare is part of
  49797. */
  49798. constructor(
  49799. /**
  49800. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49801. */
  49802. size: number,
  49803. /**
  49804. * 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.
  49805. */
  49806. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49807. /**
  49808. * Dispose and release the lens flare with its associated resources.
  49809. */
  49810. dispose(): void;
  49811. }
  49812. }
  49813. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49814. import { Nullable } from "babylonjs/types";
  49815. import { Scene } from "babylonjs/scene";
  49816. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49817. import { AbstractScene } from "babylonjs/abstractScene";
  49818. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49819. module "babylonjs/abstractScene" {
  49820. interface AbstractScene {
  49821. /**
  49822. * The list of lens flare system added to the scene
  49823. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49824. */
  49825. lensFlareSystems: Array<LensFlareSystem>;
  49826. /**
  49827. * Removes the given lens flare system from this scene.
  49828. * @param toRemove The lens flare system to remove
  49829. * @returns The index of the removed lens flare system
  49830. */
  49831. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49832. /**
  49833. * Adds the given lens flare system to this scene
  49834. * @param newLensFlareSystem The lens flare system to add
  49835. */
  49836. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49837. /**
  49838. * Gets a lens flare system using its name
  49839. * @param name defines the name to look for
  49840. * @returns the lens flare system or null if not found
  49841. */
  49842. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49843. /**
  49844. * Gets a lens flare system using its id
  49845. * @param id defines the id to look for
  49846. * @returns the lens flare system or null if not found
  49847. */
  49848. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49849. }
  49850. }
  49851. /**
  49852. * Defines the lens flare scene component responsible to manage any lens flares
  49853. * in a given scene.
  49854. */
  49855. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49856. /**
  49857. * The component name helpfull to identify the component in the list of scene components.
  49858. */
  49859. readonly name: string;
  49860. /**
  49861. * The scene the component belongs to.
  49862. */
  49863. scene: Scene;
  49864. /**
  49865. * Creates a new instance of the component for the given scene
  49866. * @param scene Defines the scene to register the component in
  49867. */
  49868. constructor(scene: Scene);
  49869. /**
  49870. * Registers the component in a given scene
  49871. */
  49872. register(): void;
  49873. /**
  49874. * Rebuilds the elements related to this component in case of
  49875. * context lost for instance.
  49876. */
  49877. rebuild(): void;
  49878. /**
  49879. * Adds all the element from the container to the scene
  49880. * @param container the container holding the elements
  49881. */
  49882. addFromContainer(container: AbstractScene): void;
  49883. /**
  49884. * Removes all the elements in the container from the scene
  49885. * @param container contains the elements to remove
  49886. * @param dispose if the removed element should be disposed (default: false)
  49887. */
  49888. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49889. /**
  49890. * Serializes the component data to the specified json object
  49891. * @param serializationObject The object to serialize to
  49892. */
  49893. serialize(serializationObject: any): void;
  49894. /**
  49895. * Disposes the component and the associated ressources.
  49896. */
  49897. dispose(): void;
  49898. private _draw;
  49899. }
  49900. }
  49901. declare module "babylonjs/LensFlares/index" {
  49902. export * from "babylonjs/LensFlares/lensFlare";
  49903. export * from "babylonjs/LensFlares/lensFlareSystem";
  49904. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49905. }
  49906. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49907. import { Scene } from "babylonjs/scene";
  49908. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49909. import { AbstractScene } from "babylonjs/abstractScene";
  49910. /**
  49911. * Defines the shadow generator component responsible to manage any shadow generators
  49912. * in a given scene.
  49913. */
  49914. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49915. /**
  49916. * The component name helpfull to identify the component in the list of scene components.
  49917. */
  49918. readonly name: string;
  49919. /**
  49920. * The scene the component belongs to.
  49921. */
  49922. scene: Scene;
  49923. /**
  49924. * Creates a new instance of the component for the given scene
  49925. * @param scene Defines the scene to register the component in
  49926. */
  49927. constructor(scene: Scene);
  49928. /**
  49929. * Registers the component in a given scene
  49930. */
  49931. register(): void;
  49932. /**
  49933. * Rebuilds the elements related to this component in case of
  49934. * context lost for instance.
  49935. */
  49936. rebuild(): void;
  49937. /**
  49938. * Serializes the component data to the specified json object
  49939. * @param serializationObject The object to serialize to
  49940. */
  49941. serialize(serializationObject: any): void;
  49942. /**
  49943. * Adds all the element from the container to the scene
  49944. * @param container the container holding the elements
  49945. */
  49946. addFromContainer(container: AbstractScene): void;
  49947. /**
  49948. * Removes all the elements in the container from the scene
  49949. * @param container contains the elements to remove
  49950. * @param dispose if the removed element should be disposed (default: false)
  49951. */
  49952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49953. /**
  49954. * Rebuilds the elements related to this component in case of
  49955. * context lost for instance.
  49956. */
  49957. dispose(): void;
  49958. private _gatherRenderTargets;
  49959. }
  49960. }
  49961. declare module "babylonjs/Lights/Shadows/index" {
  49962. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49963. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49964. }
  49965. declare module "babylonjs/Lights/pointLight" {
  49966. import { Scene } from "babylonjs/scene";
  49967. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49969. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49970. import { Effect } from "babylonjs/Materials/effect";
  49971. /**
  49972. * A point light is a light defined by an unique point in world space.
  49973. * The light is emitted in every direction from this point.
  49974. * A good example of a point light is a standard light bulb.
  49975. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49976. */
  49977. export class PointLight extends ShadowLight {
  49978. private _shadowAngle;
  49979. /**
  49980. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49981. * This specifies what angle the shadow will use to be created.
  49982. *
  49983. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49984. */
  49985. /**
  49986. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49987. * This specifies what angle the shadow will use to be created.
  49988. *
  49989. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49990. */
  49991. shadowAngle: number;
  49992. /**
  49993. * Gets the direction if it has been set.
  49994. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49995. */
  49996. /**
  49997. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49998. */
  49999. direction: Vector3;
  50000. /**
  50001. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50002. * A PointLight emits the light in every direction.
  50003. * It can cast shadows.
  50004. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50005. * ```javascript
  50006. * var pointLight = new PointLight("pl", camera.position, scene);
  50007. * ```
  50008. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50009. * @param name The light friendly name
  50010. * @param position The position of the point light in the scene
  50011. * @param scene The scene the lights belongs to
  50012. */
  50013. constructor(name: string, position: Vector3, scene: Scene);
  50014. /**
  50015. * Returns the string "PointLight"
  50016. * @returns the class name
  50017. */
  50018. getClassName(): string;
  50019. /**
  50020. * Returns the integer 0.
  50021. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50022. */
  50023. getTypeID(): number;
  50024. /**
  50025. * Specifies wether or not the shadowmap should be a cube texture.
  50026. * @returns true if the shadowmap needs to be a cube texture.
  50027. */
  50028. needCube(): boolean;
  50029. /**
  50030. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50033. */
  50034. getShadowDirection(faceIndex?: number): Vector3;
  50035. /**
  50036. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50037. * - fov = PI / 2
  50038. * - aspect ratio : 1.0
  50039. * - z-near and far equal to the active camera minZ and maxZ.
  50040. * Returns the PointLight.
  50041. */
  50042. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50043. protected _buildUniformLayout(): void;
  50044. /**
  50045. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50046. * @param effect The effect to update
  50047. * @param lightIndex The index of the light in the effect to update
  50048. * @returns The point light
  50049. */
  50050. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50051. /**
  50052. * Prepares the list of defines specific to the light type.
  50053. * @param defines the list of defines
  50054. * @param lightIndex defines the index of the light for the effect
  50055. */
  50056. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50057. }
  50058. }
  50059. declare module "babylonjs/Lights/index" {
  50060. export * from "babylonjs/Lights/light";
  50061. export * from "babylonjs/Lights/shadowLight";
  50062. export * from "babylonjs/Lights/Shadows/index";
  50063. export * from "babylonjs/Lights/directionalLight";
  50064. export * from "babylonjs/Lights/hemisphericLight";
  50065. export * from "babylonjs/Lights/pointLight";
  50066. export * from "babylonjs/Lights/spotLight";
  50067. }
  50068. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50069. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50070. /**
  50071. * Header information of HDR texture files.
  50072. */
  50073. export interface HDRInfo {
  50074. /**
  50075. * The height of the texture in pixels.
  50076. */
  50077. height: number;
  50078. /**
  50079. * The width of the texture in pixels.
  50080. */
  50081. width: number;
  50082. /**
  50083. * The index of the beginning of the data in the binary file.
  50084. */
  50085. dataPosition: number;
  50086. }
  50087. /**
  50088. * This groups tools to convert HDR texture to native colors array.
  50089. */
  50090. export class HDRTools {
  50091. private static Ldexp;
  50092. private static Rgbe2float;
  50093. private static readStringLine;
  50094. /**
  50095. * Reads header information from an RGBE texture stored in a native array.
  50096. * More information on this format are available here:
  50097. * https://en.wikipedia.org/wiki/RGBE_image_format
  50098. *
  50099. * @param uint8array The binary file stored in native array.
  50100. * @return The header information.
  50101. */
  50102. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50103. /**
  50104. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50105. * This RGBE texture needs to store the information as a panorama.
  50106. *
  50107. * More information on this format are available here:
  50108. * https://en.wikipedia.org/wiki/RGBE_image_format
  50109. *
  50110. * @param buffer The binary file stored in an array buffer.
  50111. * @param size The expected size of the extracted cubemap.
  50112. * @return The Cube Map information.
  50113. */
  50114. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50115. /**
  50116. * Returns the pixels data extracted from an RGBE texture.
  50117. * This pixels will be stored left to right up to down in the R G B order in one array.
  50118. *
  50119. * More information on this format are available here:
  50120. * https://en.wikipedia.org/wiki/RGBE_image_format
  50121. *
  50122. * @param uint8array The binary file stored in an array buffer.
  50123. * @param hdrInfo The header information of the file.
  50124. * @return The pixels data in RGB right to left up to down order.
  50125. */
  50126. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50127. private static RGBE_ReadPixels_RLE;
  50128. }
  50129. }
  50130. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50131. import { Nullable } from "babylonjs/types";
  50132. import { Scene } from "babylonjs/scene";
  50133. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50135. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50136. /**
  50137. * This represents a texture coming from an HDR input.
  50138. *
  50139. * The only supported format is currently panorama picture stored in RGBE format.
  50140. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50141. */
  50142. export class HDRCubeTexture extends BaseTexture {
  50143. private static _facesMapping;
  50144. private _generateHarmonics;
  50145. private _noMipmap;
  50146. private _textureMatrix;
  50147. private _size;
  50148. private _onLoad;
  50149. private _onError;
  50150. /**
  50151. * The texture URL.
  50152. */
  50153. url: string;
  50154. /**
  50155. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50156. */
  50157. coordinatesMode: number;
  50158. protected _isBlocking: boolean;
  50159. /**
  50160. * Sets wether or not the texture is blocking during loading.
  50161. */
  50162. /**
  50163. * Gets wether or not the texture is blocking during loading.
  50164. */
  50165. isBlocking: boolean;
  50166. protected _rotationY: number;
  50167. /**
  50168. * Sets texture matrix rotation angle around Y axis in radians.
  50169. */
  50170. /**
  50171. * Gets texture matrix rotation angle around Y axis radians.
  50172. */
  50173. rotationY: number;
  50174. /**
  50175. * Gets or sets the center of the bounding box associated with the cube texture
  50176. * It must define where the camera used to render the texture was set
  50177. */
  50178. boundingBoxPosition: Vector3;
  50179. private _boundingBoxSize;
  50180. /**
  50181. * Gets or sets the size of the bounding box associated with the cube texture
  50182. * When defined, the cubemap will switch to local mode
  50183. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50184. * @example https://www.babylonjs-playground.com/#RNASML
  50185. */
  50186. boundingBoxSize: Vector3;
  50187. /**
  50188. * Instantiates an HDRTexture from the following parameters.
  50189. *
  50190. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50191. * @param scene The scene the texture will be used in
  50192. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50193. * @param noMipmap Forces to not generate the mipmap if true
  50194. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50195. * @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)
  50196. * @param reserved Reserved flag for internal use.
  50197. */
  50198. 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>);
  50199. /**
  50200. * Get the current class name of the texture useful for serialization or dynamic coding.
  50201. * @returns "HDRCubeTexture"
  50202. */
  50203. getClassName(): string;
  50204. /**
  50205. * Occurs when the file is raw .hdr file.
  50206. */
  50207. private loadTexture;
  50208. clone(): HDRCubeTexture;
  50209. delayLoad(): void;
  50210. /**
  50211. * Get the texture reflection matrix used to rotate/transform the reflection.
  50212. * @returns the reflection matrix
  50213. */
  50214. getReflectionTextureMatrix(): Matrix;
  50215. /**
  50216. * Set the texture reflection matrix used to rotate/transform the reflection.
  50217. * @param value Define the reflection matrix to set
  50218. */
  50219. setReflectionTextureMatrix(value: Matrix): void;
  50220. /**
  50221. * Parses a JSON representation of an HDR Texture in order to create the texture
  50222. * @param parsedTexture Define the JSON representation
  50223. * @param scene Define the scene the texture should be created in
  50224. * @param rootUrl Define the root url in case we need to load relative dependencies
  50225. * @returns the newly created texture after parsing
  50226. */
  50227. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50228. serialize(): any;
  50229. }
  50230. }
  50231. declare module "babylonjs/Physics/physicsEngine" {
  50232. import { Nullable } from "babylonjs/types";
  50233. import { Vector3 } from "babylonjs/Maths/math";
  50234. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50235. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50236. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50237. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50238. /**
  50239. * Class used to control physics engine
  50240. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50241. */
  50242. export class PhysicsEngine implements IPhysicsEngine {
  50243. private _physicsPlugin;
  50244. /**
  50245. * Global value used to control the smallest number supported by the simulation
  50246. */
  50247. static Epsilon: number;
  50248. private _impostors;
  50249. private _joints;
  50250. /**
  50251. * Gets the gravity vector used by the simulation
  50252. */
  50253. gravity: Vector3;
  50254. /**
  50255. * Factory used to create the default physics plugin.
  50256. * @returns The default physics plugin
  50257. */
  50258. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50259. /**
  50260. * Creates a new Physics Engine
  50261. * @param gravity defines the gravity vector used by the simulation
  50262. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50263. */
  50264. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50265. /**
  50266. * Sets the gravity vector used by the simulation
  50267. * @param gravity defines the gravity vector to use
  50268. */
  50269. setGravity(gravity: Vector3): void;
  50270. /**
  50271. * Set the time step of the physics engine.
  50272. * Default is 1/60.
  50273. * To slow it down, enter 1/600 for example.
  50274. * To speed it up, 1/30
  50275. * @param newTimeStep defines the new timestep to apply to this world.
  50276. */
  50277. setTimeStep(newTimeStep?: number): void;
  50278. /**
  50279. * Get the time step of the physics engine.
  50280. * @returns the current time step
  50281. */
  50282. getTimeStep(): number;
  50283. /**
  50284. * Release all resources
  50285. */
  50286. dispose(): void;
  50287. /**
  50288. * Gets the name of the current physics plugin
  50289. * @returns the name of the plugin
  50290. */
  50291. getPhysicsPluginName(): string;
  50292. /**
  50293. * Adding a new impostor for the impostor tracking.
  50294. * This will be done by the impostor itself.
  50295. * @param impostor the impostor to add
  50296. */
  50297. addImpostor(impostor: PhysicsImpostor): void;
  50298. /**
  50299. * Remove an impostor from the engine.
  50300. * This impostor and its mesh will not longer be updated by the physics engine.
  50301. * @param impostor the impostor to remove
  50302. */
  50303. removeImpostor(impostor: PhysicsImpostor): void;
  50304. /**
  50305. * Add a joint to the physics engine
  50306. * @param mainImpostor defines the main impostor to which the joint is added.
  50307. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50308. * @param joint defines the joint that will connect both impostors.
  50309. */
  50310. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50311. /**
  50312. * Removes a joint from the simulation
  50313. * @param mainImpostor defines the impostor used with the joint
  50314. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50315. * @param joint defines the joint to remove
  50316. */
  50317. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50318. /**
  50319. * Called by the scene. No need to call it.
  50320. * @param delta defines the timespam between frames
  50321. */
  50322. _step(delta: number): void;
  50323. /**
  50324. * Gets the current plugin used to run the simulation
  50325. * @returns current plugin
  50326. */
  50327. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50328. /**
  50329. * Gets the list of physic impostors
  50330. * @returns an array of PhysicsImpostor
  50331. */
  50332. getImpostors(): Array<PhysicsImpostor>;
  50333. /**
  50334. * Gets the impostor for a physics enabled object
  50335. * @param object defines the object impersonated by the impostor
  50336. * @returns the PhysicsImpostor or null if not found
  50337. */
  50338. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50339. /**
  50340. * Gets the impostor for a physics body object
  50341. * @param body defines physics body used by the impostor
  50342. * @returns the PhysicsImpostor or null if not found
  50343. */
  50344. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50345. /**
  50346. * Does a raycast in the physics world
  50347. * @param from when should the ray start?
  50348. * @param to when should the ray end?
  50349. * @returns PhysicsRaycastResult
  50350. */
  50351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50352. }
  50353. }
  50354. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50355. import { Nullable } from "babylonjs/types";
  50356. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50358. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50360. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50361. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50362. /** @hidden */
  50363. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50364. private _useDeltaForWorldStep;
  50365. world: any;
  50366. name: string;
  50367. private _physicsMaterials;
  50368. private _fixedTimeStep;
  50369. private _cannonRaycastResult;
  50370. private _raycastResult;
  50371. private _removeAfterStep;
  50372. BJSCANNON: any;
  50373. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50374. setGravity(gravity: Vector3): void;
  50375. setTimeStep(timeStep: number): void;
  50376. getTimeStep(): number;
  50377. executeStep(delta: number): void;
  50378. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50379. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50380. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50381. private _processChildMeshes;
  50382. removePhysicsBody(impostor: PhysicsImpostor): void;
  50383. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50384. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50385. private _addMaterial;
  50386. private _checkWithEpsilon;
  50387. private _createShape;
  50388. private _createHeightmap;
  50389. private _minus90X;
  50390. private _plus90X;
  50391. private _tmpPosition;
  50392. private _tmpDeltaPosition;
  50393. private _tmpUnityRotation;
  50394. private _updatePhysicsBodyTransformation;
  50395. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50396. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50397. isSupported(): boolean;
  50398. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50399. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50400. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50401. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50402. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50403. getBodyMass(impostor: PhysicsImpostor): number;
  50404. getBodyFriction(impostor: PhysicsImpostor): number;
  50405. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50406. getBodyRestitution(impostor: PhysicsImpostor): number;
  50407. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50408. sleepBody(impostor: PhysicsImpostor): void;
  50409. wakeUpBody(impostor: PhysicsImpostor): void;
  50410. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50411. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50412. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50413. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50414. getRadius(impostor: PhysicsImpostor): number;
  50415. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50416. dispose(): void;
  50417. private _extendNamespace;
  50418. /**
  50419. * Does a raycast in the physics world
  50420. * @param from when should the ray start?
  50421. * @param to when should the ray end?
  50422. * @returns PhysicsRaycastResult
  50423. */
  50424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50425. }
  50426. }
  50427. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50428. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50429. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50430. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50432. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50433. import { Nullable } from "babylonjs/types";
  50434. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50435. /** @hidden */
  50436. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50437. world: any;
  50438. name: string;
  50439. BJSOIMO: any;
  50440. private _raycastResult;
  50441. constructor(iterations?: number, oimoInjection?: any);
  50442. setGravity(gravity: Vector3): void;
  50443. setTimeStep(timeStep: number): void;
  50444. getTimeStep(): number;
  50445. private _tmpImpostorsArray;
  50446. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50447. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50448. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50449. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50450. private _tmpPositionVector;
  50451. removePhysicsBody(impostor: PhysicsImpostor): void;
  50452. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50453. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50454. isSupported(): boolean;
  50455. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50456. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50457. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50458. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50459. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50460. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50461. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50462. getBodyMass(impostor: PhysicsImpostor): number;
  50463. getBodyFriction(impostor: PhysicsImpostor): number;
  50464. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50465. getBodyRestitution(impostor: PhysicsImpostor): number;
  50466. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50467. sleepBody(impostor: PhysicsImpostor): void;
  50468. wakeUpBody(impostor: PhysicsImpostor): void;
  50469. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50470. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50471. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50472. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50473. getRadius(impostor: PhysicsImpostor): number;
  50474. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50475. dispose(): void;
  50476. /**
  50477. * Does a raycast in the physics world
  50478. * @param from when should the ray start?
  50479. * @param to when should the ray end?
  50480. * @returns PhysicsRaycastResult
  50481. */
  50482. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50483. }
  50484. }
  50485. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50486. import { Nullable } from "babylonjs/types";
  50487. import { Scene } from "babylonjs/scene";
  50488. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50489. import { Mesh } from "babylonjs/Meshes/mesh";
  50490. /**
  50491. * Class containing static functions to help procedurally build meshes
  50492. */
  50493. export class RibbonBuilder {
  50494. /**
  50495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50499. * * 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
  50500. * * 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
  50501. * * 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
  50502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50505. * * 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
  50506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50507. * * 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
  50508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50510. * @param name defines the name of the mesh
  50511. * @param options defines the options used to create the mesh
  50512. * @param scene defines the hosting scene
  50513. * @returns the ribbon mesh
  50514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50516. */
  50517. static CreateRibbon(name: string, options: {
  50518. pathArray: Vector3[][];
  50519. closeArray?: boolean;
  50520. closePath?: boolean;
  50521. offset?: number;
  50522. updatable?: boolean;
  50523. sideOrientation?: number;
  50524. frontUVs?: Vector4;
  50525. backUVs?: Vector4;
  50526. instance?: Mesh;
  50527. invertUV?: boolean;
  50528. uvs?: Vector2[];
  50529. colors?: Color4[];
  50530. }, scene?: Nullable<Scene>): Mesh;
  50531. }
  50532. }
  50533. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50534. import { Nullable } from "babylonjs/types";
  50535. import { Scene } from "babylonjs/scene";
  50536. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50537. import { Mesh } from "babylonjs/Meshes/mesh";
  50538. /**
  50539. * Class containing static functions to help procedurally build meshes
  50540. */
  50541. export class ShapeBuilder {
  50542. /**
  50543. * 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.
  50544. * * 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.
  50545. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50546. * * 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.
  50547. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50548. * * 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
  50549. * * 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
  50550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50555. * @param name defines the name of the mesh
  50556. * @param options defines the options used to create the mesh
  50557. * @param scene defines the hosting scene
  50558. * @returns the extruded shape mesh
  50559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50561. */
  50562. static ExtrudeShape(name: string, options: {
  50563. shape: Vector3[];
  50564. path: Vector3[];
  50565. scale?: number;
  50566. rotation?: number;
  50567. cap?: number;
  50568. updatable?: boolean;
  50569. sideOrientation?: number;
  50570. frontUVs?: Vector4;
  50571. backUVs?: Vector4;
  50572. instance?: Mesh;
  50573. invertUV?: boolean;
  50574. }, scene?: Nullable<Scene>): Mesh;
  50575. /**
  50576. * Creates an custom extruded shape mesh.
  50577. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50578. * * 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.
  50579. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50580. * * 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
  50581. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50582. * * 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
  50583. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50584. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50585. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50586. * * 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
  50587. * * 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
  50588. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50593. * @param name defines the name of the mesh
  50594. * @param options defines the options used to create the mesh
  50595. * @param scene defines the hosting scene
  50596. * @returns the custom extruded shape mesh
  50597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50598. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50600. */
  50601. static ExtrudeShapeCustom(name: string, options: {
  50602. shape: Vector3[];
  50603. path: Vector3[];
  50604. scaleFunction?: any;
  50605. rotationFunction?: any;
  50606. ribbonCloseArray?: boolean;
  50607. ribbonClosePath?: boolean;
  50608. cap?: number;
  50609. updatable?: boolean;
  50610. sideOrientation?: number;
  50611. frontUVs?: Vector4;
  50612. backUVs?: Vector4;
  50613. instance?: Mesh;
  50614. invertUV?: boolean;
  50615. }, scene?: Nullable<Scene>): Mesh;
  50616. private static _ExtrudeShapeGeneric;
  50617. }
  50618. }
  50619. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50620. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50621. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50622. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50623. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50624. import { Nullable } from "babylonjs/types";
  50625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50626. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50627. /**
  50628. * AmmoJS Physics plugin
  50629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50630. * @see https://github.com/kripken/ammo.js/
  50631. */
  50632. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50633. private _useDeltaForWorldStep;
  50634. /**
  50635. * Reference to the Ammo library
  50636. */
  50637. bjsAMMO: any;
  50638. /**
  50639. * Created ammoJS world which physics bodies are added to
  50640. */
  50641. world: any;
  50642. /**
  50643. * Name of the plugin
  50644. */
  50645. name: string;
  50646. private _timeStep;
  50647. private _fixedTimeStep;
  50648. private _maxSteps;
  50649. private _tmpQuaternion;
  50650. private _tmpAmmoTransform;
  50651. private _tmpAmmoQuaternion;
  50652. private _tmpAmmoConcreteContactResultCallback;
  50653. private _collisionConfiguration;
  50654. private _dispatcher;
  50655. private _overlappingPairCache;
  50656. private _solver;
  50657. private _softBodySolver;
  50658. private _tmpAmmoVectorA;
  50659. private _tmpAmmoVectorB;
  50660. private _tmpAmmoVectorC;
  50661. private _tmpAmmoVectorD;
  50662. private _tmpContactCallbackResult;
  50663. private _tmpAmmoVectorRCA;
  50664. private _tmpAmmoVectorRCB;
  50665. private _raycastResult;
  50666. private static readonly DISABLE_COLLISION_FLAG;
  50667. private static readonly KINEMATIC_FLAG;
  50668. private static readonly DISABLE_DEACTIVATION_FLAG;
  50669. /**
  50670. * Initializes the ammoJS plugin
  50671. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50672. * @param ammoInjection can be used to inject your own ammo reference
  50673. */
  50674. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50675. /**
  50676. * Sets the gravity of the physics world (m/(s^2))
  50677. * @param gravity Gravity to set
  50678. */
  50679. setGravity(gravity: Vector3): void;
  50680. /**
  50681. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50682. * @param timeStep timestep to use in seconds
  50683. */
  50684. setTimeStep(timeStep: number): void;
  50685. /**
  50686. * 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)
  50687. * @param fixedTimeStep fixedTimeStep to use in seconds
  50688. */
  50689. setFixedTimeStep(fixedTimeStep: number): void;
  50690. /**
  50691. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50692. * @param maxSteps the maximum number of steps by the physics engine per frame
  50693. */
  50694. setMaxSteps(maxSteps: number): void;
  50695. /**
  50696. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50697. * @returns the current timestep in seconds
  50698. */
  50699. getTimeStep(): number;
  50700. private _isImpostorInContact;
  50701. private _isImpostorPairInContact;
  50702. private _stepSimulation;
  50703. /**
  50704. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50705. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50706. * After the step the babylon meshes are set to the position of the physics imposters
  50707. * @param delta amount of time to step forward
  50708. * @param impostors array of imposters to update before/after the step
  50709. */
  50710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50711. /**
  50712. * Update babylon mesh to match physics world object
  50713. * @param impostor imposter to match
  50714. */
  50715. private _afterSoftStep;
  50716. /**
  50717. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50718. * @param impostor imposter to match
  50719. */
  50720. private _ropeStep;
  50721. /**
  50722. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50723. * @param impostor imposter to match
  50724. */
  50725. private _softbodyOrClothStep;
  50726. private _tmpVector;
  50727. private _tmpMatrix;
  50728. /**
  50729. * Applies an impulse on the imposter
  50730. * @param impostor imposter to apply impulse to
  50731. * @param force amount of force to be applied to the imposter
  50732. * @param contactPoint the location to apply the impulse on the imposter
  50733. */
  50734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50735. /**
  50736. * Applies a force on the imposter
  50737. * @param impostor imposter to apply force
  50738. * @param force amount of force to be applied to the imposter
  50739. * @param contactPoint the location to apply the force on the imposter
  50740. */
  50741. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50742. /**
  50743. * Creates a physics body using the plugin
  50744. * @param impostor the imposter to create the physics body on
  50745. */
  50746. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50747. /**
  50748. * Removes the physics body from the imposter and disposes of the body's memory
  50749. * @param impostor imposter to remove the physics body from
  50750. */
  50751. removePhysicsBody(impostor: PhysicsImpostor): void;
  50752. /**
  50753. * Generates a joint
  50754. * @param impostorJoint the imposter joint to create the joint with
  50755. */
  50756. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50757. /**
  50758. * Removes a joint
  50759. * @param impostorJoint the imposter joint to remove the joint from
  50760. */
  50761. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50762. private _addMeshVerts;
  50763. /**
  50764. * Initialise the soft body vertices to match its object's (mesh) vertices
  50765. * Softbody vertices (nodes) are in world space and to match this
  50766. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50767. * @param impostor to create the softbody for
  50768. */
  50769. private _softVertexData;
  50770. /**
  50771. * Create an impostor's soft body
  50772. * @param impostor to create the softbody for
  50773. */
  50774. private _createSoftbody;
  50775. /**
  50776. * Create cloth for an impostor
  50777. * @param impostor to create the softbody for
  50778. */
  50779. private _createCloth;
  50780. /**
  50781. * Create rope for an impostor
  50782. * @param impostor to create the softbody for
  50783. */
  50784. private _createRope;
  50785. private _addHullVerts;
  50786. private _createShape;
  50787. /**
  50788. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50789. * @param impostor imposter containing the physics body and babylon object
  50790. */
  50791. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50792. /**
  50793. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50794. * @param impostor imposter containing the physics body and babylon object
  50795. * @param newPosition new position
  50796. * @param newRotation new rotation
  50797. */
  50798. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50799. /**
  50800. * If this plugin is supported
  50801. * @returns true if its supported
  50802. */
  50803. isSupported(): boolean;
  50804. /**
  50805. * Sets the linear velocity of the physics body
  50806. * @param impostor imposter to set the velocity on
  50807. * @param velocity velocity to set
  50808. */
  50809. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50810. /**
  50811. * Sets the angular velocity of the physics body
  50812. * @param impostor imposter to set the velocity on
  50813. * @param velocity velocity to set
  50814. */
  50815. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50816. /**
  50817. * gets the linear velocity
  50818. * @param impostor imposter to get linear velocity from
  50819. * @returns linear velocity
  50820. */
  50821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50822. /**
  50823. * gets the angular velocity
  50824. * @param impostor imposter to get angular velocity from
  50825. * @returns angular velocity
  50826. */
  50827. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50828. /**
  50829. * Sets the mass of physics body
  50830. * @param impostor imposter to set the mass on
  50831. * @param mass mass to set
  50832. */
  50833. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50834. /**
  50835. * Gets the mass of the physics body
  50836. * @param impostor imposter to get the mass from
  50837. * @returns mass
  50838. */
  50839. getBodyMass(impostor: PhysicsImpostor): number;
  50840. /**
  50841. * Gets friction of the impostor
  50842. * @param impostor impostor to get friction from
  50843. * @returns friction value
  50844. */
  50845. getBodyFriction(impostor: PhysicsImpostor): number;
  50846. /**
  50847. * Sets friction of the impostor
  50848. * @param impostor impostor to set friction on
  50849. * @param friction friction value
  50850. */
  50851. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50852. /**
  50853. * Gets restitution of the impostor
  50854. * @param impostor impostor to get restitution from
  50855. * @returns restitution value
  50856. */
  50857. getBodyRestitution(impostor: PhysicsImpostor): number;
  50858. /**
  50859. * Sets resitution of the impostor
  50860. * @param impostor impostor to set resitution on
  50861. * @param restitution resitution value
  50862. */
  50863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50864. /**
  50865. * Gets pressure inside the impostor
  50866. * @param impostor impostor to get pressure from
  50867. * @returns pressure value
  50868. */
  50869. getBodyPressure(impostor: PhysicsImpostor): number;
  50870. /**
  50871. * Sets pressure inside a soft body impostor
  50872. * Cloth and rope must remain 0 pressure
  50873. * @param impostor impostor to set pressure on
  50874. * @param pressure pressure value
  50875. */
  50876. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50877. /**
  50878. * Gets stiffness of the impostor
  50879. * @param impostor impostor to get stiffness from
  50880. * @returns pressure value
  50881. */
  50882. getBodyStiffness(impostor: PhysicsImpostor): number;
  50883. /**
  50884. * Sets stiffness of the impostor
  50885. * @param impostor impostor to set stiffness on
  50886. * @param stiffness stiffness value from 0 to 1
  50887. */
  50888. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50889. /**
  50890. * Gets velocityIterations of the impostor
  50891. * @param impostor impostor to get velocity iterations from
  50892. * @returns velocityIterations value
  50893. */
  50894. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50895. /**
  50896. * Sets velocityIterations of the impostor
  50897. * @param impostor impostor to set velocity iterations on
  50898. * @param velocityIterations velocityIterations value
  50899. */
  50900. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50901. /**
  50902. * Gets positionIterations of the impostor
  50903. * @param impostor impostor to get position iterations from
  50904. * @returns positionIterations value
  50905. */
  50906. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50907. /**
  50908. * Sets positionIterations of the impostor
  50909. * @param impostor impostor to set position on
  50910. * @param positionIterations positionIterations value
  50911. */
  50912. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50913. /**
  50914. * Append an anchor to a cloth object
  50915. * @param impostor is the cloth impostor to add anchor to
  50916. * @param otherImpostor is the rigid impostor to anchor to
  50917. * @param width ratio across width from 0 to 1
  50918. * @param height ratio up height from 0 to 1
  50919. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50920. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50921. */
  50922. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50923. /**
  50924. * Append an hook to a rope object
  50925. * @param impostor is the rope impostor to add hook to
  50926. * @param otherImpostor is the rigid impostor to hook to
  50927. * @param length ratio along the rope from 0 to 1
  50928. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50929. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50930. */
  50931. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50932. /**
  50933. * Sleeps the physics body and stops it from being active
  50934. * @param impostor impostor to sleep
  50935. */
  50936. sleepBody(impostor: PhysicsImpostor): void;
  50937. /**
  50938. * Activates the physics body
  50939. * @param impostor impostor to activate
  50940. */
  50941. wakeUpBody(impostor: PhysicsImpostor): void;
  50942. /**
  50943. * Updates the distance parameters of the joint
  50944. * @param joint joint to update
  50945. * @param maxDistance maximum distance of the joint
  50946. * @param minDistance minimum distance of the joint
  50947. */
  50948. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50949. /**
  50950. * Sets a motor on the joint
  50951. * @param joint joint to set motor on
  50952. * @param speed speed of the motor
  50953. * @param maxForce maximum force of the motor
  50954. * @param motorIndex index of the motor
  50955. */
  50956. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50957. /**
  50958. * Sets the motors limit
  50959. * @param joint joint to set limit on
  50960. * @param upperLimit upper limit
  50961. * @param lowerLimit lower limit
  50962. */
  50963. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50964. /**
  50965. * Syncs the position and rotation of a mesh with the impostor
  50966. * @param mesh mesh to sync
  50967. * @param impostor impostor to update the mesh with
  50968. */
  50969. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50970. /**
  50971. * Gets the radius of the impostor
  50972. * @param impostor impostor to get radius from
  50973. * @returns the radius
  50974. */
  50975. getRadius(impostor: PhysicsImpostor): number;
  50976. /**
  50977. * Gets the box size of the impostor
  50978. * @param impostor impostor to get box size from
  50979. * @param result the resulting box size
  50980. */
  50981. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50982. /**
  50983. * Disposes of the impostor
  50984. */
  50985. dispose(): void;
  50986. /**
  50987. * Does a raycast in the physics world
  50988. * @param from when should the ray start?
  50989. * @param to when should the ray end?
  50990. * @returns PhysicsRaycastResult
  50991. */
  50992. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50993. }
  50994. }
  50995. declare module "babylonjs/Probes/reflectionProbe" {
  50996. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50997. import { Vector3 } from "babylonjs/Maths/math";
  50998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50999. import { Nullable } from "babylonjs/types";
  51000. import { Scene } from "babylonjs/scene";
  51001. module "babylonjs/abstractScene" {
  51002. interface AbstractScene {
  51003. /**
  51004. * The list of reflection probes added to the scene
  51005. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51006. */
  51007. reflectionProbes: Array<ReflectionProbe>;
  51008. /**
  51009. * Removes the given reflection probe from this scene.
  51010. * @param toRemove The reflection probe to remove
  51011. * @returns The index of the removed reflection probe
  51012. */
  51013. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51014. /**
  51015. * Adds the given reflection probe to this scene.
  51016. * @param newReflectionProbe The reflection probe to add
  51017. */
  51018. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51019. }
  51020. }
  51021. /**
  51022. * Class used to generate realtime reflection / refraction cube textures
  51023. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51024. */
  51025. export class ReflectionProbe {
  51026. /** defines the name of the probe */
  51027. name: string;
  51028. private _scene;
  51029. private _renderTargetTexture;
  51030. private _projectionMatrix;
  51031. private _viewMatrix;
  51032. private _target;
  51033. private _add;
  51034. private _attachedMesh;
  51035. private _invertYAxis;
  51036. /** Gets or sets probe position (center of the cube map) */
  51037. position: Vector3;
  51038. /**
  51039. * Creates a new reflection probe
  51040. * @param name defines the name of the probe
  51041. * @param size defines the texture resolution (for each face)
  51042. * @param scene defines the hosting scene
  51043. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51044. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51045. */
  51046. constructor(
  51047. /** defines the name of the probe */
  51048. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51049. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51050. samples: number;
  51051. /** Gets or sets the refresh rate to use (on every frame by default) */
  51052. refreshRate: number;
  51053. /**
  51054. * Gets the hosting scene
  51055. * @returns a Scene
  51056. */
  51057. getScene(): Scene;
  51058. /** Gets the internal CubeTexture used to render to */
  51059. readonly cubeTexture: RenderTargetTexture;
  51060. /** Gets the list of meshes to render */
  51061. readonly renderList: Nullable<AbstractMesh[]>;
  51062. /**
  51063. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51064. * @param mesh defines the mesh to attach to
  51065. */
  51066. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51067. /**
  51068. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51069. * @param renderingGroupId The rendering group id corresponding to its index
  51070. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51071. */
  51072. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51073. /**
  51074. * Clean all associated resources
  51075. */
  51076. dispose(): void;
  51077. /**
  51078. * Converts the reflection probe information to a readable string for debug purpose.
  51079. * @param fullDetails Supports for multiple levels of logging within scene loading
  51080. * @returns the human readable reflection probe info
  51081. */
  51082. toString(fullDetails?: boolean): string;
  51083. /**
  51084. * Get the class name of the relfection probe.
  51085. * @returns "ReflectionProbe"
  51086. */
  51087. getClassName(): string;
  51088. /**
  51089. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51090. * @returns The JSON representation of the texture
  51091. */
  51092. serialize(): any;
  51093. /**
  51094. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51095. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51096. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51097. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51098. * @returns The parsed reflection probe if successful
  51099. */
  51100. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51101. }
  51102. }
  51103. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51104. /** @hidden */
  51105. export var _BabylonLoaderRegistered: boolean;
  51106. }
  51107. declare module "babylonjs/Loading/Plugins/index" {
  51108. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51109. }
  51110. declare module "babylonjs/Loading/index" {
  51111. export * from "babylonjs/Loading/loadingScreen";
  51112. export * from "babylonjs/Loading/Plugins/index";
  51113. export * from "babylonjs/Loading/sceneLoader";
  51114. export * from "babylonjs/Loading/sceneLoaderFlags";
  51115. }
  51116. declare module "babylonjs/Materials/Background/index" {
  51117. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51118. }
  51119. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51120. import { Scene } from "babylonjs/scene";
  51121. import { Color3 } from "babylonjs/Maths/math";
  51122. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51124. /**
  51125. * The Physically based simple base material of BJS.
  51126. *
  51127. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51128. * It is used as the base class for both the specGloss and metalRough conventions.
  51129. */
  51130. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51131. /**
  51132. * Number of Simultaneous lights allowed on the material.
  51133. */
  51134. maxSimultaneousLights: number;
  51135. /**
  51136. * If sets to true, disables all the lights affecting the material.
  51137. */
  51138. disableLighting: boolean;
  51139. /**
  51140. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51141. */
  51142. environmentTexture: BaseTexture;
  51143. /**
  51144. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51145. */
  51146. invertNormalMapX: boolean;
  51147. /**
  51148. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51149. */
  51150. invertNormalMapY: boolean;
  51151. /**
  51152. * Normal map used in the model.
  51153. */
  51154. normalTexture: BaseTexture;
  51155. /**
  51156. * Emissivie color used to self-illuminate the model.
  51157. */
  51158. emissiveColor: Color3;
  51159. /**
  51160. * Emissivie texture used to self-illuminate the model.
  51161. */
  51162. emissiveTexture: BaseTexture;
  51163. /**
  51164. * Occlusion Channel Strenght.
  51165. */
  51166. occlusionStrength: number;
  51167. /**
  51168. * Occlusion Texture of the material (adding extra occlusion effects).
  51169. */
  51170. occlusionTexture: BaseTexture;
  51171. /**
  51172. * Defines the alpha limits in alpha test mode.
  51173. */
  51174. alphaCutOff: number;
  51175. /**
  51176. * Gets the current double sided mode.
  51177. */
  51178. /**
  51179. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51180. */
  51181. doubleSided: boolean;
  51182. /**
  51183. * Stores the pre-calculated light information of a mesh in a texture.
  51184. */
  51185. lightmapTexture: BaseTexture;
  51186. /**
  51187. * If true, the light map contains occlusion information instead of lighting info.
  51188. */
  51189. useLightmapAsShadowmap: boolean;
  51190. /**
  51191. * Instantiates a new PBRMaterial instance.
  51192. *
  51193. * @param name The material name
  51194. * @param scene The scene the material will be use in.
  51195. */
  51196. constructor(name: string, scene: Scene);
  51197. getClassName(): string;
  51198. }
  51199. }
  51200. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51201. import { Scene } from "babylonjs/scene";
  51202. import { Color3 } from "babylonjs/Maths/math";
  51203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51204. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51205. /**
  51206. * The PBR material of BJS following the metal roughness convention.
  51207. *
  51208. * This fits to the PBR convention in the GLTF definition:
  51209. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51210. */
  51211. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51212. /**
  51213. * The base color has two different interpretations depending on the value of metalness.
  51214. * When the material is a metal, the base color is the specific measured reflectance value
  51215. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51216. * of the material.
  51217. */
  51218. baseColor: Color3;
  51219. /**
  51220. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51221. * well as opacity information in the alpha channel.
  51222. */
  51223. baseTexture: BaseTexture;
  51224. /**
  51225. * Specifies the metallic scalar value of the material.
  51226. * Can also be used to scale the metalness values of the metallic texture.
  51227. */
  51228. metallic: number;
  51229. /**
  51230. * Specifies the roughness scalar value of the material.
  51231. * Can also be used to scale the roughness values of the metallic texture.
  51232. */
  51233. roughness: number;
  51234. /**
  51235. * Texture containing both the metallic value in the B channel and the
  51236. * roughness value in the G channel to keep better precision.
  51237. */
  51238. metallicRoughnessTexture: BaseTexture;
  51239. /**
  51240. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51241. *
  51242. * @param name The material name
  51243. * @param scene The scene the material will be use in.
  51244. */
  51245. constructor(name: string, scene: Scene);
  51246. /**
  51247. * Return the currrent class name of the material.
  51248. */
  51249. getClassName(): string;
  51250. /**
  51251. * Makes a duplicate of the current material.
  51252. * @param name - name to use for the new material.
  51253. */
  51254. clone(name: string): PBRMetallicRoughnessMaterial;
  51255. /**
  51256. * Serialize the material to a parsable JSON object.
  51257. */
  51258. serialize(): any;
  51259. /**
  51260. * Parses a JSON object correponding to the serialize function.
  51261. */
  51262. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51263. }
  51264. }
  51265. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51266. import { Scene } from "babylonjs/scene";
  51267. import { Color3 } from "babylonjs/Maths/math";
  51268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51269. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51270. /**
  51271. * The PBR material of BJS following the specular glossiness convention.
  51272. *
  51273. * This fits to the PBR convention in the GLTF definition:
  51274. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51275. */
  51276. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51277. /**
  51278. * Specifies the diffuse color of the material.
  51279. */
  51280. diffuseColor: Color3;
  51281. /**
  51282. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51283. * channel.
  51284. */
  51285. diffuseTexture: BaseTexture;
  51286. /**
  51287. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51288. */
  51289. specularColor: Color3;
  51290. /**
  51291. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51292. */
  51293. glossiness: number;
  51294. /**
  51295. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51296. */
  51297. specularGlossinessTexture: BaseTexture;
  51298. /**
  51299. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51300. *
  51301. * @param name The material name
  51302. * @param scene The scene the material will be use in.
  51303. */
  51304. constructor(name: string, scene: Scene);
  51305. /**
  51306. * Return the currrent class name of the material.
  51307. */
  51308. getClassName(): string;
  51309. /**
  51310. * Makes a duplicate of the current material.
  51311. * @param name - name to use for the new material.
  51312. */
  51313. clone(name: string): PBRSpecularGlossinessMaterial;
  51314. /**
  51315. * Serialize the material to a parsable JSON object.
  51316. */
  51317. serialize(): any;
  51318. /**
  51319. * Parses a JSON object correponding to the serialize function.
  51320. */
  51321. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51322. }
  51323. }
  51324. declare module "babylonjs/Materials/PBR/index" {
  51325. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51326. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51327. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51328. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51329. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51330. }
  51331. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51332. import { Nullable } from "babylonjs/types";
  51333. import { Scene } from "babylonjs/scene";
  51334. import { Matrix } from "babylonjs/Maths/math";
  51335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51336. /**
  51337. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51338. * It can help converting any input color in a desired output one. This can then be used to create effects
  51339. * from sepia, black and white to sixties or futuristic rendering...
  51340. *
  51341. * The only supported format is currently 3dl.
  51342. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51343. */
  51344. export class ColorGradingTexture extends BaseTexture {
  51345. /**
  51346. * The current texture matrix. (will always be identity in color grading texture)
  51347. */
  51348. private _textureMatrix;
  51349. /**
  51350. * The texture URL.
  51351. */
  51352. url: string;
  51353. /**
  51354. * Empty line regex stored for GC.
  51355. */
  51356. private static _noneEmptyLineRegex;
  51357. private _engine;
  51358. /**
  51359. * Instantiates a ColorGradingTexture from the following parameters.
  51360. *
  51361. * @param url The location of the color gradind data (currently only supporting 3dl)
  51362. * @param scene The scene the texture will be used in
  51363. */
  51364. constructor(url: string, scene: Scene);
  51365. /**
  51366. * Returns the texture matrix used in most of the material.
  51367. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51368. */
  51369. getTextureMatrix(): Matrix;
  51370. /**
  51371. * Occurs when the file being loaded is a .3dl LUT file.
  51372. */
  51373. private load3dlTexture;
  51374. /**
  51375. * Starts the loading process of the texture.
  51376. */
  51377. private loadTexture;
  51378. /**
  51379. * Clones the color gradind texture.
  51380. */
  51381. clone(): ColorGradingTexture;
  51382. /**
  51383. * Called during delayed load for textures.
  51384. */
  51385. delayLoad(): void;
  51386. /**
  51387. * Parses a color grading texture serialized by Babylon.
  51388. * @param parsedTexture The texture information being parsedTexture
  51389. * @param scene The scene to load the texture in
  51390. * @param rootUrl The root url of the data assets to load
  51391. * @return A color gradind texture
  51392. */
  51393. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51394. /**
  51395. * Serializes the LUT texture to json format.
  51396. */
  51397. serialize(): any;
  51398. }
  51399. }
  51400. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51402. import { Scene } from "babylonjs/scene";
  51403. import { Nullable } from "babylonjs/types";
  51404. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51405. /**
  51406. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51407. */
  51408. export class EquiRectangularCubeTexture extends BaseTexture {
  51409. /** The six faces of the cube. */
  51410. private static _FacesMapping;
  51411. private _noMipmap;
  51412. private _onLoad;
  51413. private _onError;
  51414. /** The size of the cubemap. */
  51415. private _size;
  51416. /** The buffer of the image. */
  51417. private _buffer;
  51418. /** The width of the input image. */
  51419. private _width;
  51420. /** The height of the input image. */
  51421. private _height;
  51422. /** The URL to the image. */
  51423. url: string;
  51424. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51425. coordinatesMode: number;
  51426. /**
  51427. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51428. * @param url The location of the image
  51429. * @param scene The scene the texture will be used in
  51430. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51431. * @param noMipmap Forces to not generate the mipmap if true
  51432. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51433. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51434. * @param onLoad — defines a callback called when texture is loaded
  51435. * @param onError — defines a callback called if there is an error
  51436. */
  51437. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51438. /**
  51439. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51440. */
  51441. private loadImage;
  51442. /**
  51443. * Convert the image buffer into a cubemap and create a CubeTexture.
  51444. */
  51445. private loadTexture;
  51446. /**
  51447. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51448. * @param buffer The ArrayBuffer that should be converted.
  51449. * @returns The buffer as Float32Array.
  51450. */
  51451. private getFloat32ArrayFromArrayBuffer;
  51452. /**
  51453. * Get the current class name of the texture useful for serialization or dynamic coding.
  51454. * @returns "EquiRectangularCubeTexture"
  51455. */
  51456. getClassName(): string;
  51457. /**
  51458. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51459. * @returns A clone of the current EquiRectangularCubeTexture.
  51460. */
  51461. clone(): EquiRectangularCubeTexture;
  51462. }
  51463. }
  51464. declare module "babylonjs/Misc/tga" {
  51465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51466. /**
  51467. * Based on jsTGALoader - Javascript loader for TGA file
  51468. * By Vincent Thibault
  51469. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51470. */
  51471. export class TGATools {
  51472. private static _TYPE_INDEXED;
  51473. private static _TYPE_RGB;
  51474. private static _TYPE_GREY;
  51475. private static _TYPE_RLE_INDEXED;
  51476. private static _TYPE_RLE_RGB;
  51477. private static _TYPE_RLE_GREY;
  51478. private static _ORIGIN_MASK;
  51479. private static _ORIGIN_SHIFT;
  51480. private static _ORIGIN_BL;
  51481. private static _ORIGIN_BR;
  51482. private static _ORIGIN_UL;
  51483. private static _ORIGIN_UR;
  51484. /**
  51485. * Gets the header of a TGA file
  51486. * @param data defines the TGA data
  51487. * @returns the header
  51488. */
  51489. static GetTGAHeader(data: Uint8Array): any;
  51490. /**
  51491. * Uploads TGA content to a Babylon Texture
  51492. * @hidden
  51493. */
  51494. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51495. /** @hidden */
  51496. 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;
  51497. /** @hidden */
  51498. 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;
  51499. /** @hidden */
  51500. 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;
  51501. /** @hidden */
  51502. 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;
  51503. /** @hidden */
  51504. 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;
  51505. /** @hidden */
  51506. 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;
  51507. }
  51508. }
  51509. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51510. import { Nullable } from "babylonjs/types";
  51511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51512. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51513. /**
  51514. * Implementation of the TGA Texture Loader.
  51515. * @hidden
  51516. */
  51517. export class _TGATextureLoader implements IInternalTextureLoader {
  51518. /**
  51519. * Defines wether the loader supports cascade loading the different faces.
  51520. */
  51521. readonly supportCascades: boolean;
  51522. /**
  51523. * This returns if the loader support the current file information.
  51524. * @param extension defines the file extension of the file being loaded
  51525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51526. * @param fallback defines the fallback internal texture if any
  51527. * @param isBase64 defines whether the texture is encoded as a base64
  51528. * @param isBuffer defines whether the texture data are stored as a buffer
  51529. * @returns true if the loader can load the specified file
  51530. */
  51531. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51532. /**
  51533. * Transform the url before loading if required.
  51534. * @param rootUrl the url of the texture
  51535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51536. * @returns the transformed texture
  51537. */
  51538. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51539. /**
  51540. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51541. * @param rootUrl the url of the texture
  51542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51543. * @returns the fallback texture
  51544. */
  51545. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51546. /**
  51547. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51548. * @param data contains the texture data
  51549. * @param texture defines the BabylonJS internal texture
  51550. * @param createPolynomials will be true if polynomials have been requested
  51551. * @param onLoad defines the callback to trigger once the texture is ready
  51552. * @param onError defines the callback to trigger in case of error
  51553. */
  51554. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51555. /**
  51556. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51557. * @param data contains the texture data
  51558. * @param texture defines the BabylonJS internal texture
  51559. * @param callback defines the method to call once ready to upload
  51560. */
  51561. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51562. }
  51563. }
  51564. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51565. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51566. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51567. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51568. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51569. }
  51570. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51571. import { Scene } from "babylonjs/scene";
  51572. import { Texture } from "babylonjs/Materials/Textures/texture";
  51573. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51574. /**
  51575. * 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.
  51576. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51577. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51578. */
  51579. export class CustomProceduralTexture extends ProceduralTexture {
  51580. private _animate;
  51581. private _time;
  51582. private _config;
  51583. private _texturePath;
  51584. /**
  51585. * Instantiates a new Custom Procedural Texture.
  51586. * 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.
  51587. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51588. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51589. * @param name Define the name of the texture
  51590. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51591. * @param size Define the size of the texture to create
  51592. * @param scene Define the scene the texture belongs to
  51593. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51594. * @param generateMipMaps Define if the texture should creates mip maps or not
  51595. */
  51596. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51597. private _loadJson;
  51598. /**
  51599. * Is the texture ready to be used ? (rendered at least once)
  51600. * @returns true if ready, otherwise, false.
  51601. */
  51602. isReady(): boolean;
  51603. /**
  51604. * Render the texture to its associated render target.
  51605. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51606. */
  51607. render(useCameraPostProcess?: boolean): void;
  51608. /**
  51609. * Update the list of dependant textures samplers in the shader.
  51610. */
  51611. updateTextures(): void;
  51612. /**
  51613. * Update the uniform values of the procedural texture in the shader.
  51614. */
  51615. updateShaderUniforms(): void;
  51616. /**
  51617. * Define if the texture animates or not.
  51618. */
  51619. animate: boolean;
  51620. }
  51621. }
  51622. declare module "babylonjs/Shaders/noise.fragment" {
  51623. /** @hidden */
  51624. export var noisePixelShader: {
  51625. name: string;
  51626. shader: string;
  51627. };
  51628. }
  51629. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51630. import { Nullable } from "babylonjs/types";
  51631. import { Scene } from "babylonjs/scene";
  51632. import { Texture } from "babylonjs/Materials/Textures/texture";
  51633. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51634. import "babylonjs/Shaders/noise.fragment";
  51635. /**
  51636. * Class used to generate noise procedural textures
  51637. */
  51638. export class NoiseProceduralTexture extends ProceduralTexture {
  51639. private _time;
  51640. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51641. brightness: number;
  51642. /** Defines the number of octaves to process */
  51643. octaves: number;
  51644. /** Defines the level of persistence (0.8 by default) */
  51645. persistence: number;
  51646. /** Gets or sets animation speed factor (default is 1) */
  51647. animationSpeedFactor: number;
  51648. /**
  51649. * Creates a new NoiseProceduralTexture
  51650. * @param name defines the name fo the texture
  51651. * @param size defines the size of the texture (default is 256)
  51652. * @param scene defines the hosting scene
  51653. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51654. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51655. */
  51656. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51657. private _updateShaderUniforms;
  51658. protected _getDefines(): string;
  51659. /** Generate the current state of the procedural texture */
  51660. render(useCameraPostProcess?: boolean): void;
  51661. /**
  51662. * Serializes this noise procedural texture
  51663. * @returns a serialized noise procedural texture object
  51664. */
  51665. serialize(): any;
  51666. /**
  51667. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51668. * @param parsedTexture defines parsed texture data
  51669. * @param scene defines the current scene
  51670. * @param rootUrl defines the root URL containing noise procedural texture information
  51671. * @returns a parsed NoiseProceduralTexture
  51672. */
  51673. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51674. }
  51675. }
  51676. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51677. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51678. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51679. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51680. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51681. }
  51682. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51683. import { Nullable } from "babylonjs/types";
  51684. import { Scene } from "babylonjs/scene";
  51685. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51687. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51688. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51689. /**
  51690. * Raw cube texture where the raw buffers are passed in
  51691. */
  51692. export class RawCubeTexture extends CubeTexture {
  51693. /**
  51694. * Creates a cube texture where the raw buffers are passed in.
  51695. * @param scene defines the scene the texture is attached to
  51696. * @param data defines the array of data to use to create each face
  51697. * @param size defines the size of the textures
  51698. * @param format defines the format of the data
  51699. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51700. * @param generateMipMaps defines if the engine should generate the mip levels
  51701. * @param invertY defines if data must be stored with Y axis inverted
  51702. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51703. * @param compression defines the compression used (null by default)
  51704. */
  51705. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51706. /**
  51707. * Updates the raw cube texture.
  51708. * @param data defines the data to store
  51709. * @param format defines the data format
  51710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51711. * @param invertY defines if data must be stored with Y axis inverted
  51712. * @param compression defines the compression used (null by default)
  51713. * @param level defines which level of the texture to update
  51714. */
  51715. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51716. /**
  51717. * Updates a raw cube texture with RGBD encoded data.
  51718. * @param data defines the array of data [mipmap][face] to use to create each face
  51719. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51722. * @returns a promsie that resolves when the operation is complete
  51723. */
  51724. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51725. /**
  51726. * Clones the raw cube texture.
  51727. * @return a new cube texture
  51728. */
  51729. clone(): CubeTexture;
  51730. /** @hidden */
  51731. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51732. }
  51733. }
  51734. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51735. import { Scene } from "babylonjs/scene";
  51736. import { Texture } from "babylonjs/Materials/Textures/texture";
  51737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51738. /**
  51739. * Class used to store 3D textures containing user data
  51740. */
  51741. export class RawTexture3D extends Texture {
  51742. /** Gets or sets the texture format to use */
  51743. format: number;
  51744. private _engine;
  51745. /**
  51746. * Create a new RawTexture3D
  51747. * @param data defines the data of the texture
  51748. * @param width defines the width of the texture
  51749. * @param height defines the height of the texture
  51750. * @param depth defines the depth of the texture
  51751. * @param format defines the texture format to use
  51752. * @param scene defines the hosting scene
  51753. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51754. * @param invertY defines if texture must be stored with Y axis inverted
  51755. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51756. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51757. */
  51758. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51759. /** Gets or sets the texture format to use */
  51760. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51761. /**
  51762. * Update the texture with new data
  51763. * @param data defines the data to store in the texture
  51764. */
  51765. update(data: ArrayBufferView): void;
  51766. }
  51767. }
  51768. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51769. import { Scene } from "babylonjs/scene";
  51770. import { Plane } from "babylonjs/Maths/math";
  51771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51772. /**
  51773. * Creates a refraction texture used by refraction channel of the standard material.
  51774. * It is like a mirror but to see through a material.
  51775. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51776. */
  51777. export class RefractionTexture extends RenderTargetTexture {
  51778. /**
  51779. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51780. * 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.
  51781. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51782. */
  51783. refractionPlane: Plane;
  51784. /**
  51785. * Define how deep under the surface we should see.
  51786. */
  51787. depth: number;
  51788. /**
  51789. * Creates a refraction texture used by refraction channel of the standard material.
  51790. * It is like a mirror but to see through a material.
  51791. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51792. * @param name Define the texture name
  51793. * @param size Define the size of the underlying texture
  51794. * @param scene Define the scene the refraction belongs to
  51795. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51796. */
  51797. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51798. /**
  51799. * Clone the refraction texture.
  51800. * @returns the cloned texture
  51801. */
  51802. clone(): RefractionTexture;
  51803. /**
  51804. * Serialize the texture to a JSON representation you could use in Parse later on
  51805. * @returns the serialized JSON representation
  51806. */
  51807. serialize(): any;
  51808. }
  51809. }
  51810. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51811. import { Nullable } from "babylonjs/types";
  51812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51813. import { Matrix } from "babylonjs/Maths/math";
  51814. import { Engine } from "babylonjs/Engines/engine";
  51815. import { Scene } from "babylonjs/scene";
  51816. /**
  51817. * Defines the options related to the creation of an HtmlElementTexture
  51818. */
  51819. export interface IHtmlElementTextureOptions {
  51820. /**
  51821. * Defines wether mip maps should be created or not.
  51822. */
  51823. generateMipMaps?: boolean;
  51824. /**
  51825. * Defines the sampling mode of the texture.
  51826. */
  51827. samplingMode?: number;
  51828. /**
  51829. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51830. */
  51831. engine: Nullable<Engine>;
  51832. /**
  51833. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51834. */
  51835. scene: Nullable<Scene>;
  51836. }
  51837. /**
  51838. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51839. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51840. * is automatically managed.
  51841. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51842. * in your application.
  51843. *
  51844. * As the update is not automatic, you need to call them manually.
  51845. */
  51846. export class HtmlElementTexture extends BaseTexture {
  51847. /**
  51848. * The texture URL.
  51849. */
  51850. element: HTMLVideoElement | HTMLCanvasElement;
  51851. private static readonly DefaultOptions;
  51852. private _textureMatrix;
  51853. private _engine;
  51854. private _isVideo;
  51855. private _generateMipMaps;
  51856. private _samplingMode;
  51857. /**
  51858. * Instantiates a HtmlElementTexture from the following parameters.
  51859. *
  51860. * @param name Defines the name of the texture
  51861. * @param element Defines the video or canvas the texture is filled with
  51862. * @param options Defines the other none mandatory texture creation options
  51863. */
  51864. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51865. private _createInternalTexture;
  51866. /**
  51867. * Returns the texture matrix used in most of the material.
  51868. */
  51869. getTextureMatrix(): Matrix;
  51870. /**
  51871. * Updates the content of the texture.
  51872. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51873. */
  51874. update(invertY?: Nullable<boolean>): void;
  51875. }
  51876. }
  51877. declare module "babylonjs/Materials/Textures/index" {
  51878. export * from "babylonjs/Materials/Textures/baseTexture";
  51879. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51880. export * from "babylonjs/Materials/Textures/cubeTexture";
  51881. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51882. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51883. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51884. export * from "babylonjs/Materials/Textures/internalTexture";
  51885. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51886. export * from "babylonjs/Materials/Textures/Loaders/index";
  51887. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51888. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51889. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51890. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51891. export * from "babylonjs/Materials/Textures/rawTexture";
  51892. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51893. export * from "babylonjs/Materials/Textures/refractionTexture";
  51894. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51895. export * from "babylonjs/Materials/Textures/texture";
  51896. export * from "babylonjs/Materials/Textures/videoTexture";
  51897. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51898. }
  51899. declare module "babylonjs/Materials/index" {
  51900. export * from "babylonjs/Materials/Background/index";
  51901. export * from "babylonjs/Materials/colorCurves";
  51902. export * from "babylonjs/Materials/effect";
  51903. export * from "babylonjs/Materials/fresnelParameters";
  51904. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51905. export * from "babylonjs/Materials/material";
  51906. export * from "babylonjs/Materials/materialDefines";
  51907. export * from "babylonjs/Materials/materialHelper";
  51908. export * from "babylonjs/Materials/multiMaterial";
  51909. export * from "babylonjs/Materials/PBR/index";
  51910. export * from "babylonjs/Materials/pushMaterial";
  51911. export * from "babylonjs/Materials/shaderMaterial";
  51912. export * from "babylonjs/Materials/standardMaterial";
  51913. export * from "babylonjs/Materials/Textures/index";
  51914. export * from "babylonjs/Materials/uniformBuffer";
  51915. export * from "babylonjs/Materials/materialFlags";
  51916. }
  51917. declare module "babylonjs/Maths/index" {
  51918. export * from "babylonjs/Maths/math.scalar";
  51919. export * from "babylonjs/Maths/math";
  51920. export * from "babylonjs/Maths/sphericalPolynomial";
  51921. }
  51922. declare module "babylonjs/Misc/workerPool" {
  51923. import { IDisposable } from "babylonjs/scene";
  51924. /**
  51925. * Helper class to push actions to a pool of workers.
  51926. */
  51927. export class WorkerPool implements IDisposable {
  51928. private _workerInfos;
  51929. private _pendingActions;
  51930. /**
  51931. * Constructor
  51932. * @param workers Array of workers to use for actions
  51933. */
  51934. constructor(workers: Array<Worker>);
  51935. /**
  51936. * Terminates all workers and clears any pending actions.
  51937. */
  51938. dispose(): void;
  51939. /**
  51940. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51941. * pended until a worker has completed its action.
  51942. * @param action The action to perform. Call onComplete when the action is complete.
  51943. */
  51944. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51945. private _execute;
  51946. }
  51947. }
  51948. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51949. import { IDisposable } from "babylonjs/scene";
  51950. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51951. /**
  51952. * Configuration for Draco compression
  51953. */
  51954. export interface IDracoCompressionConfiguration {
  51955. /**
  51956. * Configuration for the decoder.
  51957. */
  51958. decoder: {
  51959. /**
  51960. * The url to the WebAssembly module.
  51961. */
  51962. wasmUrl?: string;
  51963. /**
  51964. * The url to the WebAssembly binary.
  51965. */
  51966. wasmBinaryUrl?: string;
  51967. /**
  51968. * The url to the fallback JavaScript module.
  51969. */
  51970. fallbackUrl?: string;
  51971. };
  51972. }
  51973. /**
  51974. * Draco compression (https://google.github.io/draco/)
  51975. *
  51976. * This class wraps the Draco module.
  51977. *
  51978. * **Encoder**
  51979. *
  51980. * The encoder is not currently implemented.
  51981. *
  51982. * **Decoder**
  51983. *
  51984. * 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.
  51985. *
  51986. * To update the configuration, use the following code:
  51987. * ```javascript
  51988. * DracoCompression.Configuration = {
  51989. * decoder: {
  51990. * wasmUrl: "<url to the WebAssembly library>",
  51991. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51992. * fallbackUrl: "<url to the fallback JavaScript library>",
  51993. * }
  51994. * };
  51995. * ```
  51996. *
  51997. * 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.
  51998. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51999. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52000. *
  52001. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52002. * ```javascript
  52003. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52004. * ```
  52005. *
  52006. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52007. */
  52008. export class DracoCompression implements IDisposable {
  52009. private _workerPoolPromise?;
  52010. private _decoderModulePromise?;
  52011. /**
  52012. * The configuration. Defaults to the following urls:
  52013. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52014. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52015. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52016. */
  52017. static Configuration: IDracoCompressionConfiguration;
  52018. /**
  52019. * Returns true if the decoder configuration is available.
  52020. */
  52021. static readonly DecoderAvailable: boolean;
  52022. /**
  52023. * Default number of workers to create when creating the draco compression object.
  52024. */
  52025. static DefaultNumWorkers: number;
  52026. private static GetDefaultNumWorkers;
  52027. private static _Default;
  52028. /**
  52029. * Default instance for the draco compression object.
  52030. */
  52031. static readonly Default: DracoCompression;
  52032. /**
  52033. * Constructor
  52034. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52035. */
  52036. constructor(numWorkers?: number);
  52037. /**
  52038. * Stop all async operations and release resources.
  52039. */
  52040. dispose(): void;
  52041. /**
  52042. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52043. * @returns a promise that resolves when ready
  52044. */
  52045. whenReadyAsync(): Promise<void>;
  52046. /**
  52047. * Decode Draco compressed mesh data to vertex data.
  52048. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52049. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52050. * @returns A promise that resolves with the decoded vertex data
  52051. */
  52052. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52053. [kind: string]: number;
  52054. }): Promise<VertexData>;
  52055. }
  52056. }
  52057. declare module "babylonjs/Meshes/Compression/index" {
  52058. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52059. }
  52060. declare module "babylonjs/Meshes/csg" {
  52061. import { Nullable } from "babylonjs/types";
  52062. import { Scene } from "babylonjs/scene";
  52063. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52064. import { Mesh } from "babylonjs/Meshes/mesh";
  52065. import { Material } from "babylonjs/Materials/material";
  52066. /**
  52067. * Class for building Constructive Solid Geometry
  52068. */
  52069. export class CSG {
  52070. private polygons;
  52071. /**
  52072. * The world matrix
  52073. */
  52074. matrix: Matrix;
  52075. /**
  52076. * Stores the position
  52077. */
  52078. position: Vector3;
  52079. /**
  52080. * Stores the rotation
  52081. */
  52082. rotation: Vector3;
  52083. /**
  52084. * Stores the rotation quaternion
  52085. */
  52086. rotationQuaternion: Nullable<Quaternion>;
  52087. /**
  52088. * Stores the scaling vector
  52089. */
  52090. scaling: Vector3;
  52091. /**
  52092. * Convert the Mesh to CSG
  52093. * @param mesh The Mesh to convert to CSG
  52094. * @returns A new CSG from the Mesh
  52095. */
  52096. static FromMesh(mesh: Mesh): CSG;
  52097. /**
  52098. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52099. * @param polygons Polygons used to construct a CSG solid
  52100. */
  52101. private static FromPolygons;
  52102. /**
  52103. * Clones, or makes a deep copy, of the CSG
  52104. * @returns A new CSG
  52105. */
  52106. clone(): CSG;
  52107. /**
  52108. * Unions this CSG with another CSG
  52109. * @param csg The CSG to union against this CSG
  52110. * @returns The unioned CSG
  52111. */
  52112. union(csg: CSG): CSG;
  52113. /**
  52114. * Unions this CSG with another CSG in place
  52115. * @param csg The CSG to union against this CSG
  52116. */
  52117. unionInPlace(csg: CSG): void;
  52118. /**
  52119. * Subtracts this CSG with another CSG
  52120. * @param csg The CSG to subtract against this CSG
  52121. * @returns A new CSG
  52122. */
  52123. subtract(csg: CSG): CSG;
  52124. /**
  52125. * Subtracts this CSG with another CSG in place
  52126. * @param csg The CSG to subtact against this CSG
  52127. */
  52128. subtractInPlace(csg: CSG): void;
  52129. /**
  52130. * Intersect this CSG with another CSG
  52131. * @param csg The CSG to intersect against this CSG
  52132. * @returns A new CSG
  52133. */
  52134. intersect(csg: CSG): CSG;
  52135. /**
  52136. * Intersects this CSG with another CSG in place
  52137. * @param csg The CSG to intersect against this CSG
  52138. */
  52139. intersectInPlace(csg: CSG): void;
  52140. /**
  52141. * Return a new CSG solid with solid and empty space switched. This solid is
  52142. * not modified.
  52143. * @returns A new CSG solid with solid and empty space switched
  52144. */
  52145. inverse(): CSG;
  52146. /**
  52147. * Inverses the CSG in place
  52148. */
  52149. inverseInPlace(): void;
  52150. /**
  52151. * This is used to keep meshes transformations so they can be restored
  52152. * when we build back a Babylon Mesh
  52153. * NB : All CSG operations are performed in world coordinates
  52154. * @param csg The CSG to copy the transform attributes from
  52155. * @returns This CSG
  52156. */
  52157. copyTransformAttributes(csg: CSG): CSG;
  52158. /**
  52159. * Build Raw mesh from CSG
  52160. * Coordinates here are in world space
  52161. * @param name The name of the mesh geometry
  52162. * @param scene The Scene
  52163. * @param keepSubMeshes Specifies if the submeshes should be kept
  52164. * @returns A new Mesh
  52165. */
  52166. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52167. /**
  52168. * Build Mesh from CSG taking material and transforms into account
  52169. * @param name The name of the Mesh
  52170. * @param material The material of the Mesh
  52171. * @param scene The Scene
  52172. * @param keepSubMeshes Specifies if submeshes should be kept
  52173. * @returns The new Mesh
  52174. */
  52175. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52176. }
  52177. }
  52178. declare module "babylonjs/Meshes/trailMesh" {
  52179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52180. import { Mesh } from "babylonjs/Meshes/mesh";
  52181. import { Scene } from "babylonjs/scene";
  52182. /**
  52183. * Class used to create a trail following a mesh
  52184. */
  52185. export class TrailMesh extends Mesh {
  52186. private _generator;
  52187. private _autoStart;
  52188. private _running;
  52189. private _diameter;
  52190. private _length;
  52191. private _sectionPolygonPointsCount;
  52192. private _sectionVectors;
  52193. private _sectionNormalVectors;
  52194. private _beforeRenderObserver;
  52195. /**
  52196. * @constructor
  52197. * @param name The value used by scene.getMeshByName() to do a lookup.
  52198. * @param generator The mesh to generate a trail.
  52199. * @param scene The scene to add this mesh to.
  52200. * @param diameter Diameter of trailing mesh. Default is 1.
  52201. * @param length Length of trailing mesh. Default is 60.
  52202. * @param autoStart Automatically start trailing mesh. Default true.
  52203. */
  52204. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52205. /**
  52206. * "TrailMesh"
  52207. * @returns "TrailMesh"
  52208. */
  52209. getClassName(): string;
  52210. private _createMesh;
  52211. /**
  52212. * Start trailing mesh.
  52213. */
  52214. start(): void;
  52215. /**
  52216. * Stop trailing mesh.
  52217. */
  52218. stop(): void;
  52219. /**
  52220. * Update trailing mesh geometry.
  52221. */
  52222. update(): void;
  52223. /**
  52224. * Returns a new TrailMesh object.
  52225. * @param name is a string, the name given to the new mesh
  52226. * @param newGenerator use new generator object for cloned trail mesh
  52227. * @returns a new mesh
  52228. */
  52229. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52230. /**
  52231. * Serializes this trail mesh
  52232. * @param serializationObject object to write serialization to
  52233. */
  52234. serialize(serializationObject: any): void;
  52235. /**
  52236. * Parses a serialized trail mesh
  52237. * @param parsedMesh the serialized mesh
  52238. * @param scene the scene to create the trail mesh in
  52239. * @returns the created trail mesh
  52240. */
  52241. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52242. }
  52243. }
  52244. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52245. import { Vector4 } from "babylonjs/Maths/math";
  52246. import { Mesh } from "babylonjs/Meshes/mesh";
  52247. /**
  52248. * Class containing static functions to help procedurally build meshes
  52249. */
  52250. export class TorusKnotBuilder {
  52251. /**
  52252. * Creates a torus knot mesh
  52253. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52254. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52255. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52256. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52260. * @param name defines the name of the mesh
  52261. * @param options defines the options used to create the mesh
  52262. * @param scene defines the hosting scene
  52263. * @returns the torus knot mesh
  52264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52265. */
  52266. static CreateTorusKnot(name: string, options: {
  52267. radius?: number;
  52268. tube?: number;
  52269. radialSegments?: number;
  52270. tubularSegments?: number;
  52271. p?: number;
  52272. q?: number;
  52273. updatable?: boolean;
  52274. sideOrientation?: number;
  52275. frontUVs?: Vector4;
  52276. backUVs?: Vector4;
  52277. }, scene: any): Mesh;
  52278. }
  52279. }
  52280. declare module "babylonjs/Meshes/polygonMesh" {
  52281. import { Scene } from "babylonjs/scene";
  52282. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52283. import { Mesh } from "babylonjs/Meshes/mesh";
  52284. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52285. /**
  52286. * Polygon
  52287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52288. */
  52289. export class Polygon {
  52290. /**
  52291. * Creates a rectangle
  52292. * @param xmin bottom X coord
  52293. * @param ymin bottom Y coord
  52294. * @param xmax top X coord
  52295. * @param ymax top Y coord
  52296. * @returns points that make the resulting rectation
  52297. */
  52298. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52299. /**
  52300. * Creates a circle
  52301. * @param radius radius of circle
  52302. * @param cx scale in x
  52303. * @param cy scale in y
  52304. * @param numberOfSides number of sides that make up the circle
  52305. * @returns points that make the resulting circle
  52306. */
  52307. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52308. /**
  52309. * Creates a polygon from input string
  52310. * @param input Input polygon data
  52311. * @returns the parsed points
  52312. */
  52313. static Parse(input: string): Vector2[];
  52314. /**
  52315. * Starts building a polygon from x and y coordinates
  52316. * @param x x coordinate
  52317. * @param y y coordinate
  52318. * @returns the started path2
  52319. */
  52320. static StartingAt(x: number, y: number): Path2;
  52321. }
  52322. /**
  52323. * Builds a polygon
  52324. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52325. */
  52326. export class PolygonMeshBuilder {
  52327. private _points;
  52328. private _outlinepoints;
  52329. private _holes;
  52330. private _name;
  52331. private _scene;
  52332. private _epoints;
  52333. private _eholes;
  52334. private _addToepoint;
  52335. /**
  52336. * Babylon reference to the earcut plugin.
  52337. */
  52338. bjsEarcut: any;
  52339. /**
  52340. * Creates a PolygonMeshBuilder
  52341. * @param name name of the builder
  52342. * @param contours Path of the polygon
  52343. * @param scene scene to add to when creating the mesh
  52344. * @param earcutInjection can be used to inject your own earcut reference
  52345. */
  52346. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52347. /**
  52348. * Adds a whole within the polygon
  52349. * @param hole Array of points defining the hole
  52350. * @returns this
  52351. */
  52352. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52353. /**
  52354. * Creates the polygon
  52355. * @param updatable If the mesh should be updatable
  52356. * @param depth The depth of the mesh created
  52357. * @returns the created mesh
  52358. */
  52359. build(updatable?: boolean, depth?: number): Mesh;
  52360. /**
  52361. * Creates the polygon
  52362. * @param depth The depth of the mesh created
  52363. * @returns the created VertexData
  52364. */
  52365. buildVertexData(depth?: number): VertexData;
  52366. /**
  52367. * Adds a side to the polygon
  52368. * @param positions points that make the polygon
  52369. * @param normals normals of the polygon
  52370. * @param uvs uvs of the polygon
  52371. * @param indices indices of the polygon
  52372. * @param bounds bounds of the polygon
  52373. * @param points points of the polygon
  52374. * @param depth depth of the polygon
  52375. * @param flip flip of the polygon
  52376. */
  52377. private addSide;
  52378. }
  52379. }
  52380. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52381. import { Scene } from "babylonjs/scene";
  52382. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52383. import { Mesh } from "babylonjs/Meshes/mesh";
  52384. import { Nullable } from "babylonjs/types";
  52385. /**
  52386. * Class containing static functions to help procedurally build meshes
  52387. */
  52388. export class PolygonBuilder {
  52389. /**
  52390. * Creates a polygon mesh
  52391. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52392. * * 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
  52393. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52396. * * Remember you can only change the shape positions, not their number when updating a polygon
  52397. * @param name defines the name of the mesh
  52398. * @param options defines the options used to create the mesh
  52399. * @param scene defines the hosting scene
  52400. * @param earcutInjection can be used to inject your own earcut reference
  52401. * @returns the polygon mesh
  52402. */
  52403. static CreatePolygon(name: string, options: {
  52404. shape: Vector3[];
  52405. holes?: Vector3[][];
  52406. depth?: number;
  52407. faceUV?: Vector4[];
  52408. faceColors?: Color4[];
  52409. updatable?: boolean;
  52410. sideOrientation?: number;
  52411. frontUVs?: Vector4;
  52412. backUVs?: Vector4;
  52413. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52414. /**
  52415. * Creates an extruded polygon mesh, with depth in the Y direction.
  52416. * * 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)
  52417. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52418. * @param name defines the name of the mesh
  52419. * @param options defines the options used to create the mesh
  52420. * @param scene defines the hosting scene
  52421. * @param earcutInjection can be used to inject your own earcut reference
  52422. * @returns the polygon mesh
  52423. */
  52424. static ExtrudePolygon(name: string, options: {
  52425. shape: Vector3[];
  52426. holes?: Vector3[][];
  52427. depth?: number;
  52428. faceUV?: Vector4[];
  52429. faceColors?: Color4[];
  52430. updatable?: boolean;
  52431. sideOrientation?: number;
  52432. frontUVs?: Vector4;
  52433. backUVs?: Vector4;
  52434. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52435. }
  52436. }
  52437. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52438. import { Scene } from "babylonjs/scene";
  52439. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52440. import { Mesh } from "babylonjs/Meshes/mesh";
  52441. import { Nullable } from "babylonjs/types";
  52442. /**
  52443. * Class containing static functions to help procedurally build meshes
  52444. */
  52445. export class LatheBuilder {
  52446. /**
  52447. * Creates lathe mesh.
  52448. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52449. * * 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
  52450. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52451. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52452. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52453. * * 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
  52454. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52455. * * 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
  52456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52460. * @param name defines the name of the mesh
  52461. * @param options defines the options used to create the mesh
  52462. * @param scene defines the hosting scene
  52463. * @returns the lathe mesh
  52464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52465. */
  52466. static CreateLathe(name: string, options: {
  52467. shape: Vector3[];
  52468. radius?: number;
  52469. tessellation?: number;
  52470. clip?: number;
  52471. arc?: number;
  52472. closed?: boolean;
  52473. updatable?: boolean;
  52474. sideOrientation?: number;
  52475. frontUVs?: Vector4;
  52476. backUVs?: Vector4;
  52477. cap?: number;
  52478. invertUV?: boolean;
  52479. }, scene?: Nullable<Scene>): Mesh;
  52480. }
  52481. }
  52482. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52483. import { Nullable } from "babylonjs/types";
  52484. import { Scene } from "babylonjs/scene";
  52485. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52486. import { Mesh } from "babylonjs/Meshes/mesh";
  52487. /**
  52488. * Class containing static functions to help procedurally build meshes
  52489. */
  52490. export class TubeBuilder {
  52491. /**
  52492. * Creates a tube mesh.
  52493. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52494. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52495. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52496. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52497. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52498. * * 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)
  52499. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52500. * * 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
  52501. * * 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
  52502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52506. * @param name defines the name of the mesh
  52507. * @param options defines the options used to create the mesh
  52508. * @param scene defines the hosting scene
  52509. * @returns the tube mesh
  52510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52511. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52512. */
  52513. static CreateTube(name: string, options: {
  52514. path: Vector3[];
  52515. radius?: number;
  52516. tessellation?: number;
  52517. radiusFunction?: {
  52518. (i: number, distance: number): number;
  52519. };
  52520. cap?: number;
  52521. arc?: number;
  52522. updatable?: boolean;
  52523. sideOrientation?: number;
  52524. frontUVs?: Vector4;
  52525. backUVs?: Vector4;
  52526. instance?: Mesh;
  52527. invertUV?: boolean;
  52528. }, scene?: Nullable<Scene>): Mesh;
  52529. }
  52530. }
  52531. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52532. import { Scene } from "babylonjs/scene";
  52533. import { Vector4 } from "babylonjs/Maths/math";
  52534. import { Mesh } from "babylonjs/Meshes/mesh";
  52535. import { Nullable } from "babylonjs/types";
  52536. /**
  52537. * Class containing static functions to help procedurally build meshes
  52538. */
  52539. export class IcoSphereBuilder {
  52540. /**
  52541. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52542. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52543. * * 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`)
  52544. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52545. * * 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
  52546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52549. * @param name defines the name of the mesh
  52550. * @param options defines the options used to create the mesh
  52551. * @param scene defines the hosting scene
  52552. * @returns the icosahedron mesh
  52553. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52554. */
  52555. static CreateIcoSphere(name: string, options: {
  52556. radius?: number;
  52557. radiusX?: number;
  52558. radiusY?: number;
  52559. radiusZ?: number;
  52560. flat?: boolean;
  52561. subdivisions?: number;
  52562. sideOrientation?: number;
  52563. frontUVs?: Vector4;
  52564. backUVs?: Vector4;
  52565. updatable?: boolean;
  52566. }, scene?: Nullable<Scene>): Mesh;
  52567. }
  52568. }
  52569. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52570. import { Vector3 } from "babylonjs/Maths/math";
  52571. import { Mesh } from "babylonjs/Meshes/mesh";
  52572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52573. /**
  52574. * Class containing static functions to help procedurally build meshes
  52575. */
  52576. export class DecalBuilder {
  52577. /**
  52578. * Creates a decal mesh.
  52579. * 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
  52580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52584. * @param name defines the name of the mesh
  52585. * @param sourceMesh defines the mesh where the decal must be applied
  52586. * @param options defines the options used to create the mesh
  52587. * @param scene defines the hosting scene
  52588. * @returns the decal mesh
  52589. * @see https://doc.babylonjs.com/how_to/decals
  52590. */
  52591. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52592. position?: Vector3;
  52593. normal?: Vector3;
  52594. size?: Vector3;
  52595. angle?: number;
  52596. }): Mesh;
  52597. }
  52598. }
  52599. declare module "babylonjs/Meshes/meshBuilder" {
  52600. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52601. import { Nullable } from "babylonjs/types";
  52602. import { Scene } from "babylonjs/scene";
  52603. import { Mesh } from "babylonjs/Meshes/mesh";
  52604. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52605. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52607. /**
  52608. * Class containing static functions to help procedurally build meshes
  52609. */
  52610. export class MeshBuilder {
  52611. /**
  52612. * Creates a box mesh
  52613. * * The parameter `size` sets the size (float) of each box side (default 1)
  52614. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52615. * * 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)
  52616. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52620. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52621. * @param name defines the name of the mesh
  52622. * @param options defines the options used to create the mesh
  52623. * @param scene defines the hosting scene
  52624. * @returns the box mesh
  52625. */
  52626. static CreateBox(name: string, options: {
  52627. size?: number;
  52628. width?: number;
  52629. height?: number;
  52630. depth?: number;
  52631. faceUV?: Vector4[];
  52632. faceColors?: Color4[];
  52633. sideOrientation?: number;
  52634. frontUVs?: Vector4;
  52635. backUVs?: Vector4;
  52636. updatable?: boolean;
  52637. }, scene?: Nullable<Scene>): Mesh;
  52638. /**
  52639. * Creates a sphere mesh
  52640. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52641. * * 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`)
  52642. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52643. * * 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
  52644. * * 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)
  52645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52648. * @param name defines the name of the mesh
  52649. * @param options defines the options used to create the mesh
  52650. * @param scene defines the hosting scene
  52651. * @returns the sphere mesh
  52652. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52653. */
  52654. static CreateSphere(name: string, options: {
  52655. segments?: number;
  52656. diameter?: number;
  52657. diameterX?: number;
  52658. diameterY?: number;
  52659. diameterZ?: number;
  52660. arc?: number;
  52661. slice?: number;
  52662. sideOrientation?: number;
  52663. frontUVs?: Vector4;
  52664. backUVs?: Vector4;
  52665. updatable?: boolean;
  52666. }, scene?: Nullable<Scene>): Mesh;
  52667. /**
  52668. * Creates a plane polygonal mesh. By default, this is a disc
  52669. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52670. * * 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
  52671. * * 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
  52672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52675. * @param name defines the name of the mesh
  52676. * @param options defines the options used to create the mesh
  52677. * @param scene defines the hosting scene
  52678. * @returns the plane polygonal mesh
  52679. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52680. */
  52681. static CreateDisc(name: string, options: {
  52682. radius?: number;
  52683. tessellation?: number;
  52684. arc?: number;
  52685. updatable?: boolean;
  52686. sideOrientation?: number;
  52687. frontUVs?: Vector4;
  52688. backUVs?: Vector4;
  52689. }, scene?: Nullable<Scene>): Mesh;
  52690. /**
  52691. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52692. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52693. * * 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`)
  52694. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52695. * * 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
  52696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52699. * @param name defines the name of the mesh
  52700. * @param options defines the options used to create the mesh
  52701. * @param scene defines the hosting scene
  52702. * @returns the icosahedron mesh
  52703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52704. */
  52705. static CreateIcoSphere(name: string, options: {
  52706. radius?: number;
  52707. radiusX?: number;
  52708. radiusY?: number;
  52709. radiusZ?: number;
  52710. flat?: boolean;
  52711. subdivisions?: number;
  52712. sideOrientation?: number;
  52713. frontUVs?: Vector4;
  52714. backUVs?: Vector4;
  52715. updatable?: boolean;
  52716. }, scene?: Nullable<Scene>): Mesh;
  52717. /**
  52718. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52719. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52720. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52721. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52722. * * 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
  52723. * * 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
  52724. * * 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
  52725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52728. * * 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
  52729. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52730. * * 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
  52731. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52733. * @param name defines the name of the mesh
  52734. * @param options defines the options used to create the mesh
  52735. * @param scene defines the hosting scene
  52736. * @returns the ribbon mesh
  52737. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52738. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52739. */
  52740. static CreateRibbon(name: string, options: {
  52741. pathArray: Vector3[][];
  52742. closeArray?: boolean;
  52743. closePath?: boolean;
  52744. offset?: number;
  52745. updatable?: boolean;
  52746. sideOrientation?: number;
  52747. frontUVs?: Vector4;
  52748. backUVs?: Vector4;
  52749. instance?: Mesh;
  52750. invertUV?: boolean;
  52751. uvs?: Vector2[];
  52752. colors?: Color4[];
  52753. }, scene?: Nullable<Scene>): Mesh;
  52754. /**
  52755. * Creates a cylinder or a cone mesh
  52756. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52757. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52758. * * 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.
  52759. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52760. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52761. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52762. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52763. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52764. * * 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).
  52765. * * 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
  52766. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52767. * * 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
  52768. * * 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.
  52769. * * If `enclose` is false, a ring surface is one element.
  52770. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52771. * * 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
  52772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52775. * @param name defines the name of the mesh
  52776. * @param options defines the options used to create the mesh
  52777. * @param scene defines the hosting scene
  52778. * @returns the cylinder mesh
  52779. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52780. */
  52781. static CreateCylinder(name: string, options: {
  52782. height?: number;
  52783. diameterTop?: number;
  52784. diameterBottom?: number;
  52785. diameter?: number;
  52786. tessellation?: number;
  52787. subdivisions?: number;
  52788. arc?: number;
  52789. faceColors?: Color4[];
  52790. faceUV?: Vector4[];
  52791. updatable?: boolean;
  52792. hasRings?: boolean;
  52793. enclose?: boolean;
  52794. sideOrientation?: number;
  52795. frontUVs?: Vector4;
  52796. backUVs?: Vector4;
  52797. }, scene?: Nullable<Scene>): Mesh;
  52798. /**
  52799. * Creates a torus mesh
  52800. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52801. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52802. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52806. * @param name defines the name of the mesh
  52807. * @param options defines the options used to create the mesh
  52808. * @param scene defines the hosting scene
  52809. * @returns the torus mesh
  52810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52811. */
  52812. static CreateTorus(name: string, options: {
  52813. diameter?: number;
  52814. thickness?: number;
  52815. tessellation?: number;
  52816. updatable?: boolean;
  52817. sideOrientation?: number;
  52818. frontUVs?: Vector4;
  52819. backUVs?: Vector4;
  52820. }, scene?: Nullable<Scene>): Mesh;
  52821. /**
  52822. * Creates a torus knot mesh
  52823. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52824. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52825. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52826. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52830. * @param name defines the name of the mesh
  52831. * @param options defines the options used to create the mesh
  52832. * @param scene defines the hosting scene
  52833. * @returns the torus knot mesh
  52834. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52835. */
  52836. static CreateTorusKnot(name: string, options: {
  52837. radius?: number;
  52838. tube?: number;
  52839. radialSegments?: number;
  52840. tubularSegments?: number;
  52841. p?: number;
  52842. q?: number;
  52843. updatable?: boolean;
  52844. sideOrientation?: number;
  52845. frontUVs?: Vector4;
  52846. backUVs?: Vector4;
  52847. }, scene?: Nullable<Scene>): Mesh;
  52848. /**
  52849. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52850. * * 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
  52851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52852. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52853. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52854. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52855. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52856. * * 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
  52857. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52860. * @param name defines the name of the new line system
  52861. * @param options defines the options used to create the line system
  52862. * @param scene defines the hosting scene
  52863. * @returns a new line system mesh
  52864. */
  52865. static CreateLineSystem(name: string, options: {
  52866. lines: Vector3[][];
  52867. updatable?: boolean;
  52868. instance?: Nullable<LinesMesh>;
  52869. colors?: Nullable<Color4[][]>;
  52870. useVertexAlpha?: boolean;
  52871. }, scene: Nullable<Scene>): LinesMesh;
  52872. /**
  52873. * Creates a line mesh
  52874. * 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
  52875. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52876. * * The parameter `points` is an array successive Vector3
  52877. * * 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
  52878. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52879. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52880. * * When updating an instance, remember that only point positions can change, not the number of points
  52881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52883. * @param name defines the name of the new line system
  52884. * @param options defines the options used to create the line system
  52885. * @param scene defines the hosting scene
  52886. * @returns a new line mesh
  52887. */
  52888. static CreateLines(name: string, options: {
  52889. points: Vector3[];
  52890. updatable?: boolean;
  52891. instance?: Nullable<LinesMesh>;
  52892. colors?: Color4[];
  52893. useVertexAlpha?: boolean;
  52894. }, scene?: Nullable<Scene>): LinesMesh;
  52895. /**
  52896. * Creates a dashed line mesh
  52897. * * 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
  52898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52899. * * The parameter `points` is an array successive Vector3
  52900. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52901. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52902. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52903. * * 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
  52904. * * When updating an instance, remember that only point positions can change, not the number of points
  52905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52906. * @param name defines the name of the mesh
  52907. * @param options defines the options used to create the mesh
  52908. * @param scene defines the hosting scene
  52909. * @returns the dashed line mesh
  52910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52911. */
  52912. static CreateDashedLines(name: string, options: {
  52913. points: Vector3[];
  52914. dashSize?: number;
  52915. gapSize?: number;
  52916. dashNb?: number;
  52917. updatable?: boolean;
  52918. instance?: LinesMesh;
  52919. }, scene?: Nullable<Scene>): LinesMesh;
  52920. /**
  52921. * 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.
  52922. * * 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.
  52923. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52924. * * 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.
  52925. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52926. * * 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
  52927. * * 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
  52928. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52933. * @param name defines the name of the mesh
  52934. * @param options defines the options used to create the mesh
  52935. * @param scene defines the hosting scene
  52936. * @returns the extruded shape mesh
  52937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52939. */
  52940. static ExtrudeShape(name: string, options: {
  52941. shape: Vector3[];
  52942. path: Vector3[];
  52943. scale?: number;
  52944. rotation?: number;
  52945. cap?: number;
  52946. updatable?: boolean;
  52947. sideOrientation?: number;
  52948. frontUVs?: Vector4;
  52949. backUVs?: Vector4;
  52950. instance?: Mesh;
  52951. invertUV?: boolean;
  52952. }, scene?: Nullable<Scene>): Mesh;
  52953. /**
  52954. * Creates an custom extruded shape mesh.
  52955. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52956. * * 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.
  52957. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52958. * * 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
  52959. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52960. * * 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
  52961. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52962. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52963. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52964. * * 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
  52965. * * 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
  52966. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52971. * @param name defines the name of the mesh
  52972. * @param options defines the options used to create the mesh
  52973. * @param scene defines the hosting scene
  52974. * @returns the custom extruded shape mesh
  52975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52978. */
  52979. static ExtrudeShapeCustom(name: string, options: {
  52980. shape: Vector3[];
  52981. path: Vector3[];
  52982. scaleFunction?: any;
  52983. rotationFunction?: any;
  52984. ribbonCloseArray?: boolean;
  52985. ribbonClosePath?: boolean;
  52986. cap?: number;
  52987. updatable?: boolean;
  52988. sideOrientation?: number;
  52989. frontUVs?: Vector4;
  52990. backUVs?: Vector4;
  52991. instance?: Mesh;
  52992. invertUV?: boolean;
  52993. }, scene?: Nullable<Scene>): Mesh;
  52994. /**
  52995. * Creates lathe mesh.
  52996. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52997. * * 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
  52998. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52999. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53000. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53001. * * 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
  53002. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53003. * * 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
  53004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53008. * @param name defines the name of the mesh
  53009. * @param options defines the options used to create the mesh
  53010. * @param scene defines the hosting scene
  53011. * @returns the lathe mesh
  53012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53013. */
  53014. static CreateLathe(name: string, options: {
  53015. shape: Vector3[];
  53016. radius?: number;
  53017. tessellation?: number;
  53018. clip?: number;
  53019. arc?: number;
  53020. closed?: boolean;
  53021. updatable?: boolean;
  53022. sideOrientation?: number;
  53023. frontUVs?: Vector4;
  53024. backUVs?: Vector4;
  53025. cap?: number;
  53026. invertUV?: boolean;
  53027. }, scene?: Nullable<Scene>): Mesh;
  53028. /**
  53029. * Creates a plane mesh
  53030. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53031. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53032. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53036. * @param name defines the name of the mesh
  53037. * @param options defines the options used to create the mesh
  53038. * @param scene defines the hosting scene
  53039. * @returns the plane mesh
  53040. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53041. */
  53042. static CreatePlane(name: string, options: {
  53043. size?: number;
  53044. width?: number;
  53045. height?: number;
  53046. sideOrientation?: number;
  53047. frontUVs?: Vector4;
  53048. backUVs?: Vector4;
  53049. updatable?: boolean;
  53050. sourcePlane?: Plane;
  53051. }, scene?: Nullable<Scene>): Mesh;
  53052. /**
  53053. * Creates a ground mesh
  53054. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53055. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53057. * @param name defines the name of the mesh
  53058. * @param options defines the options used to create the mesh
  53059. * @param scene defines the hosting scene
  53060. * @returns the ground mesh
  53061. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53062. */
  53063. static CreateGround(name: string, options: {
  53064. width?: number;
  53065. height?: number;
  53066. subdivisions?: number;
  53067. subdivisionsX?: number;
  53068. subdivisionsY?: number;
  53069. updatable?: boolean;
  53070. }, scene?: Nullable<Scene>): Mesh;
  53071. /**
  53072. * Creates a tiled ground mesh
  53073. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53074. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53075. * * 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
  53076. * * 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
  53077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53078. * @param name defines the name of the mesh
  53079. * @param options defines the options used to create the mesh
  53080. * @param scene defines the hosting scene
  53081. * @returns the tiled ground mesh
  53082. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53083. */
  53084. static CreateTiledGround(name: string, options: {
  53085. xmin: number;
  53086. zmin: number;
  53087. xmax: number;
  53088. zmax: number;
  53089. subdivisions?: {
  53090. w: number;
  53091. h: number;
  53092. };
  53093. precision?: {
  53094. w: number;
  53095. h: number;
  53096. };
  53097. updatable?: boolean;
  53098. }, scene?: Nullable<Scene>): Mesh;
  53099. /**
  53100. * Creates a ground mesh from a height map
  53101. * * The parameter `url` sets the URL of the height map image resource.
  53102. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53103. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53104. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53105. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53106. * * 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.
  53107. * * 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).
  53108. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53110. * @param name defines the name of the mesh
  53111. * @param url defines the url to the height map
  53112. * @param options defines the options used to create the mesh
  53113. * @param scene defines the hosting scene
  53114. * @returns the ground mesh
  53115. * @see https://doc.babylonjs.com/babylon101/height_map
  53116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53117. */
  53118. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53119. width?: number;
  53120. height?: number;
  53121. subdivisions?: number;
  53122. minHeight?: number;
  53123. maxHeight?: number;
  53124. colorFilter?: Color3;
  53125. alphaFilter?: number;
  53126. updatable?: boolean;
  53127. onReady?: (mesh: GroundMesh) => void;
  53128. }, scene?: Nullable<Scene>): GroundMesh;
  53129. /**
  53130. * Creates a polygon mesh
  53131. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53132. * * 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
  53133. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53136. * * Remember you can only change the shape positions, not their number when updating a polygon
  53137. * @param name defines the name of the mesh
  53138. * @param options defines the options used to create the mesh
  53139. * @param scene defines the hosting scene
  53140. * @param earcutInjection can be used to inject your own earcut reference
  53141. * @returns the polygon mesh
  53142. */
  53143. static CreatePolygon(name: string, options: {
  53144. shape: Vector3[];
  53145. holes?: Vector3[][];
  53146. depth?: number;
  53147. faceUV?: Vector4[];
  53148. faceColors?: Color4[];
  53149. updatable?: boolean;
  53150. sideOrientation?: number;
  53151. frontUVs?: Vector4;
  53152. backUVs?: Vector4;
  53153. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53154. /**
  53155. * Creates an extruded polygon mesh, with depth in the Y direction.
  53156. * * 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)
  53157. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53158. * @param name defines the name of the mesh
  53159. * @param options defines the options used to create the mesh
  53160. * @param scene defines the hosting scene
  53161. * @param earcutInjection can be used to inject your own earcut reference
  53162. * @returns the polygon mesh
  53163. */
  53164. static ExtrudePolygon(name: string, options: {
  53165. shape: Vector3[];
  53166. holes?: Vector3[][];
  53167. depth?: number;
  53168. faceUV?: Vector4[];
  53169. faceColors?: Color4[];
  53170. updatable?: boolean;
  53171. sideOrientation?: number;
  53172. frontUVs?: Vector4;
  53173. backUVs?: Vector4;
  53174. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53175. /**
  53176. * Creates a tube mesh.
  53177. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53178. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53179. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53180. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53181. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53182. * * 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)
  53183. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53184. * * 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
  53185. * * 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
  53186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53190. * @param name defines the name of the mesh
  53191. * @param options defines the options used to create the mesh
  53192. * @param scene defines the hosting scene
  53193. * @returns the tube mesh
  53194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53195. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53196. */
  53197. static CreateTube(name: string, options: {
  53198. path: Vector3[];
  53199. radius?: number;
  53200. tessellation?: number;
  53201. radiusFunction?: {
  53202. (i: number, distance: number): number;
  53203. };
  53204. cap?: number;
  53205. arc?: number;
  53206. updatable?: boolean;
  53207. sideOrientation?: number;
  53208. frontUVs?: Vector4;
  53209. backUVs?: Vector4;
  53210. instance?: Mesh;
  53211. invertUV?: boolean;
  53212. }, scene?: Nullable<Scene>): Mesh;
  53213. /**
  53214. * Creates a polyhedron mesh
  53215. * * 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
  53216. * * The parameter `size` (positive float, default 1) sets the polygon size
  53217. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53218. * * 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`
  53219. * * 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
  53220. * * 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)`)
  53221. * * 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
  53222. * * 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
  53223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53226. * @param name defines the name of the mesh
  53227. * @param options defines the options used to create the mesh
  53228. * @param scene defines the hosting scene
  53229. * @returns the polyhedron mesh
  53230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53231. */
  53232. static CreatePolyhedron(name: string, options: {
  53233. type?: number;
  53234. size?: number;
  53235. sizeX?: number;
  53236. sizeY?: number;
  53237. sizeZ?: number;
  53238. custom?: any;
  53239. faceUV?: Vector4[];
  53240. faceColors?: Color4[];
  53241. flat?: boolean;
  53242. updatable?: boolean;
  53243. sideOrientation?: number;
  53244. frontUVs?: Vector4;
  53245. backUVs?: Vector4;
  53246. }, scene?: Nullable<Scene>): Mesh;
  53247. /**
  53248. * Creates a decal mesh.
  53249. * 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
  53250. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53251. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53252. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53253. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53254. * @param name defines the name of the mesh
  53255. * @param sourceMesh defines the mesh where the decal must be applied
  53256. * @param options defines the options used to create the mesh
  53257. * @param scene defines the hosting scene
  53258. * @returns the decal mesh
  53259. * @see https://doc.babylonjs.com/how_to/decals
  53260. */
  53261. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53262. position?: Vector3;
  53263. normal?: Vector3;
  53264. size?: Vector3;
  53265. angle?: number;
  53266. }): Mesh;
  53267. }
  53268. }
  53269. declare module "babylonjs/Meshes/meshSimplification" {
  53270. import { Mesh } from "babylonjs/Meshes/mesh";
  53271. /**
  53272. * A simplifier interface for future simplification implementations
  53273. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53274. */
  53275. export interface ISimplifier {
  53276. /**
  53277. * Simplification of a given mesh according to the given settings.
  53278. * Since this requires computation, it is assumed that the function runs async.
  53279. * @param settings The settings of the simplification, including quality and distance
  53280. * @param successCallback A callback that will be called after the mesh was simplified.
  53281. * @param errorCallback in case of an error, this callback will be called. optional.
  53282. */
  53283. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53284. }
  53285. /**
  53286. * Expected simplification settings.
  53287. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53289. */
  53290. export interface ISimplificationSettings {
  53291. /**
  53292. * Gets or sets the expected quality
  53293. */
  53294. quality: number;
  53295. /**
  53296. * Gets or sets the distance when this optimized version should be used
  53297. */
  53298. distance: number;
  53299. /**
  53300. * Gets an already optimized mesh
  53301. */
  53302. optimizeMesh?: boolean;
  53303. }
  53304. /**
  53305. * Class used to specify simplification options
  53306. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53307. */
  53308. export class SimplificationSettings implements ISimplificationSettings {
  53309. /** expected quality */
  53310. quality: number;
  53311. /** distance when this optimized version should be used */
  53312. distance: number;
  53313. /** already optimized mesh */
  53314. optimizeMesh?: boolean | undefined;
  53315. /**
  53316. * Creates a SimplificationSettings
  53317. * @param quality expected quality
  53318. * @param distance distance when this optimized version should be used
  53319. * @param optimizeMesh already optimized mesh
  53320. */
  53321. constructor(
  53322. /** expected quality */
  53323. quality: number,
  53324. /** distance when this optimized version should be used */
  53325. distance: number,
  53326. /** already optimized mesh */
  53327. optimizeMesh?: boolean | undefined);
  53328. }
  53329. /**
  53330. * Interface used to define a simplification task
  53331. */
  53332. export interface ISimplificationTask {
  53333. /**
  53334. * Array of settings
  53335. */
  53336. settings: Array<ISimplificationSettings>;
  53337. /**
  53338. * Simplification type
  53339. */
  53340. simplificationType: SimplificationType;
  53341. /**
  53342. * Mesh to simplify
  53343. */
  53344. mesh: Mesh;
  53345. /**
  53346. * Callback called on success
  53347. */
  53348. successCallback?: () => void;
  53349. /**
  53350. * Defines if parallel processing can be used
  53351. */
  53352. parallelProcessing: boolean;
  53353. }
  53354. /**
  53355. * Queue used to order the simplification tasks
  53356. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53357. */
  53358. export class SimplificationQueue {
  53359. private _simplificationArray;
  53360. /**
  53361. * Gets a boolean indicating that the process is still running
  53362. */
  53363. running: boolean;
  53364. /**
  53365. * Creates a new queue
  53366. */
  53367. constructor();
  53368. /**
  53369. * Adds a new simplification task
  53370. * @param task defines a task to add
  53371. */
  53372. addTask(task: ISimplificationTask): void;
  53373. /**
  53374. * Execute next task
  53375. */
  53376. executeNext(): void;
  53377. /**
  53378. * Execute a simplification task
  53379. * @param task defines the task to run
  53380. */
  53381. runSimplification(task: ISimplificationTask): void;
  53382. private getSimplifier;
  53383. }
  53384. /**
  53385. * The implemented types of simplification
  53386. * At the moment only Quadratic Error Decimation is implemented
  53387. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53388. */
  53389. export enum SimplificationType {
  53390. /** Quadratic error decimation */
  53391. QUADRATIC = 0
  53392. }
  53393. }
  53394. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53395. import { Scene } from "babylonjs/scene";
  53396. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53397. import { ISceneComponent } from "babylonjs/sceneComponent";
  53398. module "babylonjs/scene" {
  53399. interface Scene {
  53400. /** @hidden (Backing field) */
  53401. _simplificationQueue: SimplificationQueue;
  53402. /**
  53403. * Gets or sets the simplification queue attached to the scene
  53404. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53405. */
  53406. simplificationQueue: SimplificationQueue;
  53407. }
  53408. }
  53409. module "babylonjs/Meshes/mesh" {
  53410. interface Mesh {
  53411. /**
  53412. * Simplify the mesh according to the given array of settings.
  53413. * Function will return immediately and will simplify async
  53414. * @param settings a collection of simplification settings
  53415. * @param parallelProcessing should all levels calculate parallel or one after the other
  53416. * @param simplificationType the type of simplification to run
  53417. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53418. * @returns the current mesh
  53419. */
  53420. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53421. }
  53422. }
  53423. /**
  53424. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53425. * created in a scene
  53426. */
  53427. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53428. /**
  53429. * The component name helpfull to identify the component in the list of scene components.
  53430. */
  53431. readonly name: string;
  53432. /**
  53433. * The scene the component belongs to.
  53434. */
  53435. scene: Scene;
  53436. /**
  53437. * Creates a new instance of the component for the given scene
  53438. * @param scene Defines the scene to register the component in
  53439. */
  53440. constructor(scene: Scene);
  53441. /**
  53442. * Registers the component in a given scene
  53443. */
  53444. register(): void;
  53445. /**
  53446. * Rebuilds the elements related to this component in case of
  53447. * context lost for instance.
  53448. */
  53449. rebuild(): void;
  53450. /**
  53451. * Disposes the component and the associated ressources
  53452. */
  53453. dispose(): void;
  53454. private _beforeCameraUpdate;
  53455. }
  53456. }
  53457. declare module "babylonjs/Meshes/Builders/index" {
  53458. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53459. export * from "babylonjs/Meshes/Builders/discBuilder";
  53460. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53461. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53462. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53463. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53464. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53465. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53466. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53467. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53468. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53469. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53470. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53471. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53472. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53473. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53474. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53475. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53476. }
  53477. declare module "babylonjs/Meshes/index" {
  53478. export * from "babylonjs/Meshes/abstractMesh";
  53479. export * from "babylonjs/Meshes/buffer";
  53480. export * from "babylonjs/Meshes/Compression/index";
  53481. export * from "babylonjs/Meshes/csg";
  53482. export * from "babylonjs/Meshes/geometry";
  53483. export * from "babylonjs/Meshes/groundMesh";
  53484. export * from "babylonjs/Meshes/trailMesh";
  53485. export * from "babylonjs/Meshes/instancedMesh";
  53486. export * from "babylonjs/Meshes/linesMesh";
  53487. export * from "babylonjs/Meshes/mesh";
  53488. export * from "babylonjs/Meshes/mesh.vertexData";
  53489. export * from "babylonjs/Meshes/meshBuilder";
  53490. export * from "babylonjs/Meshes/meshSimplification";
  53491. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53492. export * from "babylonjs/Meshes/polygonMesh";
  53493. export * from "babylonjs/Meshes/subMesh";
  53494. export * from "babylonjs/Meshes/meshLODLevel";
  53495. export * from "babylonjs/Meshes/transformNode";
  53496. export * from "babylonjs/Meshes/Builders/index";
  53497. export * from "babylonjs/Meshes/dataBuffer";
  53498. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53499. }
  53500. declare module "babylonjs/Morph/index" {
  53501. export * from "babylonjs/Morph/morphTarget";
  53502. export * from "babylonjs/Morph/morphTargetManager";
  53503. }
  53504. declare module "babylonjs/Offline/database" {
  53505. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53506. /**
  53507. * Class used to enable access to IndexedDB
  53508. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53509. */
  53510. export class Database implements IOfflineProvider {
  53511. private _callbackManifestChecked;
  53512. private _currentSceneUrl;
  53513. private _db;
  53514. private _enableSceneOffline;
  53515. private _enableTexturesOffline;
  53516. private _manifestVersionFound;
  53517. private _mustUpdateRessources;
  53518. private _hasReachedQuota;
  53519. private _isSupported;
  53520. private _idbFactory;
  53521. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53522. private static IsUASupportingBlobStorage;
  53523. /**
  53524. * Gets a boolean indicating if Database storate is enabled (off by default)
  53525. */
  53526. static IDBStorageEnabled: boolean;
  53527. /**
  53528. * Gets a boolean indicating if scene must be saved in the database
  53529. */
  53530. readonly enableSceneOffline: boolean;
  53531. /**
  53532. * Gets a boolean indicating if textures must be saved in the database
  53533. */
  53534. readonly enableTexturesOffline: boolean;
  53535. /**
  53536. * Creates a new Database
  53537. * @param urlToScene defines the url to load the scene
  53538. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53539. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53540. */
  53541. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53542. private static _ParseURL;
  53543. private static _ReturnFullUrlLocation;
  53544. private _checkManifestFile;
  53545. /**
  53546. * Open the database and make it available
  53547. * @param successCallback defines the callback to call on success
  53548. * @param errorCallback defines the callback to call on error
  53549. */
  53550. open(successCallback: () => void, errorCallback: () => void): void;
  53551. /**
  53552. * Loads an image from the database
  53553. * @param url defines the url to load from
  53554. * @param image defines the target DOM image
  53555. */
  53556. loadImage(url: string, image: HTMLImageElement): void;
  53557. private _loadImageFromDBAsync;
  53558. private _saveImageIntoDBAsync;
  53559. private _checkVersionFromDB;
  53560. private _loadVersionFromDBAsync;
  53561. private _saveVersionIntoDBAsync;
  53562. /**
  53563. * Loads a file from database
  53564. * @param url defines the URL to load from
  53565. * @param sceneLoaded defines a callback to call on success
  53566. * @param progressCallBack defines a callback to call when progress changed
  53567. * @param errorCallback defines a callback to call on error
  53568. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53569. */
  53570. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53571. private _loadFileAsync;
  53572. private _saveFileAsync;
  53573. /**
  53574. * Validates if xhr data is correct
  53575. * @param xhr defines the request to validate
  53576. * @param dataType defines the expected data type
  53577. * @returns true if data is correct
  53578. */
  53579. private static _ValidateXHRData;
  53580. }
  53581. }
  53582. declare module "babylonjs/Offline/index" {
  53583. export * from "babylonjs/Offline/database";
  53584. export * from "babylonjs/Offline/IOfflineProvider";
  53585. }
  53586. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53587. /** @hidden */
  53588. export var gpuUpdateParticlesPixelShader: {
  53589. name: string;
  53590. shader: string;
  53591. };
  53592. }
  53593. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53594. /** @hidden */
  53595. export var gpuUpdateParticlesVertexShader: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53601. /** @hidden */
  53602. export var clipPlaneFragmentDeclaration2: {
  53603. name: string;
  53604. shader: string;
  53605. };
  53606. }
  53607. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53608. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53609. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53611. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53612. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53613. /** @hidden */
  53614. export var gpuRenderParticlesPixelShader: {
  53615. name: string;
  53616. shader: string;
  53617. };
  53618. }
  53619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53620. /** @hidden */
  53621. export var clipPlaneVertexDeclaration2: {
  53622. name: string;
  53623. shader: string;
  53624. };
  53625. }
  53626. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53628. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53629. /** @hidden */
  53630. export var gpuRenderParticlesVertexShader: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module "babylonjs/Particles/gpuParticleSystem" {
  53636. import { Nullable } from "babylonjs/types";
  53637. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53638. import { Observable } from "babylonjs/Misc/observable";
  53639. import { Color4, Color3 } from "babylonjs/Maths/math";
  53640. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53641. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53642. import { Scene, IDisposable } from "babylonjs/scene";
  53643. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53644. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53645. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53646. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53647. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53648. /**
  53649. * This represents a GPU particle system in Babylon
  53650. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53651. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53652. */
  53653. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53654. /**
  53655. * The layer mask we are rendering the particles through.
  53656. */
  53657. layerMask: number;
  53658. private _capacity;
  53659. private _activeCount;
  53660. private _currentActiveCount;
  53661. private _accumulatedCount;
  53662. private _renderEffect;
  53663. private _updateEffect;
  53664. private _buffer0;
  53665. private _buffer1;
  53666. private _spriteBuffer;
  53667. private _updateVAO;
  53668. private _renderVAO;
  53669. private _targetIndex;
  53670. private _sourceBuffer;
  53671. private _targetBuffer;
  53672. private _engine;
  53673. private _currentRenderId;
  53674. private _started;
  53675. private _stopped;
  53676. private _timeDelta;
  53677. private _randomTexture;
  53678. private _randomTexture2;
  53679. private _attributesStrideSize;
  53680. private _updateEffectOptions;
  53681. private _randomTextureSize;
  53682. private _actualFrame;
  53683. private readonly _rawTextureWidth;
  53684. /**
  53685. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53686. */
  53687. static readonly IsSupported: boolean;
  53688. /**
  53689. * An event triggered when the system is disposed.
  53690. */
  53691. onDisposeObservable: Observable<GPUParticleSystem>;
  53692. /**
  53693. * Gets the maximum number of particles active at the same time.
  53694. * @returns The max number of active particles.
  53695. */
  53696. getCapacity(): number;
  53697. /**
  53698. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53699. * to override the particles.
  53700. */
  53701. forceDepthWrite: boolean;
  53702. /**
  53703. * Gets or set the number of active particles
  53704. */
  53705. activeParticleCount: number;
  53706. private _preWarmDone;
  53707. /**
  53708. * Is this system ready to be used/rendered
  53709. * @return true if the system is ready
  53710. */
  53711. isReady(): boolean;
  53712. /**
  53713. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53714. * @returns True if it has been started, otherwise false.
  53715. */
  53716. isStarted(): boolean;
  53717. /**
  53718. * Starts the particle system and begins to emit
  53719. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53720. */
  53721. start(delay?: number): void;
  53722. /**
  53723. * Stops the particle system.
  53724. */
  53725. stop(): void;
  53726. /**
  53727. * Remove all active particles
  53728. */
  53729. reset(): void;
  53730. /**
  53731. * Returns the string "GPUParticleSystem"
  53732. * @returns a string containing the class name
  53733. */
  53734. getClassName(): string;
  53735. private _colorGradientsTexture;
  53736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53737. /**
  53738. * Adds a new color gradient
  53739. * @param gradient defines the gradient to use (between 0 and 1)
  53740. * @param color1 defines the color to affect to the specified gradient
  53741. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53742. * @returns the current particle system
  53743. */
  53744. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53745. /**
  53746. * Remove a specific color gradient
  53747. * @param gradient defines the gradient to remove
  53748. * @returns the current particle system
  53749. */
  53750. removeColorGradient(gradient: number): GPUParticleSystem;
  53751. private _angularSpeedGradientsTexture;
  53752. private _sizeGradientsTexture;
  53753. private _velocityGradientsTexture;
  53754. private _limitVelocityGradientsTexture;
  53755. private _dragGradientsTexture;
  53756. private _addFactorGradient;
  53757. /**
  53758. * Adds a new size gradient
  53759. * @param gradient defines the gradient to use (between 0 and 1)
  53760. * @param factor defines the size factor to affect to the specified gradient
  53761. * @returns the current particle system
  53762. */
  53763. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53764. /**
  53765. * Remove a specific size gradient
  53766. * @param gradient defines the gradient to remove
  53767. * @returns the current particle system
  53768. */
  53769. removeSizeGradient(gradient: number): GPUParticleSystem;
  53770. /**
  53771. * Adds a new angular speed gradient
  53772. * @param gradient defines the gradient to use (between 0 and 1)
  53773. * @param factor defines the angular speed to affect to the specified gradient
  53774. * @returns the current particle system
  53775. */
  53776. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53777. /**
  53778. * Remove a specific angular speed gradient
  53779. * @param gradient defines the gradient to remove
  53780. * @returns the current particle system
  53781. */
  53782. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53783. /**
  53784. * Adds a new velocity gradient
  53785. * @param gradient defines the gradient to use (between 0 and 1)
  53786. * @param factor defines the velocity to affect to the specified gradient
  53787. * @returns the current particle system
  53788. */
  53789. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53790. /**
  53791. * Remove a specific velocity gradient
  53792. * @param gradient defines the gradient to remove
  53793. * @returns the current particle system
  53794. */
  53795. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53796. /**
  53797. * Adds a new limit velocity gradient
  53798. * @param gradient defines the gradient to use (between 0 and 1)
  53799. * @param factor defines the limit velocity value to affect to the specified gradient
  53800. * @returns the current particle system
  53801. */
  53802. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53803. /**
  53804. * Remove a specific limit velocity gradient
  53805. * @param gradient defines the gradient to remove
  53806. * @returns the current particle system
  53807. */
  53808. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53809. /**
  53810. * Adds a new drag gradient
  53811. * @param gradient defines the gradient to use (between 0 and 1)
  53812. * @param factor defines the drag value to affect to the specified gradient
  53813. * @returns the current particle system
  53814. */
  53815. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53816. /**
  53817. * Remove a specific drag gradient
  53818. * @param gradient defines the gradient to remove
  53819. * @returns the current particle system
  53820. */
  53821. removeDragGradient(gradient: number): GPUParticleSystem;
  53822. /**
  53823. * Not supported by GPUParticleSystem
  53824. * @param gradient defines the gradient to use (between 0 and 1)
  53825. * @param factor defines the emit rate value to affect to the specified gradient
  53826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53827. * @returns the current particle system
  53828. */
  53829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53830. /**
  53831. * Not supported by GPUParticleSystem
  53832. * @param gradient defines the gradient to remove
  53833. * @returns the current particle system
  53834. */
  53835. removeEmitRateGradient(gradient: number): IParticleSystem;
  53836. /**
  53837. * Not supported by GPUParticleSystem
  53838. * @param gradient defines the gradient to use (between 0 and 1)
  53839. * @param factor defines the start size value to affect to the specified gradient
  53840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53841. * @returns the current particle system
  53842. */
  53843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53844. /**
  53845. * Not supported by GPUParticleSystem
  53846. * @param gradient defines the gradient to remove
  53847. * @returns the current particle system
  53848. */
  53849. removeStartSizeGradient(gradient: number): IParticleSystem;
  53850. /**
  53851. * Not supported by GPUParticleSystem
  53852. * @param gradient defines the gradient to use (between 0 and 1)
  53853. * @param min defines the color remap minimal range
  53854. * @param max defines the color remap maximal range
  53855. * @returns the current particle system
  53856. */
  53857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53858. /**
  53859. * Not supported by GPUParticleSystem
  53860. * @param gradient defines the gradient to remove
  53861. * @returns the current particle system
  53862. */
  53863. removeColorRemapGradient(): IParticleSystem;
  53864. /**
  53865. * Not supported by GPUParticleSystem
  53866. * @param gradient defines the gradient to use (between 0 and 1)
  53867. * @param min defines the alpha remap minimal range
  53868. * @param max defines the alpha remap maximal range
  53869. * @returns the current particle system
  53870. */
  53871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53872. /**
  53873. * Not supported by GPUParticleSystem
  53874. * @param gradient defines the gradient to remove
  53875. * @returns the current particle system
  53876. */
  53877. removeAlphaRemapGradient(): IParticleSystem;
  53878. /**
  53879. * Not supported by GPUParticleSystem
  53880. * @param gradient defines the gradient to use (between 0 and 1)
  53881. * @param color defines the color to affect to the specified gradient
  53882. * @returns the current particle system
  53883. */
  53884. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53885. /**
  53886. * Not supported by GPUParticleSystem
  53887. * @param gradient defines the gradient to remove
  53888. * @returns the current particle system
  53889. */
  53890. removeRampGradient(): IParticleSystem;
  53891. /**
  53892. * Not supported by GPUParticleSystem
  53893. * @returns the list of ramp gradients
  53894. */
  53895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53896. /**
  53897. * Not supported by GPUParticleSystem
  53898. * Gets or sets a boolean indicating that ramp gradients must be used
  53899. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53900. */
  53901. useRampGradients: boolean;
  53902. /**
  53903. * Not supported by GPUParticleSystem
  53904. * @param gradient defines the gradient to use (between 0 and 1)
  53905. * @param factor defines the life time factor to affect to the specified gradient
  53906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53907. * @returns the current particle system
  53908. */
  53909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53910. /**
  53911. * Not supported by GPUParticleSystem
  53912. * @param gradient defines the gradient to remove
  53913. * @returns the current particle system
  53914. */
  53915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53916. /**
  53917. * Instantiates a GPU particle system.
  53918. * 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.
  53919. * @param name The name of the particle system
  53920. * @param options The options used to create the system
  53921. * @param scene The scene the particle system belongs to
  53922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53923. */
  53924. constructor(name: string, options: Partial<{
  53925. capacity: number;
  53926. randomTextureSize: number;
  53927. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53928. protected _reset(): void;
  53929. private _createUpdateVAO;
  53930. private _createRenderVAO;
  53931. private _initialize;
  53932. /** @hidden */
  53933. _recreateUpdateEffect(): void;
  53934. /** @hidden */
  53935. _recreateRenderEffect(): void;
  53936. /**
  53937. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53938. * @param preWarm defines if we are in the pre-warmimg phase
  53939. */
  53940. animate(preWarm?: boolean): void;
  53941. private _createFactorGradientTexture;
  53942. private _createSizeGradientTexture;
  53943. private _createAngularSpeedGradientTexture;
  53944. private _createVelocityGradientTexture;
  53945. private _createLimitVelocityGradientTexture;
  53946. private _createDragGradientTexture;
  53947. private _createColorGradientTexture;
  53948. /**
  53949. * Renders the particle system in its current state
  53950. * @param preWarm defines if the system should only update the particles but not render them
  53951. * @returns the current number of particles
  53952. */
  53953. render(preWarm?: boolean): number;
  53954. /**
  53955. * Rebuilds the particle system
  53956. */
  53957. rebuild(): void;
  53958. private _releaseBuffers;
  53959. private _releaseVAOs;
  53960. /**
  53961. * Disposes the particle system and free the associated resources
  53962. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53963. */
  53964. dispose(disposeTexture?: boolean): void;
  53965. /**
  53966. * Clones the particle system.
  53967. * @param name The name of the cloned object
  53968. * @param newEmitter The new emitter to use
  53969. * @returns the cloned particle system
  53970. */
  53971. clone(name: string, newEmitter: any): GPUParticleSystem;
  53972. /**
  53973. * Serializes the particle system to a JSON object.
  53974. * @returns the JSON object
  53975. */
  53976. serialize(): any;
  53977. /**
  53978. * Parses a JSON object to create a GPU particle system.
  53979. * @param parsedParticleSystem The JSON object to parse
  53980. * @param scene The scene to create the particle system in
  53981. * @param rootUrl The root url to use to load external dependencies like texture
  53982. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53983. * @returns the parsed GPU particle system
  53984. */
  53985. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53986. }
  53987. }
  53988. declare module "babylonjs/Particles/particleSystemSet" {
  53989. import { Nullable } from "babylonjs/types";
  53990. import { Color3 } from "babylonjs/Maths/math";
  53991. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53994. import { Scene, IDisposable } from "babylonjs/scene";
  53995. /**
  53996. * Represents a set of particle systems working together to create a specific effect
  53997. */
  53998. export class ParticleSystemSet implements IDisposable {
  53999. private _emitterCreationOptions;
  54000. private _emitterNode;
  54001. /**
  54002. * Gets the particle system list
  54003. */
  54004. systems: IParticleSystem[];
  54005. /**
  54006. * Gets the emitter node used with this set
  54007. */
  54008. readonly emitterNode: Nullable<TransformNode>;
  54009. /**
  54010. * Creates a new emitter mesh as a sphere
  54011. * @param options defines the options used to create the sphere
  54012. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54013. * @param scene defines the hosting scene
  54014. */
  54015. setEmitterAsSphere(options: {
  54016. diameter: number;
  54017. segments: number;
  54018. color: Color3;
  54019. }, renderingGroupId: number, scene: Scene): void;
  54020. /**
  54021. * Starts all particle systems of the set
  54022. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54023. */
  54024. start(emitter?: AbstractMesh): void;
  54025. /**
  54026. * Release all associated resources
  54027. */
  54028. dispose(): void;
  54029. /**
  54030. * Serialize the set into a JSON compatible object
  54031. * @returns a JSON compatible representation of the set
  54032. */
  54033. serialize(): any;
  54034. /**
  54035. * Parse a new ParticleSystemSet from a serialized source
  54036. * @param data defines a JSON compatible representation of the set
  54037. * @param scene defines the hosting scene
  54038. * @param gpu defines if we want GPU particles or CPU particles
  54039. * @returns a new ParticleSystemSet
  54040. */
  54041. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54042. }
  54043. }
  54044. declare module "babylonjs/Particles/particleHelper" {
  54045. import { Nullable } from "babylonjs/types";
  54046. import { Scene } from "babylonjs/scene";
  54047. import { Vector3 } from "babylonjs/Maths/math";
  54048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54049. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54050. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54051. /**
  54052. * This class is made for on one-liner static method to help creating particle system set.
  54053. */
  54054. export class ParticleHelper {
  54055. /**
  54056. * Gets or sets base Assets URL
  54057. */
  54058. static BaseAssetsUrl: string;
  54059. /**
  54060. * Create a default particle system that you can tweak
  54061. * @param emitter defines the emitter to use
  54062. * @param capacity defines the system capacity (default is 500 particles)
  54063. * @param scene defines the hosting scene
  54064. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54065. * @returns the new Particle system
  54066. */
  54067. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54068. /**
  54069. * This is the main static method (one-liner) of this helper to create different particle systems
  54070. * @param type This string represents the type to the particle system to create
  54071. * @param scene The scene where the particle system should live
  54072. * @param gpu If the system will use gpu
  54073. * @returns the ParticleSystemSet created
  54074. */
  54075. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54076. /**
  54077. * Static function used to export a particle system to a ParticleSystemSet variable.
  54078. * Please note that the emitter shape is not exported
  54079. * @param systems defines the particle systems to export
  54080. * @returns the created particle system set
  54081. */
  54082. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54083. }
  54084. }
  54085. declare module "babylonjs/Particles/particleSystemComponent" {
  54086. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54087. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54088. import "babylonjs/Shaders/particles.vertex";
  54089. module "babylonjs/Engines/engine" {
  54090. interface Engine {
  54091. /**
  54092. * Create an effect to use with particle systems.
  54093. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54094. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54095. * @param uniformsNames defines a list of attribute names
  54096. * @param samplers defines an array of string used to represent textures
  54097. * @param defines defines the string containing the defines to use to compile the shaders
  54098. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54099. * @param onCompiled defines a function to call when the effect creation is successful
  54100. * @param onError defines a function to call when the effect creation has failed
  54101. * @returns the new Effect
  54102. */
  54103. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54104. }
  54105. }
  54106. module "babylonjs/Meshes/mesh" {
  54107. interface Mesh {
  54108. /**
  54109. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54110. * @returns an array of IParticleSystem
  54111. */
  54112. getEmittedParticleSystems(): IParticleSystem[];
  54113. /**
  54114. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54115. * @returns an array of IParticleSystem
  54116. */
  54117. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54118. }
  54119. }
  54120. /**
  54121. * @hidden
  54122. */
  54123. export var _IDoNeedToBeInTheBuild: number;
  54124. }
  54125. declare module "babylonjs/Particles/index" {
  54126. export * from "babylonjs/Particles/baseParticleSystem";
  54127. export * from "babylonjs/Particles/EmitterTypes/index";
  54128. export * from "babylonjs/Particles/gpuParticleSystem";
  54129. export * from "babylonjs/Particles/IParticleSystem";
  54130. export * from "babylonjs/Particles/particle";
  54131. export * from "babylonjs/Particles/particleHelper";
  54132. export * from "babylonjs/Particles/particleSystem";
  54133. export * from "babylonjs/Particles/particleSystemComponent";
  54134. export * from "babylonjs/Particles/particleSystemSet";
  54135. export * from "babylonjs/Particles/solidParticle";
  54136. export * from "babylonjs/Particles/solidParticleSystem";
  54137. export * from "babylonjs/Particles/subEmitter";
  54138. }
  54139. declare module "babylonjs/Physics/physicsEngineComponent" {
  54140. import { Nullable } from "babylonjs/types";
  54141. import { Observable, Observer } from "babylonjs/Misc/observable";
  54142. import { Vector3 } from "babylonjs/Maths/math";
  54143. import { Mesh } from "babylonjs/Meshes/mesh";
  54144. import { ISceneComponent } from "babylonjs/sceneComponent";
  54145. import { Scene } from "babylonjs/scene";
  54146. import { Node } from "babylonjs/node";
  54147. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54148. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54149. module "babylonjs/scene" {
  54150. interface Scene {
  54151. /** @hidden (Backing field) */
  54152. _physicsEngine: Nullable<IPhysicsEngine>;
  54153. /**
  54154. * Gets the current physics engine
  54155. * @returns a IPhysicsEngine or null if none attached
  54156. */
  54157. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54158. /**
  54159. * Enables physics to the current scene
  54160. * @param gravity defines the scene's gravity for the physics engine
  54161. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54162. * @return a boolean indicating if the physics engine was initialized
  54163. */
  54164. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54165. /**
  54166. * Disables and disposes the physics engine associated with the scene
  54167. */
  54168. disablePhysicsEngine(): void;
  54169. /**
  54170. * Gets a boolean indicating if there is an active physics engine
  54171. * @returns a boolean indicating if there is an active physics engine
  54172. */
  54173. isPhysicsEnabled(): boolean;
  54174. /**
  54175. * Deletes a physics compound impostor
  54176. * @param compound defines the compound to delete
  54177. */
  54178. deleteCompoundImpostor(compound: any): void;
  54179. /**
  54180. * An event triggered when physic simulation is about to be run
  54181. */
  54182. onBeforePhysicsObservable: Observable<Scene>;
  54183. /**
  54184. * An event triggered when physic simulation has been done
  54185. */
  54186. onAfterPhysicsObservable: Observable<Scene>;
  54187. }
  54188. }
  54189. module "babylonjs/Meshes/abstractMesh" {
  54190. interface AbstractMesh {
  54191. /** @hidden */
  54192. _physicsImpostor: Nullable<PhysicsImpostor>;
  54193. /**
  54194. * Gets or sets impostor used for physic simulation
  54195. * @see http://doc.babylonjs.com/features/physics_engine
  54196. */
  54197. physicsImpostor: Nullable<PhysicsImpostor>;
  54198. /**
  54199. * Gets the current physics impostor
  54200. * @see http://doc.babylonjs.com/features/physics_engine
  54201. * @returns a physics impostor or null
  54202. */
  54203. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54204. /** Apply a physic impulse to the mesh
  54205. * @param force defines the force to apply
  54206. * @param contactPoint defines where to apply the force
  54207. * @returns the current mesh
  54208. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54209. */
  54210. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54211. /**
  54212. * Creates a physic joint between two meshes
  54213. * @param otherMesh defines the other mesh to use
  54214. * @param pivot1 defines the pivot to use on this mesh
  54215. * @param pivot2 defines the pivot to use on the other mesh
  54216. * @param options defines additional options (can be plugin dependent)
  54217. * @returns the current mesh
  54218. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54219. */
  54220. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54221. /** @hidden */
  54222. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54223. }
  54224. }
  54225. /**
  54226. * Defines the physics engine scene component responsible to manage a physics engine
  54227. */
  54228. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54229. /**
  54230. * The component name helpful to identify the component in the list of scene components.
  54231. */
  54232. readonly name: string;
  54233. /**
  54234. * The scene the component belongs to.
  54235. */
  54236. scene: Scene;
  54237. /**
  54238. * Creates a new instance of the component for the given scene
  54239. * @param scene Defines the scene to register the component in
  54240. */
  54241. constructor(scene: Scene);
  54242. /**
  54243. * Registers the component in a given scene
  54244. */
  54245. register(): void;
  54246. /**
  54247. * Rebuilds the elements related to this component in case of
  54248. * context lost for instance.
  54249. */
  54250. rebuild(): void;
  54251. /**
  54252. * Disposes the component and the associated ressources
  54253. */
  54254. dispose(): void;
  54255. }
  54256. }
  54257. declare module "babylonjs/Physics/physicsHelper" {
  54258. import { Nullable } from "babylonjs/types";
  54259. import { Vector3 } from "babylonjs/Maths/math";
  54260. import { Mesh } from "babylonjs/Meshes/mesh";
  54261. import { Scene } from "babylonjs/scene";
  54262. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54263. /**
  54264. * A helper for physics simulations
  54265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54266. */
  54267. export class PhysicsHelper {
  54268. private _scene;
  54269. private _physicsEngine;
  54270. /**
  54271. * Initializes the Physics helper
  54272. * @param scene Babylon.js scene
  54273. */
  54274. constructor(scene: Scene);
  54275. /**
  54276. * Applies a radial explosion impulse
  54277. * @param origin the origin of the explosion
  54278. * @param radiusOrEventOptions the radius or the options of radial explosion
  54279. * @param strength the explosion strength
  54280. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54281. * @returns A physics radial explosion event, or null
  54282. */
  54283. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54284. /**
  54285. * Applies a radial explosion force
  54286. * @param origin the origin of the explosion
  54287. * @param radiusOrEventOptions the radius or the options of radial explosion
  54288. * @param strength the explosion strength
  54289. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54290. * @returns A physics radial explosion event, or null
  54291. */
  54292. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54293. /**
  54294. * Creates a gravitational field
  54295. * @param origin the origin of the explosion
  54296. * @param radiusOrEventOptions the radius or the options of radial explosion
  54297. * @param strength the explosion strength
  54298. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54299. * @returns A physics gravitational field event, or null
  54300. */
  54301. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54302. /**
  54303. * Creates a physics updraft event
  54304. * @param origin the origin of the updraft
  54305. * @param radiusOrEventOptions the radius or the options of the updraft
  54306. * @param strength the strength of the updraft
  54307. * @param height the height of the updraft
  54308. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54309. * @returns A physics updraft event, or null
  54310. */
  54311. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54312. /**
  54313. * Creates a physics vortex event
  54314. * @param origin the of the vortex
  54315. * @param radiusOrEventOptions the radius or the options of the vortex
  54316. * @param strength the strength of the vortex
  54317. * @param height the height of the vortex
  54318. * @returns a Physics vortex event, or null
  54319. * A physics vortex event or null
  54320. */
  54321. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54322. }
  54323. /**
  54324. * Represents a physics radial explosion event
  54325. */
  54326. class PhysicsRadialExplosionEvent {
  54327. private _scene;
  54328. private _options;
  54329. private _sphere;
  54330. private _dataFetched;
  54331. /**
  54332. * Initializes a radial explosioin event
  54333. * @param _scene BabylonJS scene
  54334. * @param _options The options for the vortex event
  54335. */
  54336. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54337. /**
  54338. * Returns the data related to the radial explosion event (sphere).
  54339. * @returns The radial explosion event data
  54340. */
  54341. getData(): PhysicsRadialExplosionEventData;
  54342. /**
  54343. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54344. * @param impostor A physics imposter
  54345. * @param origin the origin of the explosion
  54346. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54347. */
  54348. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54349. /**
  54350. * Triggers affecterd impostors callbacks
  54351. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54352. */
  54353. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54354. /**
  54355. * Disposes the sphere.
  54356. * @param force Specifies if the sphere should be disposed by force
  54357. */
  54358. dispose(force?: boolean): void;
  54359. /*** Helpers ***/
  54360. private _prepareSphere;
  54361. private _intersectsWithSphere;
  54362. }
  54363. /**
  54364. * Represents a gravitational field event
  54365. */
  54366. class PhysicsGravitationalFieldEvent {
  54367. private _physicsHelper;
  54368. private _scene;
  54369. private _origin;
  54370. private _options;
  54371. private _tickCallback;
  54372. private _sphere;
  54373. private _dataFetched;
  54374. /**
  54375. * Initializes the physics gravitational field event
  54376. * @param _physicsHelper A physics helper
  54377. * @param _scene BabylonJS scene
  54378. * @param _origin The origin position of the gravitational field event
  54379. * @param _options The options for the vortex event
  54380. */
  54381. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54382. /**
  54383. * Returns the data related to the gravitational field event (sphere).
  54384. * @returns A gravitational field event
  54385. */
  54386. getData(): PhysicsGravitationalFieldEventData;
  54387. /**
  54388. * Enables the gravitational field.
  54389. */
  54390. enable(): void;
  54391. /**
  54392. * Disables the gravitational field.
  54393. */
  54394. disable(): void;
  54395. /**
  54396. * Disposes the sphere.
  54397. * @param force The force to dispose from the gravitational field event
  54398. */
  54399. dispose(force?: boolean): void;
  54400. private _tick;
  54401. }
  54402. /**
  54403. * Represents a physics updraft event
  54404. */
  54405. class PhysicsUpdraftEvent {
  54406. private _scene;
  54407. private _origin;
  54408. private _options;
  54409. private _physicsEngine;
  54410. private _originTop;
  54411. private _originDirection;
  54412. private _tickCallback;
  54413. private _cylinder;
  54414. private _cylinderPosition;
  54415. private _dataFetched;
  54416. /**
  54417. * Initializes the physics updraft event
  54418. * @param _scene BabylonJS scene
  54419. * @param _origin The origin position of the updraft
  54420. * @param _options The options for the updraft event
  54421. */
  54422. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54423. /**
  54424. * Returns the data related to the updraft event (cylinder).
  54425. * @returns A physics updraft event
  54426. */
  54427. getData(): PhysicsUpdraftEventData;
  54428. /**
  54429. * Enables the updraft.
  54430. */
  54431. enable(): void;
  54432. /**
  54433. * Disables the updraft.
  54434. */
  54435. disable(): void;
  54436. /**
  54437. * Disposes the cylinder.
  54438. * @param force Specifies if the updraft should be disposed by force
  54439. */
  54440. dispose(force?: boolean): void;
  54441. private getImpostorHitData;
  54442. private _tick;
  54443. /*** Helpers ***/
  54444. private _prepareCylinder;
  54445. private _intersectsWithCylinder;
  54446. }
  54447. /**
  54448. * Represents a physics vortex event
  54449. */
  54450. class PhysicsVortexEvent {
  54451. private _scene;
  54452. private _origin;
  54453. private _options;
  54454. private _physicsEngine;
  54455. private _originTop;
  54456. private _tickCallback;
  54457. private _cylinder;
  54458. private _cylinderPosition;
  54459. private _dataFetched;
  54460. /**
  54461. * Initializes the physics vortex event
  54462. * @param _scene The BabylonJS scene
  54463. * @param _origin The origin position of the vortex
  54464. * @param _options The options for the vortex event
  54465. */
  54466. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54467. /**
  54468. * Returns the data related to the vortex event (cylinder).
  54469. * @returns The physics vortex event data
  54470. */
  54471. getData(): PhysicsVortexEventData;
  54472. /**
  54473. * Enables the vortex.
  54474. */
  54475. enable(): void;
  54476. /**
  54477. * Disables the cortex.
  54478. */
  54479. disable(): void;
  54480. /**
  54481. * Disposes the sphere.
  54482. * @param force
  54483. */
  54484. dispose(force?: boolean): void;
  54485. private getImpostorHitData;
  54486. private _tick;
  54487. /*** Helpers ***/
  54488. private _prepareCylinder;
  54489. private _intersectsWithCylinder;
  54490. }
  54491. /**
  54492. * Options fot the radial explosion event
  54493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54494. */
  54495. export class PhysicsRadialExplosionEventOptions {
  54496. /**
  54497. * The radius of the sphere for the radial explosion.
  54498. */
  54499. radius: number;
  54500. /**
  54501. * The strenth of the explosion.
  54502. */
  54503. strength: number;
  54504. /**
  54505. * The strenght of the force in correspondence to the distance of the affected object
  54506. */
  54507. falloff: PhysicsRadialImpulseFalloff;
  54508. /**
  54509. * Sphere options for the radial explosion.
  54510. */
  54511. sphere: {
  54512. segments: number;
  54513. diameter: number;
  54514. };
  54515. /**
  54516. * Sphere options for the radial explosion.
  54517. */
  54518. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54519. }
  54520. /**
  54521. * Options fot the updraft event
  54522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54523. */
  54524. export class PhysicsUpdraftEventOptions {
  54525. /**
  54526. * The radius of the cylinder for the vortex
  54527. */
  54528. radius: number;
  54529. /**
  54530. * The strenth of the updraft.
  54531. */
  54532. strength: number;
  54533. /**
  54534. * The height of the cylinder for the updraft.
  54535. */
  54536. height: number;
  54537. /**
  54538. * The mode for the the updraft.
  54539. */
  54540. updraftMode: PhysicsUpdraftMode;
  54541. }
  54542. /**
  54543. * Options fot the vortex event
  54544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54545. */
  54546. export class PhysicsVortexEventOptions {
  54547. /**
  54548. * The radius of the cylinder for the vortex
  54549. */
  54550. radius: number;
  54551. /**
  54552. * The strenth of the vortex.
  54553. */
  54554. strength: number;
  54555. /**
  54556. * The height of the cylinder for the vortex.
  54557. */
  54558. height: number;
  54559. /**
  54560. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54561. */
  54562. centripetalForceThreshold: number;
  54563. /**
  54564. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54565. */
  54566. centripetalForceMultiplier: number;
  54567. /**
  54568. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54569. */
  54570. centrifugalForceMultiplier: number;
  54571. /**
  54572. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54573. */
  54574. updraftForceMultiplier: number;
  54575. }
  54576. /**
  54577. * The strenght of the force in correspondence to the distance of the affected object
  54578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54579. */
  54580. export enum PhysicsRadialImpulseFalloff {
  54581. /** Defines that impulse is constant in strength across it's whole radius */
  54582. Constant = 0,
  54583. /** Defines that impulse gets weaker if it's further from the origin */
  54584. Linear = 1
  54585. }
  54586. /**
  54587. * The strength of the force in correspondence to the distance of the affected object
  54588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54589. */
  54590. export enum PhysicsUpdraftMode {
  54591. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54592. Center = 0,
  54593. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54594. Perpendicular = 1
  54595. }
  54596. /**
  54597. * Interface for a physics hit data
  54598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54599. */
  54600. export interface PhysicsHitData {
  54601. /**
  54602. * The force applied at the contact point
  54603. */
  54604. force: Vector3;
  54605. /**
  54606. * The contact point
  54607. */
  54608. contactPoint: Vector3;
  54609. /**
  54610. * The distance from the origin to the contact point
  54611. */
  54612. distanceFromOrigin: number;
  54613. }
  54614. /**
  54615. * Interface for radial explosion event data
  54616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54617. */
  54618. export interface PhysicsRadialExplosionEventData {
  54619. /**
  54620. * A sphere used for the radial explosion event
  54621. */
  54622. sphere: Mesh;
  54623. }
  54624. /**
  54625. * Interface for gravitational field event data
  54626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54627. */
  54628. export interface PhysicsGravitationalFieldEventData {
  54629. /**
  54630. * A sphere mesh used for the gravitational field event
  54631. */
  54632. sphere: Mesh;
  54633. }
  54634. /**
  54635. * Interface for updraft event data
  54636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54637. */
  54638. export interface PhysicsUpdraftEventData {
  54639. /**
  54640. * A cylinder used for the updraft event
  54641. */
  54642. cylinder: Mesh;
  54643. }
  54644. /**
  54645. * Interface for vortex event data
  54646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54647. */
  54648. export interface PhysicsVortexEventData {
  54649. /**
  54650. * A cylinder used for the vortex event
  54651. */
  54652. cylinder: Mesh;
  54653. }
  54654. /**
  54655. * Interface for an affected physics impostor
  54656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54657. */
  54658. export interface PhysicsAffectedImpostorWithData {
  54659. /**
  54660. * The impostor affected by the effect
  54661. */
  54662. impostor: PhysicsImpostor;
  54663. /**
  54664. * The data about the hit/horce from the explosion
  54665. */
  54666. hitData: PhysicsHitData;
  54667. }
  54668. }
  54669. declare module "babylonjs/Physics/Plugins/index" {
  54670. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54671. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54672. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54673. }
  54674. declare module "babylonjs/Physics/index" {
  54675. export * from "babylonjs/Physics/IPhysicsEngine";
  54676. export * from "babylonjs/Physics/physicsEngine";
  54677. export * from "babylonjs/Physics/physicsEngineComponent";
  54678. export * from "babylonjs/Physics/physicsHelper";
  54679. export * from "babylonjs/Physics/physicsImpostor";
  54680. export * from "babylonjs/Physics/physicsJoint";
  54681. export * from "babylonjs/Physics/Plugins/index";
  54682. }
  54683. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54684. /** @hidden */
  54685. export var blackAndWhitePixelShader: {
  54686. name: string;
  54687. shader: string;
  54688. };
  54689. }
  54690. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54692. import { Camera } from "babylonjs/Cameras/camera";
  54693. import { Engine } from "babylonjs/Engines/engine";
  54694. import "babylonjs/Shaders/blackAndWhite.fragment";
  54695. /**
  54696. * Post process used to render in black and white
  54697. */
  54698. export class BlackAndWhitePostProcess extends PostProcess {
  54699. /**
  54700. * Linear about to convert he result to black and white (default: 1)
  54701. */
  54702. degree: number;
  54703. /**
  54704. * Creates a black and white post process
  54705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54706. * @param name The name of the effect.
  54707. * @param options The required width/height ratio to downsize to before computing the render pass.
  54708. * @param camera The camera to apply the render pass to.
  54709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54710. * @param engine The engine which the post process will be applied. (default: current engine)
  54711. * @param reusable If the post process can be reused on the same frame. (default: false)
  54712. */
  54713. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54714. }
  54715. }
  54716. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54717. import { Nullable } from "babylonjs/types";
  54718. import { Camera } from "babylonjs/Cameras/camera";
  54719. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54720. import { Engine } from "babylonjs/Engines/engine";
  54721. /**
  54722. * This represents a set of one or more post processes in Babylon.
  54723. * A post process can be used to apply a shader to a texture after it is rendered.
  54724. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54725. */
  54726. export class PostProcessRenderEffect {
  54727. private _postProcesses;
  54728. private _getPostProcesses;
  54729. private _singleInstance;
  54730. private _cameras;
  54731. private _indicesForCamera;
  54732. /**
  54733. * Name of the effect
  54734. * @hidden
  54735. */
  54736. _name: string;
  54737. /**
  54738. * Instantiates a post process render effect.
  54739. * A post process can be used to apply a shader to a texture after it is rendered.
  54740. * @param engine The engine the effect is tied to
  54741. * @param name The name of the effect
  54742. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54743. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54744. */
  54745. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54746. /**
  54747. * Checks if all the post processes in the effect are supported.
  54748. */
  54749. readonly isSupported: boolean;
  54750. /**
  54751. * Updates the current state of the effect
  54752. * @hidden
  54753. */
  54754. _update(): void;
  54755. /**
  54756. * Attaches the effect on cameras
  54757. * @param cameras The camera to attach to.
  54758. * @hidden
  54759. */
  54760. _attachCameras(cameras: Camera): void;
  54761. /**
  54762. * Attaches the effect on cameras
  54763. * @param cameras The camera to attach to.
  54764. * @hidden
  54765. */
  54766. _attachCameras(cameras: Camera[]): void;
  54767. /**
  54768. * Detaches the effect on cameras
  54769. * @param cameras The camera to detatch from.
  54770. * @hidden
  54771. */
  54772. _detachCameras(cameras: Camera): void;
  54773. /**
  54774. * Detatches the effect on cameras
  54775. * @param cameras The camera to detatch from.
  54776. * @hidden
  54777. */
  54778. _detachCameras(cameras: Camera[]): void;
  54779. /**
  54780. * Enables the effect on given cameras
  54781. * @param cameras The camera to enable.
  54782. * @hidden
  54783. */
  54784. _enable(cameras: Camera): void;
  54785. /**
  54786. * Enables the effect on given cameras
  54787. * @param cameras The camera to enable.
  54788. * @hidden
  54789. */
  54790. _enable(cameras: Nullable<Camera[]>): void;
  54791. /**
  54792. * Disables the effect on the given cameras
  54793. * @param cameras The camera to disable.
  54794. * @hidden
  54795. */
  54796. _disable(cameras: Camera): void;
  54797. /**
  54798. * Disables the effect on the given cameras
  54799. * @param cameras The camera to disable.
  54800. * @hidden
  54801. */
  54802. _disable(cameras: Nullable<Camera[]>): void;
  54803. /**
  54804. * Gets a list of the post processes contained in the effect.
  54805. * @param camera The camera to get the post processes on.
  54806. * @returns The list of the post processes in the effect.
  54807. */
  54808. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54809. }
  54810. }
  54811. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54812. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54813. /** @hidden */
  54814. export var extractHighlightsPixelShader: {
  54815. name: string;
  54816. shader: string;
  54817. };
  54818. }
  54819. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54820. import { Nullable } from "babylonjs/types";
  54821. import { Camera } from "babylonjs/Cameras/camera";
  54822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54823. import { Engine } from "babylonjs/Engines/engine";
  54824. import "babylonjs/Shaders/extractHighlights.fragment";
  54825. /**
  54826. * 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.
  54827. */
  54828. export class ExtractHighlightsPostProcess extends PostProcess {
  54829. /**
  54830. * The luminance threshold, pixels below this value will be set to black.
  54831. */
  54832. threshold: number;
  54833. /** @hidden */
  54834. _exposure: number;
  54835. /**
  54836. * Post process which has the input texture to be used when performing highlight extraction
  54837. * @hidden
  54838. */
  54839. _inputPostProcess: Nullable<PostProcess>;
  54840. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54841. }
  54842. }
  54843. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54844. /** @hidden */
  54845. export var bloomMergePixelShader: {
  54846. name: string;
  54847. shader: string;
  54848. };
  54849. }
  54850. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54852. import { Nullable } from "babylonjs/types";
  54853. import { Engine } from "babylonjs/Engines/engine";
  54854. import { Camera } from "babylonjs/Cameras/camera";
  54855. import "babylonjs/Shaders/bloomMerge.fragment";
  54856. /**
  54857. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54858. */
  54859. export class BloomMergePostProcess extends PostProcess {
  54860. /** Weight of the bloom to be added to the original input. */
  54861. weight: number;
  54862. /**
  54863. * Creates a new instance of @see BloomMergePostProcess
  54864. * @param name The name of the effect.
  54865. * @param originalFromInput Post process which's input will be used for the merge.
  54866. * @param blurred Blurred highlights post process which's output will be used.
  54867. * @param weight Weight of the bloom to be added to the original input.
  54868. * @param options The required width/height ratio to downsize to before computing the render pass.
  54869. * @param camera The camera to apply the render pass to.
  54870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54871. * @param engine The engine which the post process will be applied. (default: current engine)
  54872. * @param reusable If the post process can be reused on the same frame. (default: false)
  54873. * @param textureType Type of textures used when performing the post process. (default: 0)
  54874. * @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)
  54875. */
  54876. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54877. /** Weight of the bloom to be added to the original input. */
  54878. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54879. }
  54880. }
  54881. declare module "babylonjs/PostProcesses/bloomEffect" {
  54882. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54884. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54885. import { Camera } from "babylonjs/Cameras/camera";
  54886. import { Scene } from "babylonjs/scene";
  54887. /**
  54888. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54889. */
  54890. export class BloomEffect extends PostProcessRenderEffect {
  54891. private bloomScale;
  54892. /**
  54893. * @hidden Internal
  54894. */
  54895. _effects: Array<PostProcess>;
  54896. /**
  54897. * @hidden Internal
  54898. */
  54899. _downscale: ExtractHighlightsPostProcess;
  54900. private _blurX;
  54901. private _blurY;
  54902. private _merge;
  54903. /**
  54904. * The luminance threshold to find bright areas of the image to bloom.
  54905. */
  54906. threshold: number;
  54907. /**
  54908. * The strength of the bloom.
  54909. */
  54910. weight: number;
  54911. /**
  54912. * Specifies the size of the bloom blur kernel, relative to the final output size
  54913. */
  54914. kernel: number;
  54915. /**
  54916. * Creates a new instance of @see BloomEffect
  54917. * @param scene The scene the effect belongs to.
  54918. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54919. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54920. * @param bloomWeight The the strength of bloom.
  54921. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54922. * @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)
  54923. */
  54924. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54925. /**
  54926. * Disposes each of the internal effects for a given camera.
  54927. * @param camera The camera to dispose the effect on.
  54928. */
  54929. disposeEffects(camera: Camera): void;
  54930. /**
  54931. * @hidden Internal
  54932. */
  54933. _updateEffects(): void;
  54934. /**
  54935. * Internal
  54936. * @returns if all the contained post processes are ready.
  54937. * @hidden
  54938. */
  54939. _isReady(): boolean;
  54940. }
  54941. }
  54942. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54943. /** @hidden */
  54944. export var chromaticAberrationPixelShader: {
  54945. name: string;
  54946. shader: string;
  54947. };
  54948. }
  54949. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54950. import { Vector2 } from "babylonjs/Maths/math";
  54951. import { Nullable } from "babylonjs/types";
  54952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54953. import { Camera } from "babylonjs/Cameras/camera";
  54954. import { Engine } from "babylonjs/Engines/engine";
  54955. import "babylonjs/Shaders/chromaticAberration.fragment";
  54956. /**
  54957. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54958. */
  54959. export class ChromaticAberrationPostProcess extends PostProcess {
  54960. /**
  54961. * The amount of seperation of rgb channels (default: 30)
  54962. */
  54963. aberrationAmount: number;
  54964. /**
  54965. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54966. */
  54967. radialIntensity: number;
  54968. /**
  54969. * 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))
  54970. */
  54971. direction: Vector2;
  54972. /**
  54973. * 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))
  54974. */
  54975. centerPosition: Vector2;
  54976. /**
  54977. * Creates a new instance ChromaticAberrationPostProcess
  54978. * @param name The name of the effect.
  54979. * @param screenWidth The width of the screen to apply the effect on.
  54980. * @param screenHeight The height of the screen to apply the effect on.
  54981. * @param options The required width/height ratio to downsize to before computing the render pass.
  54982. * @param camera The camera to apply the render pass to.
  54983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54984. * @param engine The engine which the post process will be applied. (default: current engine)
  54985. * @param reusable If the post process can be reused on the same frame. (default: false)
  54986. * @param textureType Type of textures used when performing the post process. (default: 0)
  54987. * @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)
  54988. */
  54989. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54990. }
  54991. }
  54992. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54993. /** @hidden */
  54994. export var circleOfConfusionPixelShader: {
  54995. name: string;
  54996. shader: string;
  54997. };
  54998. }
  54999. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55000. import { Nullable } from "babylonjs/types";
  55001. import { Engine } from "babylonjs/Engines/engine";
  55002. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55004. import { Camera } from "babylonjs/Cameras/camera";
  55005. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55006. /**
  55007. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55008. */
  55009. export class CircleOfConfusionPostProcess extends PostProcess {
  55010. /**
  55011. * 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.
  55012. */
  55013. lensSize: number;
  55014. /**
  55015. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55016. */
  55017. fStop: number;
  55018. /**
  55019. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55020. */
  55021. focusDistance: number;
  55022. /**
  55023. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55024. */
  55025. focalLength: number;
  55026. private _depthTexture;
  55027. /**
  55028. * Creates a new instance CircleOfConfusionPostProcess
  55029. * @param name The name of the effect.
  55030. * @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.
  55031. * @param options The required width/height ratio to downsize to before computing the render pass.
  55032. * @param camera The camera to apply the render pass to.
  55033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55034. * @param engine The engine which the post process will be applied. (default: current engine)
  55035. * @param reusable If the post process can be reused on the same frame. (default: false)
  55036. * @param textureType Type of textures used when performing the post process. (default: 0)
  55037. * @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)
  55038. */
  55039. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55040. /**
  55041. * 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.
  55042. */
  55043. depthTexture: RenderTargetTexture;
  55044. }
  55045. }
  55046. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55047. /** @hidden */
  55048. export var colorCorrectionPixelShader: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55055. import { Engine } from "babylonjs/Engines/engine";
  55056. import { Camera } from "babylonjs/Cameras/camera";
  55057. import "babylonjs/Shaders/colorCorrection.fragment";
  55058. /**
  55059. *
  55060. * This post-process allows the modification of rendered colors by using
  55061. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55062. *
  55063. * The object needs to be provided an url to a texture containing the color
  55064. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55065. * Use an image editing software to tweak the LUT to match your needs.
  55066. *
  55067. * For an example of a color LUT, see here:
  55068. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55069. * For explanations on color grading, see here:
  55070. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55071. *
  55072. */
  55073. export class ColorCorrectionPostProcess extends PostProcess {
  55074. private _colorTableTexture;
  55075. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55076. }
  55077. }
  55078. declare module "babylonjs/Shaders/convolution.fragment" {
  55079. /** @hidden */
  55080. export var convolutionPixelShader: {
  55081. name: string;
  55082. shader: string;
  55083. };
  55084. }
  55085. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55087. import { Nullable } from "babylonjs/types";
  55088. import { Camera } from "babylonjs/Cameras/camera";
  55089. import { Engine } from "babylonjs/Engines/engine";
  55090. import "babylonjs/Shaders/convolution.fragment";
  55091. /**
  55092. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55093. * input texture to perform effects such as edge detection or sharpening
  55094. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55095. */
  55096. export class ConvolutionPostProcess extends PostProcess {
  55097. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55098. kernel: number[];
  55099. /**
  55100. * Creates a new instance ConvolutionPostProcess
  55101. * @param name The name of the effect.
  55102. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55103. * @param options The required width/height ratio to downsize to before computing the render pass.
  55104. * @param camera The camera to apply the render pass to.
  55105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55106. * @param engine The engine which the post process will be applied. (default: current engine)
  55107. * @param reusable If the post process can be reused on the same frame. (default: false)
  55108. * @param textureType Type of textures used when performing the post process. (default: 0)
  55109. */
  55110. constructor(name: string,
  55111. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55112. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55113. /**
  55114. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55115. */
  55116. static EdgeDetect0Kernel: number[];
  55117. /**
  55118. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. static EdgeDetect1Kernel: number[];
  55121. /**
  55122. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55123. */
  55124. static EdgeDetect2Kernel: number[];
  55125. /**
  55126. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55127. */
  55128. static SharpenKernel: number[];
  55129. /**
  55130. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55131. */
  55132. static EmbossKernel: number[];
  55133. /**
  55134. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55135. */
  55136. static GaussianKernel: number[];
  55137. }
  55138. }
  55139. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55140. import { Nullable } from "babylonjs/types";
  55141. import { Vector2 } from "babylonjs/Maths/math";
  55142. import { Camera } from "babylonjs/Cameras/camera";
  55143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55144. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55145. import { Engine } from "babylonjs/Engines/engine";
  55146. import { Scene } from "babylonjs/scene";
  55147. /**
  55148. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55149. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55150. * based on samples that have a large difference in distance than the center pixel.
  55151. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55152. */
  55153. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55154. direction: Vector2;
  55155. /**
  55156. * Creates a new instance CircleOfConfusionPostProcess
  55157. * @param name The name of the effect.
  55158. * @param scene The scene the effect belongs to.
  55159. * @param direction The direction the blur should be applied.
  55160. * @param kernel The size of the kernel used to blur.
  55161. * @param options The required width/height ratio to downsize to before computing the render pass.
  55162. * @param camera The camera to apply the render pass to.
  55163. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55164. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55166. * @param engine The engine which the post process will be applied. (default: current engine)
  55167. * @param reusable If the post process can be reused on the same frame. (default: false)
  55168. * @param textureType Type of textures used when performing the post process. (default: 0)
  55169. * @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)
  55170. */
  55171. 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);
  55172. }
  55173. }
  55174. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55175. /** @hidden */
  55176. export var depthOfFieldMergePixelShader: {
  55177. name: string;
  55178. shader: string;
  55179. };
  55180. }
  55181. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55182. import { Nullable } from "babylonjs/types";
  55183. import { Camera } from "babylonjs/Cameras/camera";
  55184. import { Effect } from "babylonjs/Materials/effect";
  55185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55186. import { Engine } from "babylonjs/Engines/engine";
  55187. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55188. /**
  55189. * Options to be set when merging outputs from the default pipeline.
  55190. */
  55191. export class DepthOfFieldMergePostProcessOptions {
  55192. /**
  55193. * The original image to merge on top of
  55194. */
  55195. originalFromInput: PostProcess;
  55196. /**
  55197. * Parameters to perform the merge of the depth of field effect
  55198. */
  55199. depthOfField?: {
  55200. circleOfConfusion: PostProcess;
  55201. blurSteps: Array<PostProcess>;
  55202. };
  55203. /**
  55204. * Parameters to perform the merge of bloom effect
  55205. */
  55206. bloom?: {
  55207. blurred: PostProcess;
  55208. weight: number;
  55209. };
  55210. }
  55211. /**
  55212. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55213. */
  55214. export class DepthOfFieldMergePostProcess extends PostProcess {
  55215. private blurSteps;
  55216. /**
  55217. * Creates a new instance of DepthOfFieldMergePostProcess
  55218. * @param name The name of the effect.
  55219. * @param originalFromInput Post process which's input will be used for the merge.
  55220. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55221. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55222. * @param options The required width/height ratio to downsize to before computing the render pass.
  55223. * @param camera The camera to apply the render pass to.
  55224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55225. * @param engine The engine which the post process will be applied. (default: current engine)
  55226. * @param reusable If the post process can be reused on the same frame. (default: false)
  55227. * @param textureType Type of textures used when performing the post process. (default: 0)
  55228. * @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)
  55229. */
  55230. 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);
  55231. /**
  55232. * Updates the effect with the current post process compile time values and recompiles the shader.
  55233. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55234. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55235. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55236. * @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
  55237. * @param onCompiled Called when the shader has been compiled.
  55238. * @param onError Called if there is an error when compiling a shader.
  55239. */
  55240. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55241. }
  55242. }
  55243. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55244. import { Nullable } from "babylonjs/types";
  55245. import { Camera } from "babylonjs/Cameras/camera";
  55246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55248. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55249. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55250. import { Scene } from "babylonjs/scene";
  55251. /**
  55252. * Specifies the level of max blur that should be applied when using the depth of field effect
  55253. */
  55254. export enum DepthOfFieldEffectBlurLevel {
  55255. /**
  55256. * Subtle blur
  55257. */
  55258. Low = 0,
  55259. /**
  55260. * Medium blur
  55261. */
  55262. Medium = 1,
  55263. /**
  55264. * Large blur
  55265. */
  55266. High = 2
  55267. }
  55268. /**
  55269. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55270. */
  55271. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55272. private _circleOfConfusion;
  55273. /**
  55274. * @hidden Internal, blurs from high to low
  55275. */
  55276. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55277. private _depthOfFieldBlurY;
  55278. private _dofMerge;
  55279. /**
  55280. * @hidden Internal post processes in depth of field effect
  55281. */
  55282. _effects: Array<PostProcess>;
  55283. /**
  55284. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55285. */
  55286. focalLength: number;
  55287. /**
  55288. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55289. */
  55290. fStop: number;
  55291. /**
  55292. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55293. */
  55294. focusDistance: number;
  55295. /**
  55296. * 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.
  55297. */
  55298. lensSize: number;
  55299. /**
  55300. * Creates a new instance DepthOfFieldEffect
  55301. * @param scene The scene the effect belongs to.
  55302. * @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.
  55303. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55304. * @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)
  55305. */
  55306. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55307. /**
  55308. * Get the current class name of the current effet
  55309. * @returns "DepthOfFieldEffect"
  55310. */
  55311. getClassName(): string;
  55312. /**
  55313. * 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.
  55314. */
  55315. depthTexture: RenderTargetTexture;
  55316. /**
  55317. * Disposes each of the internal effects for a given camera.
  55318. * @param camera The camera to dispose the effect on.
  55319. */
  55320. disposeEffects(camera: Camera): void;
  55321. /**
  55322. * @hidden Internal
  55323. */
  55324. _updateEffects(): void;
  55325. /**
  55326. * Internal
  55327. * @returns if all the contained post processes are ready.
  55328. * @hidden
  55329. */
  55330. _isReady(): boolean;
  55331. }
  55332. }
  55333. declare module "babylonjs/Shaders/displayPass.fragment" {
  55334. /** @hidden */
  55335. export var displayPassPixelShader: {
  55336. name: string;
  55337. shader: string;
  55338. };
  55339. }
  55340. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55341. import { Nullable } from "babylonjs/types";
  55342. import { Camera } from "babylonjs/Cameras/camera";
  55343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55344. import { Engine } from "babylonjs/Engines/engine";
  55345. import "babylonjs/Shaders/displayPass.fragment";
  55346. /**
  55347. * DisplayPassPostProcess which produces an output the same as it's input
  55348. */
  55349. export class DisplayPassPostProcess extends PostProcess {
  55350. /**
  55351. * Creates the DisplayPassPostProcess
  55352. * @param name The name of the effect.
  55353. * @param options The required width/height ratio to downsize to before computing the render pass.
  55354. * @param camera The camera to apply the render pass to.
  55355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55356. * @param engine The engine which the post process will be applied. (default: current engine)
  55357. * @param reusable If the post process can be reused on the same frame. (default: false)
  55358. */
  55359. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55360. }
  55361. }
  55362. declare module "babylonjs/Shaders/filter.fragment" {
  55363. /** @hidden */
  55364. export var filterPixelShader: {
  55365. name: string;
  55366. shader: string;
  55367. };
  55368. }
  55369. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55370. import { Nullable } from "babylonjs/types";
  55371. import { Matrix } from "babylonjs/Maths/math";
  55372. import { Camera } from "babylonjs/Cameras/camera";
  55373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55374. import { Engine } from "babylonjs/Engines/engine";
  55375. import "babylonjs/Shaders/filter.fragment";
  55376. /**
  55377. * Applies a kernel filter to the image
  55378. */
  55379. export class FilterPostProcess extends PostProcess {
  55380. /** The matrix to be applied to the image */
  55381. kernelMatrix: Matrix;
  55382. /**
  55383. *
  55384. * @param name The name of the effect.
  55385. * @param kernelMatrix The matrix to be applied to the image
  55386. * @param options The required width/height ratio to downsize to before computing the render pass.
  55387. * @param camera The camera to apply the render pass to.
  55388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55389. * @param engine The engine which the post process will be applied. (default: current engine)
  55390. * @param reusable If the post process can be reused on the same frame. (default: false)
  55391. */
  55392. constructor(name: string,
  55393. /** The matrix to be applied to the image */
  55394. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55395. }
  55396. }
  55397. declare module "babylonjs/Shaders/fxaa.fragment" {
  55398. /** @hidden */
  55399. export var fxaaPixelShader: {
  55400. name: string;
  55401. shader: string;
  55402. };
  55403. }
  55404. declare module "babylonjs/Shaders/fxaa.vertex" {
  55405. /** @hidden */
  55406. export var fxaaVertexShader: {
  55407. name: string;
  55408. shader: string;
  55409. };
  55410. }
  55411. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55412. import { Nullable } from "babylonjs/types";
  55413. import { Camera } from "babylonjs/Cameras/camera";
  55414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55415. import { Engine } from "babylonjs/Engines/engine";
  55416. import "babylonjs/Shaders/fxaa.fragment";
  55417. import "babylonjs/Shaders/fxaa.vertex";
  55418. /**
  55419. * Fxaa post process
  55420. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55421. */
  55422. export class FxaaPostProcess extends PostProcess {
  55423. /** @hidden */
  55424. texelWidth: number;
  55425. /** @hidden */
  55426. texelHeight: number;
  55427. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55428. private _getDefines;
  55429. }
  55430. }
  55431. declare module "babylonjs/Shaders/grain.fragment" {
  55432. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55433. /** @hidden */
  55434. export var grainPixelShader: {
  55435. name: string;
  55436. shader: string;
  55437. };
  55438. }
  55439. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55440. import { Nullable } from "babylonjs/types";
  55441. import { Camera } from "babylonjs/Cameras/camera";
  55442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55443. import { Engine } from "babylonjs/Engines/engine";
  55444. import "babylonjs/Shaders/grain.fragment";
  55445. /**
  55446. * The GrainPostProcess adds noise to the image at mid luminance levels
  55447. */
  55448. export class GrainPostProcess extends PostProcess {
  55449. /**
  55450. * The intensity of the grain added (default: 30)
  55451. */
  55452. intensity: number;
  55453. /**
  55454. * If the grain should be randomized on every frame
  55455. */
  55456. animated: boolean;
  55457. /**
  55458. * Creates a new instance of @see GrainPostProcess
  55459. * @param name The name of the effect.
  55460. * @param options The required width/height ratio to downsize to before computing the render pass.
  55461. * @param camera The camera to apply the render pass to.
  55462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55463. * @param engine The engine which the post process will be applied. (default: current engine)
  55464. * @param reusable If the post process can be reused on the same frame. (default: false)
  55465. * @param textureType Type of textures used when performing the post process. (default: 0)
  55466. * @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)
  55467. */
  55468. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55469. }
  55470. }
  55471. declare module "babylonjs/Shaders/highlights.fragment" {
  55472. /** @hidden */
  55473. export var highlightsPixelShader: {
  55474. name: string;
  55475. shader: string;
  55476. };
  55477. }
  55478. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55479. import { Nullable } from "babylonjs/types";
  55480. import { Camera } from "babylonjs/Cameras/camera";
  55481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55482. import { Engine } from "babylonjs/Engines/engine";
  55483. import "babylonjs/Shaders/highlights.fragment";
  55484. /**
  55485. * Extracts highlights from the image
  55486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55487. */
  55488. export class HighlightsPostProcess extends PostProcess {
  55489. /**
  55490. * Extracts highlights from the image
  55491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55492. * @param name The name of the effect.
  55493. * @param options The required width/height ratio to downsize to before computing the render pass.
  55494. * @param camera The camera to apply the render pass to.
  55495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55496. * @param engine The engine which the post process will be applied. (default: current engine)
  55497. * @param reusable If the post process can be reused on the same frame. (default: false)
  55498. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55499. */
  55500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55501. }
  55502. }
  55503. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55504. /** @hidden */
  55505. export var mrtFragmentDeclaration: {
  55506. name: string;
  55507. shader: string;
  55508. };
  55509. }
  55510. declare module "babylonjs/Shaders/geometry.fragment" {
  55511. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55512. /** @hidden */
  55513. export var geometryPixelShader: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module "babylonjs/Shaders/geometry.vertex" {
  55519. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55520. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55521. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55522. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55523. /** @hidden */
  55524. export var geometryVertexShader: {
  55525. name: string;
  55526. shader: string;
  55527. };
  55528. }
  55529. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55530. import { Matrix } from "babylonjs/Maths/math";
  55531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55532. import { Mesh } from "babylonjs/Meshes/mesh";
  55533. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55534. import { Effect } from "babylonjs/Materials/effect";
  55535. import { Scene } from "babylonjs/scene";
  55536. import "babylonjs/Shaders/geometry.fragment";
  55537. import "babylonjs/Shaders/geometry.vertex";
  55538. /**
  55539. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55540. */
  55541. export class GeometryBufferRenderer {
  55542. /**
  55543. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55544. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55545. */
  55546. static readonly POSITION_TEXTURE_TYPE: number;
  55547. /**
  55548. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55549. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55550. */
  55551. static readonly VELOCITY_TEXTURE_TYPE: number;
  55552. /**
  55553. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55554. * in order to compute objects velocities when enableVelocity is set to "true"
  55555. * @hidden
  55556. */
  55557. _previousTransformationMatrices: {
  55558. [index: number]: Matrix;
  55559. };
  55560. private _scene;
  55561. private _multiRenderTarget;
  55562. private _ratio;
  55563. private _enablePosition;
  55564. private _enableVelocity;
  55565. private _positionIndex;
  55566. private _velocityIndex;
  55567. protected _effect: Effect;
  55568. protected _cachedDefines: string;
  55569. /**
  55570. * Set the render list (meshes to be rendered) used in the G buffer.
  55571. */
  55572. renderList: Mesh[];
  55573. /**
  55574. * Gets wether or not G buffer are supported by the running hardware.
  55575. * This requires draw buffer supports
  55576. */
  55577. readonly isSupported: boolean;
  55578. /**
  55579. * Returns the index of the given texture type in the G-Buffer textures array
  55580. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55581. * @returns the index of the given texture type in the G-Buffer textures array
  55582. */
  55583. getTextureIndex(textureType: number): number;
  55584. /**
  55585. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55586. */
  55587. /**
  55588. * Sets whether or not objects positions are enabled for the G buffer.
  55589. */
  55590. enablePosition: boolean;
  55591. /**
  55592. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55593. */
  55594. /**
  55595. * Sets wether or not objects velocities are enabled for the G buffer.
  55596. */
  55597. enableVelocity: boolean;
  55598. /**
  55599. * Gets the scene associated with the buffer.
  55600. */
  55601. readonly scene: Scene;
  55602. /**
  55603. * Gets the ratio used by the buffer during its creation.
  55604. * How big is the buffer related to the main canvas.
  55605. */
  55606. readonly ratio: number;
  55607. /** @hidden */
  55608. static _SceneComponentInitialization: (scene: Scene) => void;
  55609. /**
  55610. * Creates a new G Buffer for the scene
  55611. * @param scene The scene the buffer belongs to
  55612. * @param ratio How big is the buffer related to the main canvas.
  55613. */
  55614. constructor(scene: Scene, ratio?: number);
  55615. /**
  55616. * Checks wether everything is ready to render a submesh to the G buffer.
  55617. * @param subMesh the submesh to check readiness for
  55618. * @param useInstances is the mesh drawn using instance or not
  55619. * @returns true if ready otherwise false
  55620. */
  55621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55622. /**
  55623. * Gets the current underlying G Buffer.
  55624. * @returns the buffer
  55625. */
  55626. getGBuffer(): MultiRenderTarget;
  55627. /**
  55628. * Gets the number of samples used to render the buffer (anti aliasing).
  55629. */
  55630. /**
  55631. * Sets the number of samples used to render the buffer (anti aliasing).
  55632. */
  55633. samples: number;
  55634. /**
  55635. * Disposes the renderer and frees up associated resources.
  55636. */
  55637. dispose(): void;
  55638. protected _createRenderTargets(): void;
  55639. }
  55640. }
  55641. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55642. import { Nullable } from "babylonjs/types";
  55643. import { Scene } from "babylonjs/scene";
  55644. import { ISceneComponent } from "babylonjs/sceneComponent";
  55645. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55646. module "babylonjs/scene" {
  55647. interface Scene {
  55648. /** @hidden (Backing field) */
  55649. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55650. /**
  55651. * Gets or Sets the current geometry buffer associated to the scene.
  55652. */
  55653. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55654. /**
  55655. * Enables a GeometryBufferRender and associates it with the scene
  55656. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55657. * @returns the GeometryBufferRenderer
  55658. */
  55659. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55660. /**
  55661. * Disables the GeometryBufferRender associated with the scene
  55662. */
  55663. disableGeometryBufferRenderer(): void;
  55664. }
  55665. }
  55666. /**
  55667. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55668. * in several rendering techniques.
  55669. */
  55670. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55671. /**
  55672. * The component name helpful to identify the component in the list of scene components.
  55673. */
  55674. readonly name: string;
  55675. /**
  55676. * The scene the component belongs to.
  55677. */
  55678. scene: Scene;
  55679. /**
  55680. * Creates a new instance of the component for the given scene
  55681. * @param scene Defines the scene to register the component in
  55682. */
  55683. constructor(scene: Scene);
  55684. /**
  55685. * Registers the component in a given scene
  55686. */
  55687. register(): void;
  55688. /**
  55689. * Rebuilds the elements related to this component in case of
  55690. * context lost for instance.
  55691. */
  55692. rebuild(): void;
  55693. /**
  55694. * Disposes the component and the associated ressources
  55695. */
  55696. dispose(): void;
  55697. private _gatherRenderTargets;
  55698. }
  55699. }
  55700. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55701. /** @hidden */
  55702. export var motionBlurPixelShader: {
  55703. name: string;
  55704. shader: string;
  55705. };
  55706. }
  55707. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55708. import { Nullable } from "babylonjs/types";
  55709. import { Camera } from "babylonjs/Cameras/camera";
  55710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55711. import { Scene } from "babylonjs/scene";
  55712. import "babylonjs/Animations/animatable";
  55713. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55714. import "babylonjs/Shaders/motionBlur.fragment";
  55715. import { Engine } from "babylonjs/Engines/engine";
  55716. /**
  55717. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55718. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55719. * As an example, all you have to do is to create the post-process:
  55720. * var mb = new BABYLON.MotionBlurPostProcess(
  55721. * 'mb', // The name of the effect.
  55722. * scene, // The scene containing the objects to blur according to their velocity.
  55723. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55724. * camera // The camera to apply the render pass to.
  55725. * );
  55726. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55727. */
  55728. export class MotionBlurPostProcess extends PostProcess {
  55729. /**
  55730. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55731. */
  55732. motionStrength: number;
  55733. /**
  55734. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55735. */
  55736. /**
  55737. * Sets the number of iterations to be used for motion blur quality
  55738. */
  55739. motionBlurSamples: number;
  55740. private _motionBlurSamples;
  55741. private _geometryBufferRenderer;
  55742. /**
  55743. * Creates a new instance MotionBlurPostProcess
  55744. * @param name The name of the effect.
  55745. * @param scene The scene containing the objects to blur according to their velocity.
  55746. * @param options The required width/height ratio to downsize to before computing the render pass.
  55747. * @param camera The camera to apply the render pass to.
  55748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55749. * @param engine The engine which the post process will be applied. (default: current engine)
  55750. * @param reusable If the post process can be reused on the same frame. (default: false)
  55751. * @param textureType Type of textures used when performing the post process. (default: 0)
  55752. * @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)
  55753. */
  55754. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55755. /**
  55756. * Disposes the post process.
  55757. * @param camera The camera to dispose the post process on.
  55758. */
  55759. dispose(camera?: Camera): void;
  55760. }
  55761. }
  55762. declare module "babylonjs/Shaders/refraction.fragment" {
  55763. /** @hidden */
  55764. export var refractionPixelShader: {
  55765. name: string;
  55766. shader: string;
  55767. };
  55768. }
  55769. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55770. import { Color3 } from "babylonjs/Maths/math";
  55771. import { Camera } from "babylonjs/Cameras/camera";
  55772. import { Texture } from "babylonjs/Materials/Textures/texture";
  55773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55774. import { Engine } from "babylonjs/Engines/engine";
  55775. import "babylonjs/Shaders/refraction.fragment";
  55776. /**
  55777. * Post process which applies a refractin texture
  55778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55779. */
  55780. export class RefractionPostProcess extends PostProcess {
  55781. /** the base color of the refraction (used to taint the rendering) */
  55782. color: Color3;
  55783. /** simulated refraction depth */
  55784. depth: number;
  55785. /** the coefficient of the base color (0 to remove base color tainting) */
  55786. colorLevel: number;
  55787. private _refTexture;
  55788. private _ownRefractionTexture;
  55789. /**
  55790. * Gets or sets the refraction texture
  55791. * Please note that you are responsible for disposing the texture if you set it manually
  55792. */
  55793. refractionTexture: Texture;
  55794. /**
  55795. * Initializes the RefractionPostProcess
  55796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55797. * @param name The name of the effect.
  55798. * @param refractionTextureUrl Url of the refraction texture to use
  55799. * @param color the base color of the refraction (used to taint the rendering)
  55800. * @param depth simulated refraction depth
  55801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55802. * @param camera The camera to apply the render pass to.
  55803. * @param options The required width/height ratio to downsize to before computing the render pass.
  55804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55805. * @param engine The engine which the post process will be applied. (default: current engine)
  55806. * @param reusable If the post process can be reused on the same frame. (default: false)
  55807. */
  55808. constructor(name: string, refractionTextureUrl: string,
  55809. /** the base color of the refraction (used to taint the rendering) */
  55810. color: Color3,
  55811. /** simulated refraction depth */
  55812. depth: number,
  55813. /** the coefficient of the base color (0 to remove base color tainting) */
  55814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55815. /**
  55816. * Disposes of the post process
  55817. * @param camera Camera to dispose post process on
  55818. */
  55819. dispose(camera: Camera): void;
  55820. }
  55821. }
  55822. declare module "babylonjs/Shaders/sharpen.fragment" {
  55823. /** @hidden */
  55824. export var sharpenPixelShader: {
  55825. name: string;
  55826. shader: string;
  55827. };
  55828. }
  55829. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55830. import { Nullable } from "babylonjs/types";
  55831. import { Camera } from "babylonjs/Cameras/camera";
  55832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55833. import "babylonjs/Shaders/sharpen.fragment";
  55834. import { Engine } from "babylonjs/Engines/engine";
  55835. /**
  55836. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55837. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55838. */
  55839. export class SharpenPostProcess extends PostProcess {
  55840. /**
  55841. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55842. */
  55843. colorAmount: number;
  55844. /**
  55845. * How much sharpness should be applied (default: 0.3)
  55846. */
  55847. edgeAmount: number;
  55848. /**
  55849. * Creates a new instance ConvolutionPostProcess
  55850. * @param name The name of the effect.
  55851. * @param options The required width/height ratio to downsize to before computing the render pass.
  55852. * @param camera The camera to apply the render pass to.
  55853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55854. * @param engine The engine which the post process will be applied. (default: current engine)
  55855. * @param reusable If the post process can be reused on the same frame. (default: false)
  55856. * @param textureType Type of textures used when performing the post process. (default: 0)
  55857. * @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)
  55858. */
  55859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55860. }
  55861. }
  55862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55863. import { Nullable } from "babylonjs/types";
  55864. import { Camera } from "babylonjs/Cameras/camera";
  55865. import { Engine } from "babylonjs/Engines/engine";
  55866. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55867. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55868. /**
  55869. * PostProcessRenderPipeline
  55870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55871. */
  55872. export class PostProcessRenderPipeline {
  55873. private engine;
  55874. private _renderEffects;
  55875. private _renderEffectsForIsolatedPass;
  55876. /**
  55877. * List of inspectable custom properties (used by the Inspector)
  55878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55879. */
  55880. inspectableCustomProperties: IInspectable[];
  55881. /**
  55882. * @hidden
  55883. */
  55884. protected _cameras: Camera[];
  55885. /** @hidden */
  55886. _name: string;
  55887. /**
  55888. * Gets pipeline name
  55889. */
  55890. readonly name: string;
  55891. /**
  55892. * Initializes a PostProcessRenderPipeline
  55893. * @param engine engine to add the pipeline to
  55894. * @param name name of the pipeline
  55895. */
  55896. constructor(engine: Engine, name: string);
  55897. /**
  55898. * Gets the class name
  55899. * @returns "PostProcessRenderPipeline"
  55900. */
  55901. getClassName(): string;
  55902. /**
  55903. * If all the render effects in the pipeline are supported
  55904. */
  55905. readonly isSupported: boolean;
  55906. /**
  55907. * Adds an effect to the pipeline
  55908. * @param renderEffect the effect to add
  55909. */
  55910. addEffect(renderEffect: PostProcessRenderEffect): void;
  55911. /** @hidden */
  55912. _rebuild(): void;
  55913. /** @hidden */
  55914. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55915. /** @hidden */
  55916. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55917. /** @hidden */
  55918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55919. /** @hidden */
  55920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55921. /** @hidden */
  55922. _attachCameras(cameras: Camera, unique: boolean): void;
  55923. /** @hidden */
  55924. _attachCameras(cameras: Camera[], unique: boolean): void;
  55925. /** @hidden */
  55926. _detachCameras(cameras: Camera): void;
  55927. /** @hidden */
  55928. _detachCameras(cameras: Nullable<Camera[]>): void;
  55929. /** @hidden */
  55930. _update(): void;
  55931. /** @hidden */
  55932. _reset(): void;
  55933. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55934. /**
  55935. * Disposes of the pipeline
  55936. */
  55937. dispose(): void;
  55938. }
  55939. }
  55940. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55941. import { Camera } from "babylonjs/Cameras/camera";
  55942. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55943. /**
  55944. * PostProcessRenderPipelineManager class
  55945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55946. */
  55947. export class PostProcessRenderPipelineManager {
  55948. private _renderPipelines;
  55949. /**
  55950. * Initializes a PostProcessRenderPipelineManager
  55951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55952. */
  55953. constructor();
  55954. /**
  55955. * Gets the list of supported render pipelines
  55956. */
  55957. readonly supportedPipelines: PostProcessRenderPipeline[];
  55958. /**
  55959. * Adds a pipeline to the manager
  55960. * @param renderPipeline The pipeline to add
  55961. */
  55962. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55963. /**
  55964. * Attaches a camera to the pipeline
  55965. * @param renderPipelineName The name of the pipeline to attach to
  55966. * @param cameras the camera to attach
  55967. * @param unique if the camera can be attached multiple times to the pipeline
  55968. */
  55969. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55970. /**
  55971. * Detaches a camera from the pipeline
  55972. * @param renderPipelineName The name of the pipeline to detach from
  55973. * @param cameras the camera to detach
  55974. */
  55975. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55976. /**
  55977. * Enables an effect by name on a pipeline
  55978. * @param renderPipelineName the name of the pipeline to enable the effect in
  55979. * @param renderEffectName the name of the effect to enable
  55980. * @param cameras the cameras that the effect should be enabled on
  55981. */
  55982. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55983. /**
  55984. * Disables an effect by name on a pipeline
  55985. * @param renderPipelineName the name of the pipeline to disable the effect in
  55986. * @param renderEffectName the name of the effect to disable
  55987. * @param cameras the cameras that the effect should be disabled on
  55988. */
  55989. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55990. /**
  55991. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55992. */
  55993. update(): void;
  55994. /** @hidden */
  55995. _rebuild(): void;
  55996. /**
  55997. * Disposes of the manager and pipelines
  55998. */
  55999. dispose(): void;
  56000. }
  56001. }
  56002. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56003. import { ISceneComponent } from "babylonjs/sceneComponent";
  56004. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56005. import { Scene } from "babylonjs/scene";
  56006. module "babylonjs/scene" {
  56007. interface Scene {
  56008. /** @hidden (Backing field) */
  56009. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56010. /**
  56011. * Gets the postprocess render pipeline manager
  56012. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56013. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56014. */
  56015. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56016. }
  56017. }
  56018. /**
  56019. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56020. */
  56021. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56022. /**
  56023. * The component name helpfull to identify the component in the list of scene components.
  56024. */
  56025. readonly name: string;
  56026. /**
  56027. * The scene the component belongs to.
  56028. */
  56029. scene: Scene;
  56030. /**
  56031. * Creates a new instance of the component for the given scene
  56032. * @param scene Defines the scene to register the component in
  56033. */
  56034. constructor(scene: Scene);
  56035. /**
  56036. * Registers the component in a given scene
  56037. */
  56038. register(): void;
  56039. /**
  56040. * Rebuilds the elements related to this component in case of
  56041. * context lost for instance.
  56042. */
  56043. rebuild(): void;
  56044. /**
  56045. * Disposes the component and the associated ressources
  56046. */
  56047. dispose(): void;
  56048. private _gatherRenderTargets;
  56049. }
  56050. }
  56051. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56052. import { Nullable } from "babylonjs/types";
  56053. import { IAnimatable } from "babylonjs/Misc/tools";
  56054. import { Camera } from "babylonjs/Cameras/camera";
  56055. import { IDisposable } from "babylonjs/scene";
  56056. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56057. import { Scene } from "babylonjs/scene";
  56058. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56059. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56060. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56061. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56062. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56063. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56064. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56065. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56066. import { Animation } from "babylonjs/Animations/animation";
  56067. /**
  56068. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56069. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56070. */
  56071. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56072. private _scene;
  56073. private _camerasToBeAttached;
  56074. /**
  56075. * ID of the sharpen post process,
  56076. */
  56077. private readonly SharpenPostProcessId;
  56078. /**
  56079. * @ignore
  56080. * ID of the image processing post process;
  56081. */
  56082. readonly ImageProcessingPostProcessId: string;
  56083. /**
  56084. * @ignore
  56085. * ID of the Fast Approximate Anti-Aliasing post process;
  56086. */
  56087. readonly FxaaPostProcessId: string;
  56088. /**
  56089. * ID of the chromatic aberration post process,
  56090. */
  56091. private readonly ChromaticAberrationPostProcessId;
  56092. /**
  56093. * ID of the grain post process
  56094. */
  56095. private readonly GrainPostProcessId;
  56096. /**
  56097. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56098. */
  56099. sharpen: SharpenPostProcess;
  56100. private _sharpenEffect;
  56101. private bloom;
  56102. /**
  56103. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56104. */
  56105. depthOfField: DepthOfFieldEffect;
  56106. /**
  56107. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56108. */
  56109. fxaa: FxaaPostProcess;
  56110. /**
  56111. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56112. */
  56113. imageProcessing: ImageProcessingPostProcess;
  56114. /**
  56115. * Chromatic aberration post process which will shift rgb colors in the image
  56116. */
  56117. chromaticAberration: ChromaticAberrationPostProcess;
  56118. private _chromaticAberrationEffect;
  56119. /**
  56120. * Grain post process which add noise to the image
  56121. */
  56122. grain: GrainPostProcess;
  56123. private _grainEffect;
  56124. /**
  56125. * Glow post process which adds a glow to emissive areas of the image
  56126. */
  56127. private _glowLayer;
  56128. /**
  56129. * Animations which can be used to tweak settings over a period of time
  56130. */
  56131. animations: Animation[];
  56132. private _imageProcessingConfigurationObserver;
  56133. private _sharpenEnabled;
  56134. private _bloomEnabled;
  56135. private _depthOfFieldEnabled;
  56136. private _depthOfFieldBlurLevel;
  56137. private _fxaaEnabled;
  56138. private _imageProcessingEnabled;
  56139. private _defaultPipelineTextureType;
  56140. private _bloomScale;
  56141. private _chromaticAberrationEnabled;
  56142. private _grainEnabled;
  56143. private _buildAllowed;
  56144. /**
  56145. * Gets active scene
  56146. */
  56147. readonly scene: Scene;
  56148. /**
  56149. * Enable or disable the sharpen process from the pipeline
  56150. */
  56151. sharpenEnabled: boolean;
  56152. private _resizeObserver;
  56153. private _hardwareScaleLevel;
  56154. private _bloomKernel;
  56155. /**
  56156. * Specifies the size of the bloom blur kernel, relative to the final output size
  56157. */
  56158. bloomKernel: number;
  56159. /**
  56160. * Specifies the weight of the bloom in the final rendering
  56161. */
  56162. private _bloomWeight;
  56163. /**
  56164. * Specifies the luma threshold for the area that will be blurred by the bloom
  56165. */
  56166. private _bloomThreshold;
  56167. private _hdr;
  56168. /**
  56169. * The strength of the bloom.
  56170. */
  56171. bloomWeight: number;
  56172. /**
  56173. * The strength of the bloom.
  56174. */
  56175. bloomThreshold: number;
  56176. /**
  56177. * The scale of the bloom, lower value will provide better performance.
  56178. */
  56179. bloomScale: number;
  56180. /**
  56181. * Enable or disable the bloom from the pipeline
  56182. */
  56183. bloomEnabled: boolean;
  56184. private _rebuildBloom;
  56185. /**
  56186. * If the depth of field is enabled.
  56187. */
  56188. depthOfFieldEnabled: boolean;
  56189. /**
  56190. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56191. */
  56192. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56193. /**
  56194. * If the anti aliasing is enabled.
  56195. */
  56196. fxaaEnabled: boolean;
  56197. private _samples;
  56198. /**
  56199. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56200. */
  56201. samples: number;
  56202. /**
  56203. * If image processing is enabled.
  56204. */
  56205. imageProcessingEnabled: boolean;
  56206. /**
  56207. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56208. */
  56209. glowLayerEnabled: boolean;
  56210. /**
  56211. * Gets the glow layer (or null if not defined)
  56212. */
  56213. readonly glowLayer: Nullable<GlowLayer>;
  56214. /**
  56215. * Enable or disable the chromaticAberration process from the pipeline
  56216. */
  56217. chromaticAberrationEnabled: boolean;
  56218. /**
  56219. * Enable or disable the grain process from the pipeline
  56220. */
  56221. grainEnabled: boolean;
  56222. /**
  56223. * @constructor
  56224. * @param name - The rendering pipeline name (default: "")
  56225. * @param hdr - If high dynamic range textures should be used (default: true)
  56226. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56227. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56228. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56229. */
  56230. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56231. /**
  56232. * Get the class name
  56233. * @returns "DefaultRenderingPipeline"
  56234. */
  56235. getClassName(): string;
  56236. /**
  56237. * Force the compilation of the entire pipeline.
  56238. */
  56239. prepare(): void;
  56240. private _hasCleared;
  56241. private _prevPostProcess;
  56242. private _prevPrevPostProcess;
  56243. private _setAutoClearAndTextureSharing;
  56244. private _depthOfFieldSceneObserver;
  56245. private _buildPipeline;
  56246. private _disposePostProcesses;
  56247. /**
  56248. * Adds a camera to the pipeline
  56249. * @param camera the camera to be added
  56250. */
  56251. addCamera(camera: Camera): void;
  56252. /**
  56253. * Removes a camera from the pipeline
  56254. * @param camera the camera to remove
  56255. */
  56256. removeCamera(camera: Camera): void;
  56257. /**
  56258. * Dispose of the pipeline and stop all post processes
  56259. */
  56260. dispose(): void;
  56261. /**
  56262. * Serialize the rendering pipeline (Used when exporting)
  56263. * @returns the serialized object
  56264. */
  56265. serialize(): any;
  56266. /**
  56267. * Parse the serialized pipeline
  56268. * @param source Source pipeline.
  56269. * @param scene The scene to load the pipeline to.
  56270. * @param rootUrl The URL of the serialized pipeline.
  56271. * @returns An instantiated pipeline from the serialized object.
  56272. */
  56273. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56274. }
  56275. }
  56276. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56277. /** @hidden */
  56278. export var lensHighlightsPixelShader: {
  56279. name: string;
  56280. shader: string;
  56281. };
  56282. }
  56283. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56284. /** @hidden */
  56285. export var depthOfFieldPixelShader: {
  56286. name: string;
  56287. shader: string;
  56288. };
  56289. }
  56290. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56291. import { Camera } from "babylonjs/Cameras/camera";
  56292. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56293. import { Scene } from "babylonjs/scene";
  56294. import "babylonjs/Shaders/chromaticAberration.fragment";
  56295. import "babylonjs/Shaders/lensHighlights.fragment";
  56296. import "babylonjs/Shaders/depthOfField.fragment";
  56297. /**
  56298. * BABYLON.JS Chromatic Aberration GLSL Shader
  56299. * Author: Olivier Guyot
  56300. * Separates very slightly R, G and B colors on the edges of the screen
  56301. * Inspired by Francois Tarlier & Martins Upitis
  56302. */
  56303. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56304. /**
  56305. * @ignore
  56306. * The chromatic aberration PostProcess id in the pipeline
  56307. */
  56308. LensChromaticAberrationEffect: string;
  56309. /**
  56310. * @ignore
  56311. * The highlights enhancing PostProcess id in the pipeline
  56312. */
  56313. HighlightsEnhancingEffect: string;
  56314. /**
  56315. * @ignore
  56316. * The depth-of-field PostProcess id in the pipeline
  56317. */
  56318. LensDepthOfFieldEffect: string;
  56319. private _scene;
  56320. private _depthTexture;
  56321. private _grainTexture;
  56322. private _chromaticAberrationPostProcess;
  56323. private _highlightsPostProcess;
  56324. private _depthOfFieldPostProcess;
  56325. private _edgeBlur;
  56326. private _grainAmount;
  56327. private _chromaticAberration;
  56328. private _distortion;
  56329. private _highlightsGain;
  56330. private _highlightsThreshold;
  56331. private _dofDistance;
  56332. private _dofAperture;
  56333. private _dofDarken;
  56334. private _dofPentagon;
  56335. private _blurNoise;
  56336. /**
  56337. * @constructor
  56338. *
  56339. * Effect parameters are as follow:
  56340. * {
  56341. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56342. * edge_blur: number; // from 0 to x (1 for realism)
  56343. * distortion: number; // from 0 to x (1 for realism)
  56344. * grain_amount: number; // from 0 to 1
  56345. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56346. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56347. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56348. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56349. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56350. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56351. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56352. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56353. * }
  56354. * Note: if an effect parameter is unset, effect is disabled
  56355. *
  56356. * @param name The rendering pipeline name
  56357. * @param parameters - An object containing all parameters (see above)
  56358. * @param scene The scene linked to this pipeline
  56359. * @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)
  56360. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56361. */
  56362. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56363. /**
  56364. * Get the class name
  56365. * @returns "LensRenderingPipeline"
  56366. */
  56367. getClassName(): string;
  56368. /**
  56369. * Gets associated scene
  56370. */
  56371. readonly scene: Scene;
  56372. /**
  56373. * Gets or sets the edge blur
  56374. */
  56375. edgeBlur: number;
  56376. /**
  56377. * Gets or sets the grain amount
  56378. */
  56379. grainAmount: number;
  56380. /**
  56381. * Gets or sets the chromatic aberration amount
  56382. */
  56383. chromaticAberration: number;
  56384. /**
  56385. * Gets or sets the depth of field aperture
  56386. */
  56387. dofAperture: number;
  56388. /**
  56389. * Gets or sets the edge distortion
  56390. */
  56391. edgeDistortion: number;
  56392. /**
  56393. * Gets or sets the depth of field distortion
  56394. */
  56395. dofDistortion: number;
  56396. /**
  56397. * Gets or sets the darken out of focus amount
  56398. */
  56399. darkenOutOfFocus: number;
  56400. /**
  56401. * Gets or sets a boolean indicating if blur noise is enabled
  56402. */
  56403. blurNoise: boolean;
  56404. /**
  56405. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56406. */
  56407. pentagonBokeh: boolean;
  56408. /**
  56409. * Gets or sets the highlight grain amount
  56410. */
  56411. highlightsGain: number;
  56412. /**
  56413. * Gets or sets the highlight threshold
  56414. */
  56415. highlightsThreshold: number;
  56416. /**
  56417. * Sets the amount of blur at the edges
  56418. * @param amount blur amount
  56419. */
  56420. setEdgeBlur(amount: number): void;
  56421. /**
  56422. * Sets edge blur to 0
  56423. */
  56424. disableEdgeBlur(): void;
  56425. /**
  56426. * Sets the amout of grain
  56427. * @param amount Amount of grain
  56428. */
  56429. setGrainAmount(amount: number): void;
  56430. /**
  56431. * Set grain amount to 0
  56432. */
  56433. disableGrain(): void;
  56434. /**
  56435. * Sets the chromatic aberration amount
  56436. * @param amount amount of chromatic aberration
  56437. */
  56438. setChromaticAberration(amount: number): void;
  56439. /**
  56440. * Sets chromatic aberration amount to 0
  56441. */
  56442. disableChromaticAberration(): void;
  56443. /**
  56444. * Sets the EdgeDistortion amount
  56445. * @param amount amount of EdgeDistortion
  56446. */
  56447. setEdgeDistortion(amount: number): void;
  56448. /**
  56449. * Sets edge distortion to 0
  56450. */
  56451. disableEdgeDistortion(): void;
  56452. /**
  56453. * Sets the FocusDistance amount
  56454. * @param amount amount of FocusDistance
  56455. */
  56456. setFocusDistance(amount: number): void;
  56457. /**
  56458. * Disables depth of field
  56459. */
  56460. disableDepthOfField(): void;
  56461. /**
  56462. * Sets the Aperture amount
  56463. * @param amount amount of Aperture
  56464. */
  56465. setAperture(amount: number): void;
  56466. /**
  56467. * Sets the DarkenOutOfFocus amount
  56468. * @param amount amount of DarkenOutOfFocus
  56469. */
  56470. setDarkenOutOfFocus(amount: number): void;
  56471. private _pentagonBokehIsEnabled;
  56472. /**
  56473. * Creates a pentagon bokeh effect
  56474. */
  56475. enablePentagonBokeh(): void;
  56476. /**
  56477. * Disables the pentagon bokeh effect
  56478. */
  56479. disablePentagonBokeh(): void;
  56480. /**
  56481. * Enables noise blur
  56482. */
  56483. enableNoiseBlur(): void;
  56484. /**
  56485. * Disables noise blur
  56486. */
  56487. disableNoiseBlur(): void;
  56488. /**
  56489. * Sets the HighlightsGain amount
  56490. * @param amount amount of HighlightsGain
  56491. */
  56492. setHighlightsGain(amount: number): void;
  56493. /**
  56494. * Sets the HighlightsThreshold amount
  56495. * @param amount amount of HighlightsThreshold
  56496. */
  56497. setHighlightsThreshold(amount: number): void;
  56498. /**
  56499. * Disables highlights
  56500. */
  56501. disableHighlights(): void;
  56502. /**
  56503. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56504. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56505. */
  56506. dispose(disableDepthRender?: boolean): void;
  56507. private _createChromaticAberrationPostProcess;
  56508. private _createHighlightsPostProcess;
  56509. private _createDepthOfFieldPostProcess;
  56510. private _createGrainTexture;
  56511. }
  56512. }
  56513. declare module "babylonjs/Shaders/ssao2.fragment" {
  56514. /** @hidden */
  56515. export var ssao2PixelShader: {
  56516. name: string;
  56517. shader: string;
  56518. };
  56519. }
  56520. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56521. /** @hidden */
  56522. export var ssaoCombinePixelShader: {
  56523. name: string;
  56524. shader: string;
  56525. };
  56526. }
  56527. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56528. import { Camera } from "babylonjs/Cameras/camera";
  56529. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56530. import { Scene } from "babylonjs/scene";
  56531. import "babylonjs/Shaders/ssao2.fragment";
  56532. import "babylonjs/Shaders/ssaoCombine.fragment";
  56533. /**
  56534. * Render pipeline to produce ssao effect
  56535. */
  56536. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56537. /**
  56538. * @ignore
  56539. * The PassPostProcess id in the pipeline that contains the original scene color
  56540. */
  56541. SSAOOriginalSceneColorEffect: string;
  56542. /**
  56543. * @ignore
  56544. * The SSAO PostProcess id in the pipeline
  56545. */
  56546. SSAORenderEffect: string;
  56547. /**
  56548. * @ignore
  56549. * The horizontal blur PostProcess id in the pipeline
  56550. */
  56551. SSAOBlurHRenderEffect: string;
  56552. /**
  56553. * @ignore
  56554. * The vertical blur PostProcess id in the pipeline
  56555. */
  56556. SSAOBlurVRenderEffect: string;
  56557. /**
  56558. * @ignore
  56559. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56560. */
  56561. SSAOCombineRenderEffect: string;
  56562. /**
  56563. * The output strength of the SSAO post-process. Default value is 1.0.
  56564. */
  56565. totalStrength: number;
  56566. /**
  56567. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56568. */
  56569. maxZ: number;
  56570. /**
  56571. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56572. */
  56573. minZAspect: number;
  56574. private _samples;
  56575. /**
  56576. * Number of samples used for the SSAO calculations. Default value is 8
  56577. */
  56578. samples: number;
  56579. private _textureSamples;
  56580. /**
  56581. * Number of samples to use for antialiasing
  56582. */
  56583. textureSamples: number;
  56584. /**
  56585. * Ratio object used for SSAO ratio and blur ratio
  56586. */
  56587. private _ratio;
  56588. /**
  56589. * Dynamically generated sphere sampler.
  56590. */
  56591. private _sampleSphere;
  56592. /**
  56593. * Blur filter offsets
  56594. */
  56595. private _samplerOffsets;
  56596. private _expensiveBlur;
  56597. /**
  56598. * If bilateral blur should be used
  56599. */
  56600. expensiveBlur: boolean;
  56601. /**
  56602. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56603. */
  56604. radius: number;
  56605. /**
  56606. * The base color of the SSAO post-process
  56607. * The final result is "base + ssao" between [0, 1]
  56608. */
  56609. base: number;
  56610. /**
  56611. * Support test.
  56612. */
  56613. static readonly IsSupported: boolean;
  56614. private _scene;
  56615. private _depthTexture;
  56616. private _normalTexture;
  56617. private _randomTexture;
  56618. private _originalColorPostProcess;
  56619. private _ssaoPostProcess;
  56620. private _blurHPostProcess;
  56621. private _blurVPostProcess;
  56622. private _ssaoCombinePostProcess;
  56623. private _firstUpdate;
  56624. /**
  56625. * Gets active scene
  56626. */
  56627. readonly scene: Scene;
  56628. /**
  56629. * @constructor
  56630. * @param name The rendering pipeline name
  56631. * @param scene The scene linked to this pipeline
  56632. * @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 }
  56633. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56634. */
  56635. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56636. /**
  56637. * Get the class name
  56638. * @returns "SSAO2RenderingPipeline"
  56639. */
  56640. getClassName(): string;
  56641. /**
  56642. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56643. */
  56644. dispose(disableGeometryBufferRenderer?: boolean): void;
  56645. private _createBlurPostProcess;
  56646. /** @hidden */
  56647. _rebuild(): void;
  56648. private _bits;
  56649. private _radicalInverse_VdC;
  56650. private _hammersley;
  56651. private _hemisphereSample_uniform;
  56652. private _generateHemisphere;
  56653. private _createSSAOPostProcess;
  56654. private _createSSAOCombinePostProcess;
  56655. private _createRandomTexture;
  56656. /**
  56657. * Serialize the rendering pipeline (Used when exporting)
  56658. * @returns the serialized object
  56659. */
  56660. serialize(): any;
  56661. /**
  56662. * Parse the serialized pipeline
  56663. * @param source Source pipeline.
  56664. * @param scene The scene to load the pipeline to.
  56665. * @param rootUrl The URL of the serialized pipeline.
  56666. * @returns An instantiated pipeline from the serialized object.
  56667. */
  56668. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56669. }
  56670. }
  56671. declare module "babylonjs/Shaders/ssao.fragment" {
  56672. /** @hidden */
  56673. export var ssaoPixelShader: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56679. import { Camera } from "babylonjs/Cameras/camera";
  56680. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56681. import { Scene } from "babylonjs/scene";
  56682. import "babylonjs/Shaders/ssao.fragment";
  56683. import "babylonjs/Shaders/ssaoCombine.fragment";
  56684. /**
  56685. * Render pipeline to produce ssao effect
  56686. */
  56687. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56688. /**
  56689. * @ignore
  56690. * The PassPostProcess id in the pipeline that contains the original scene color
  56691. */
  56692. SSAOOriginalSceneColorEffect: string;
  56693. /**
  56694. * @ignore
  56695. * The SSAO PostProcess id in the pipeline
  56696. */
  56697. SSAORenderEffect: string;
  56698. /**
  56699. * @ignore
  56700. * The horizontal blur PostProcess id in the pipeline
  56701. */
  56702. SSAOBlurHRenderEffect: string;
  56703. /**
  56704. * @ignore
  56705. * The vertical blur PostProcess id in the pipeline
  56706. */
  56707. SSAOBlurVRenderEffect: string;
  56708. /**
  56709. * @ignore
  56710. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56711. */
  56712. SSAOCombineRenderEffect: string;
  56713. /**
  56714. * The output strength of the SSAO post-process. Default value is 1.0.
  56715. */
  56716. totalStrength: number;
  56717. /**
  56718. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56719. */
  56720. radius: number;
  56721. /**
  56722. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56723. * Must not be equal to fallOff and superior to fallOff.
  56724. * Default value is 0.0075
  56725. */
  56726. area: number;
  56727. /**
  56728. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56729. * Must not be equal to area and inferior to area.
  56730. * Default value is 0.000001
  56731. */
  56732. fallOff: number;
  56733. /**
  56734. * The base color of the SSAO post-process
  56735. * The final result is "base + ssao" between [0, 1]
  56736. */
  56737. base: number;
  56738. private _scene;
  56739. private _depthTexture;
  56740. private _randomTexture;
  56741. private _originalColorPostProcess;
  56742. private _ssaoPostProcess;
  56743. private _blurHPostProcess;
  56744. private _blurVPostProcess;
  56745. private _ssaoCombinePostProcess;
  56746. private _firstUpdate;
  56747. /**
  56748. * Gets active scene
  56749. */
  56750. readonly scene: Scene;
  56751. /**
  56752. * @constructor
  56753. * @param name - The rendering pipeline name
  56754. * @param scene - The scene linked to this pipeline
  56755. * @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 }
  56756. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56757. */
  56758. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56759. /**
  56760. * Get the class name
  56761. * @returns "SSAORenderingPipeline"
  56762. */
  56763. getClassName(): string;
  56764. /**
  56765. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56766. */
  56767. dispose(disableDepthRender?: boolean): void;
  56768. private _createBlurPostProcess;
  56769. /** @hidden */
  56770. _rebuild(): void;
  56771. private _createSSAOPostProcess;
  56772. private _createSSAOCombinePostProcess;
  56773. private _createRandomTexture;
  56774. }
  56775. }
  56776. declare module "babylonjs/Shaders/standard.fragment" {
  56777. /** @hidden */
  56778. export var standardPixelShader: {
  56779. name: string;
  56780. shader: string;
  56781. };
  56782. }
  56783. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56784. import { Nullable } from "babylonjs/types";
  56785. import { IAnimatable } from "babylonjs/Misc/tools";
  56786. import { Camera } from "babylonjs/Cameras/camera";
  56787. import { Texture } from "babylonjs/Materials/Textures/texture";
  56788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56789. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56790. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56791. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56792. import { IDisposable } from "babylonjs/scene";
  56793. import { SpotLight } from "babylonjs/Lights/spotLight";
  56794. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56795. import { Scene } from "babylonjs/scene";
  56796. import { Animation } from "babylonjs/Animations/animation";
  56797. import "babylonjs/Shaders/standard.fragment";
  56798. /**
  56799. * Standard rendering pipeline
  56800. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56801. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56802. */
  56803. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56804. /**
  56805. * Public members
  56806. */
  56807. /**
  56808. * Post-process which contains the original scene color before the pipeline applies all the effects
  56809. */
  56810. originalPostProcess: Nullable<PostProcess>;
  56811. /**
  56812. * Post-process used to down scale an image x4
  56813. */
  56814. downSampleX4PostProcess: Nullable<PostProcess>;
  56815. /**
  56816. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56817. */
  56818. brightPassPostProcess: Nullable<PostProcess>;
  56819. /**
  56820. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56821. */
  56822. blurHPostProcesses: PostProcess[];
  56823. /**
  56824. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56825. */
  56826. blurVPostProcesses: PostProcess[];
  56827. /**
  56828. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56829. */
  56830. textureAdderPostProcess: Nullable<PostProcess>;
  56831. /**
  56832. * Post-process used to create volumetric lighting effect
  56833. */
  56834. volumetricLightPostProcess: Nullable<PostProcess>;
  56835. /**
  56836. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56837. */
  56838. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56839. /**
  56840. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56841. */
  56842. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56843. /**
  56844. * Post-process used to merge the volumetric light effect and the real scene color
  56845. */
  56846. volumetricLightMergePostProces: Nullable<PostProcess>;
  56847. /**
  56848. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56849. */
  56850. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56851. /**
  56852. * Base post-process used to calculate the average luminance of the final image for HDR
  56853. */
  56854. luminancePostProcess: Nullable<PostProcess>;
  56855. /**
  56856. * Post-processes used to create down sample post-processes in order to get
  56857. * the average luminance of the final image for HDR
  56858. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56859. */
  56860. luminanceDownSamplePostProcesses: PostProcess[];
  56861. /**
  56862. * Post-process used to create a HDR effect (light adaptation)
  56863. */
  56864. hdrPostProcess: Nullable<PostProcess>;
  56865. /**
  56866. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56867. */
  56868. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56869. /**
  56870. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56871. */
  56872. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56873. /**
  56874. * Post-process used to merge the final HDR post-process and the real scene color
  56875. */
  56876. hdrFinalPostProcess: Nullable<PostProcess>;
  56877. /**
  56878. * Post-process used to create a lens flare effect
  56879. */
  56880. lensFlarePostProcess: Nullable<PostProcess>;
  56881. /**
  56882. * Post-process that merges the result of the lens flare post-process and the real scene color
  56883. */
  56884. lensFlareComposePostProcess: Nullable<PostProcess>;
  56885. /**
  56886. * Post-process used to create a motion blur effect
  56887. */
  56888. motionBlurPostProcess: Nullable<PostProcess>;
  56889. /**
  56890. * Post-process used to create a depth of field effect
  56891. */
  56892. depthOfFieldPostProcess: Nullable<PostProcess>;
  56893. /**
  56894. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56895. */
  56896. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56897. /**
  56898. * Represents the brightness threshold in order to configure the illuminated surfaces
  56899. */
  56900. brightThreshold: number;
  56901. /**
  56902. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56903. */
  56904. blurWidth: number;
  56905. /**
  56906. * Sets if the blur for highlighted surfaces must be only horizontal
  56907. */
  56908. horizontalBlur: boolean;
  56909. /**
  56910. * Gets the overall exposure used by the pipeline
  56911. */
  56912. /**
  56913. * Sets the overall exposure used by the pipeline
  56914. */
  56915. exposure: number;
  56916. /**
  56917. * Texture used typically to simulate "dirty" on camera lens
  56918. */
  56919. lensTexture: Nullable<Texture>;
  56920. /**
  56921. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56922. */
  56923. volumetricLightCoefficient: number;
  56924. /**
  56925. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56926. */
  56927. volumetricLightPower: number;
  56928. /**
  56929. * Used the set the blur intensity to smooth the volumetric lights
  56930. */
  56931. volumetricLightBlurScale: number;
  56932. /**
  56933. * Light (spot or directional) used to generate the volumetric lights rays
  56934. * The source light must have a shadow generate so the pipeline can get its
  56935. * depth map
  56936. */
  56937. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56938. /**
  56939. * For eye adaptation, represents the minimum luminance the eye can see
  56940. */
  56941. hdrMinimumLuminance: number;
  56942. /**
  56943. * For eye adaptation, represents the decrease luminance speed
  56944. */
  56945. hdrDecreaseRate: number;
  56946. /**
  56947. * For eye adaptation, represents the increase luminance speed
  56948. */
  56949. hdrIncreaseRate: number;
  56950. /**
  56951. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56952. */
  56953. /**
  56954. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56955. */
  56956. hdrAutoExposure: boolean;
  56957. /**
  56958. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56959. */
  56960. lensColorTexture: Nullable<Texture>;
  56961. /**
  56962. * The overall strengh for the lens flare effect
  56963. */
  56964. lensFlareStrength: number;
  56965. /**
  56966. * Dispersion coefficient for lens flare ghosts
  56967. */
  56968. lensFlareGhostDispersal: number;
  56969. /**
  56970. * Main lens flare halo width
  56971. */
  56972. lensFlareHaloWidth: number;
  56973. /**
  56974. * Based on the lens distortion effect, defines how much the lens flare result
  56975. * is distorted
  56976. */
  56977. lensFlareDistortionStrength: number;
  56978. /**
  56979. * Lens star texture must be used to simulate rays on the flares and is available
  56980. * in the documentation
  56981. */
  56982. lensStarTexture: Nullable<Texture>;
  56983. /**
  56984. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56985. * flare effect by taking account of the dirt texture
  56986. */
  56987. lensFlareDirtTexture: Nullable<Texture>;
  56988. /**
  56989. * Represents the focal length for the depth of field effect
  56990. */
  56991. depthOfFieldDistance: number;
  56992. /**
  56993. * Represents the blur intensity for the blurred part of the depth of field effect
  56994. */
  56995. depthOfFieldBlurWidth: number;
  56996. /**
  56997. * For motion blur, defines how much the image is blurred by the movement
  56998. */
  56999. motionStrength: number;
  57000. /**
  57001. * List of animations for the pipeline (IAnimatable implementation)
  57002. */
  57003. animations: Animation[];
  57004. /**
  57005. * Private members
  57006. */
  57007. private _scene;
  57008. private _currentDepthOfFieldSource;
  57009. private _basePostProcess;
  57010. private _fixedExposure;
  57011. private _currentExposure;
  57012. private _hdrAutoExposure;
  57013. private _hdrCurrentLuminance;
  57014. private _floatTextureType;
  57015. private _ratio;
  57016. private _bloomEnabled;
  57017. private _depthOfFieldEnabled;
  57018. private _vlsEnabled;
  57019. private _lensFlareEnabled;
  57020. private _hdrEnabled;
  57021. private _motionBlurEnabled;
  57022. private _fxaaEnabled;
  57023. private _motionBlurSamples;
  57024. private _volumetricLightStepsCount;
  57025. private _samples;
  57026. /**
  57027. * @ignore
  57028. * Specifies if the bloom pipeline is enabled
  57029. */
  57030. BloomEnabled: boolean;
  57031. /**
  57032. * @ignore
  57033. * Specifies if the depth of field pipeline is enabed
  57034. */
  57035. DepthOfFieldEnabled: boolean;
  57036. /**
  57037. * @ignore
  57038. * Specifies if the lens flare pipeline is enabed
  57039. */
  57040. LensFlareEnabled: boolean;
  57041. /**
  57042. * @ignore
  57043. * Specifies if the HDR pipeline is enabled
  57044. */
  57045. HDREnabled: boolean;
  57046. /**
  57047. * @ignore
  57048. * Specifies if the volumetric lights scattering effect is enabled
  57049. */
  57050. VLSEnabled: boolean;
  57051. /**
  57052. * @ignore
  57053. * Specifies if the motion blur effect is enabled
  57054. */
  57055. MotionBlurEnabled: boolean;
  57056. /**
  57057. * Specifies if anti-aliasing is enabled
  57058. */
  57059. fxaaEnabled: boolean;
  57060. /**
  57061. * Specifies the number of steps used to calculate the volumetric lights
  57062. * Typically in interval [50, 200]
  57063. */
  57064. volumetricLightStepsCount: number;
  57065. /**
  57066. * Specifies the number of samples used for the motion blur effect
  57067. * Typically in interval [16, 64]
  57068. */
  57069. motionBlurSamples: number;
  57070. /**
  57071. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57072. */
  57073. samples: number;
  57074. /**
  57075. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57076. * @constructor
  57077. * @param name The rendering pipeline name
  57078. * @param scene The scene linked to this pipeline
  57079. * @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)
  57080. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57081. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57082. */
  57083. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57084. private _buildPipeline;
  57085. private _createDownSampleX4PostProcess;
  57086. private _createBrightPassPostProcess;
  57087. private _createBlurPostProcesses;
  57088. private _createTextureAdderPostProcess;
  57089. private _createVolumetricLightPostProcess;
  57090. private _createLuminancePostProcesses;
  57091. private _createHdrPostProcess;
  57092. private _createLensFlarePostProcess;
  57093. private _createDepthOfFieldPostProcess;
  57094. private _createMotionBlurPostProcess;
  57095. private _getDepthTexture;
  57096. private _disposePostProcesses;
  57097. /**
  57098. * Dispose of the pipeline and stop all post processes
  57099. */
  57100. dispose(): void;
  57101. /**
  57102. * Serialize the rendering pipeline (Used when exporting)
  57103. * @returns the serialized object
  57104. */
  57105. serialize(): any;
  57106. /**
  57107. * Parse the serialized pipeline
  57108. * @param source Source pipeline.
  57109. * @param scene The scene to load the pipeline to.
  57110. * @param rootUrl The URL of the serialized pipeline.
  57111. * @returns An instantiated pipeline from the serialized object.
  57112. */
  57113. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57114. /**
  57115. * Luminance steps
  57116. */
  57117. static LuminanceSteps: number;
  57118. }
  57119. }
  57120. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57121. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57124. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57125. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57126. }
  57127. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57128. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57130. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57131. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57132. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57133. }
  57134. declare module "babylonjs/Shaders/tonemap.fragment" {
  57135. /** @hidden */
  57136. export var tonemapPixelShader: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57142. import { Camera } from "babylonjs/Cameras/camera";
  57143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57144. import "babylonjs/Shaders/tonemap.fragment";
  57145. import { Engine } from "babylonjs/Engines/engine";
  57146. /** Defines operator used for tonemapping */
  57147. export enum TonemappingOperator {
  57148. /** Hable */
  57149. Hable = 0,
  57150. /** Reinhard */
  57151. Reinhard = 1,
  57152. /** HejiDawson */
  57153. HejiDawson = 2,
  57154. /** Photographic */
  57155. Photographic = 3
  57156. }
  57157. /**
  57158. * Defines a post process to apply tone mapping
  57159. */
  57160. export class TonemapPostProcess extends PostProcess {
  57161. private _operator;
  57162. /** Defines the required exposure adjustement */
  57163. exposureAdjustment: number;
  57164. /**
  57165. * Creates a new TonemapPostProcess
  57166. * @param name defines the name of the postprocess
  57167. * @param _operator defines the operator to use
  57168. * @param exposureAdjustment defines the required exposure adjustement
  57169. * @param camera defines the camera to use (can be null)
  57170. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57171. * @param engine defines the hosting engine (can be ignore if camera is set)
  57172. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57173. */
  57174. constructor(name: string, _operator: TonemappingOperator,
  57175. /** Defines the required exposure adjustement */
  57176. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57177. }
  57178. }
  57179. declare module "babylonjs/Shaders/depth.vertex" {
  57180. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57181. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57182. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57183. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57184. /** @hidden */
  57185. export var depthVertexShader: {
  57186. name: string;
  57187. shader: string;
  57188. };
  57189. }
  57190. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57191. /** @hidden */
  57192. export var volumetricLightScatteringPixelShader: {
  57193. name: string;
  57194. shader: string;
  57195. };
  57196. }
  57197. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57198. /** @hidden */
  57199. export var volumetricLightScatteringPassPixelShader: {
  57200. name: string;
  57201. shader: string;
  57202. };
  57203. }
  57204. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57205. import { Vector3 } from "babylonjs/Maths/math";
  57206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57207. import { Mesh } from "babylonjs/Meshes/mesh";
  57208. import { Camera } from "babylonjs/Cameras/camera";
  57209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57210. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57211. import { Scene } from "babylonjs/scene";
  57212. import "babylonjs/Meshes/Builders/planeBuilder";
  57213. import "babylonjs/Shaders/depth.vertex";
  57214. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57215. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57216. import { Engine } from "babylonjs/Engines/engine";
  57217. /**
  57218. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57219. */
  57220. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57221. private _volumetricLightScatteringPass;
  57222. private _volumetricLightScatteringRTT;
  57223. private _viewPort;
  57224. private _screenCoordinates;
  57225. private _cachedDefines;
  57226. /**
  57227. * If not undefined, the mesh position is computed from the attached node position
  57228. */
  57229. attachedNode: {
  57230. position: Vector3;
  57231. };
  57232. /**
  57233. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57234. */
  57235. customMeshPosition: Vector3;
  57236. /**
  57237. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57238. */
  57239. useCustomMeshPosition: boolean;
  57240. /**
  57241. * If the post-process should inverse the light scattering direction
  57242. */
  57243. invert: boolean;
  57244. /**
  57245. * The internal mesh used by the post-process
  57246. */
  57247. mesh: Mesh;
  57248. /**
  57249. * @hidden
  57250. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57251. */
  57252. useDiffuseColor: boolean;
  57253. /**
  57254. * Array containing the excluded meshes not rendered in the internal pass
  57255. */
  57256. excludedMeshes: AbstractMesh[];
  57257. /**
  57258. * Controls the overall intensity of the post-process
  57259. */
  57260. exposure: number;
  57261. /**
  57262. * Dissipates each sample's contribution in range [0, 1]
  57263. */
  57264. decay: number;
  57265. /**
  57266. * Controls the overall intensity of each sample
  57267. */
  57268. weight: number;
  57269. /**
  57270. * Controls the density of each sample
  57271. */
  57272. density: number;
  57273. /**
  57274. * @constructor
  57275. * @param name The post-process name
  57276. * @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)
  57277. * @param camera The camera that the post-process will be attached to
  57278. * @param mesh The mesh used to create the light scattering
  57279. * @param samples The post-process quality, default 100
  57280. * @param samplingModeThe post-process filtering mode
  57281. * @param engine The babylon engine
  57282. * @param reusable If the post-process is reusable
  57283. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57284. */
  57285. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57286. /**
  57287. * Returns the string "VolumetricLightScatteringPostProcess"
  57288. * @returns "VolumetricLightScatteringPostProcess"
  57289. */
  57290. getClassName(): string;
  57291. private _isReady;
  57292. /**
  57293. * Sets the new light position for light scattering effect
  57294. * @param position The new custom light position
  57295. */
  57296. setCustomMeshPosition(position: Vector3): void;
  57297. /**
  57298. * Returns the light position for light scattering effect
  57299. * @return Vector3 The custom light position
  57300. */
  57301. getCustomMeshPosition(): Vector3;
  57302. /**
  57303. * Disposes the internal assets and detaches the post-process from the camera
  57304. */
  57305. dispose(camera: Camera): void;
  57306. /**
  57307. * Returns the render target texture used by the post-process
  57308. * @return the render target texture used by the post-process
  57309. */
  57310. getPass(): RenderTargetTexture;
  57311. private _meshExcluded;
  57312. private _createPass;
  57313. private _updateMeshScreenCoordinates;
  57314. /**
  57315. * Creates a default mesh for the Volumeric Light Scattering post-process
  57316. * @param name The mesh name
  57317. * @param scene The scene where to create the mesh
  57318. * @return the default mesh
  57319. */
  57320. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57321. }
  57322. }
  57323. declare module "babylonjs/PostProcesses/index" {
  57324. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57325. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57326. export * from "babylonjs/PostProcesses/bloomEffect";
  57327. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57328. export * from "babylonjs/PostProcesses/blurPostProcess";
  57329. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57330. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57331. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57332. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57333. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57334. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57335. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57336. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57337. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57338. export * from "babylonjs/PostProcesses/filterPostProcess";
  57339. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57340. export * from "babylonjs/PostProcesses/grainPostProcess";
  57341. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57342. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57343. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57344. export * from "babylonjs/PostProcesses/passPostProcess";
  57345. export * from "babylonjs/PostProcesses/postProcess";
  57346. export * from "babylonjs/PostProcesses/postProcessManager";
  57347. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57348. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57349. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57350. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57351. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57352. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57353. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57354. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57355. }
  57356. declare module "babylonjs/Probes/index" {
  57357. export * from "babylonjs/Probes/reflectionProbe";
  57358. }
  57359. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57360. import { Scene } from "babylonjs/scene";
  57361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57362. import { Color3 } from "babylonjs/Maths/math";
  57363. import { SmartArray } from "babylonjs/Misc/smartArray";
  57364. import { ISceneComponent } from "babylonjs/sceneComponent";
  57365. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57366. import "babylonjs/Meshes/Builders/boxBuilder";
  57367. import "babylonjs/Shaders/color.fragment";
  57368. import "babylonjs/Shaders/color.vertex";
  57369. module "babylonjs/scene" {
  57370. interface Scene {
  57371. /** @hidden (Backing field) */
  57372. _boundingBoxRenderer: BoundingBoxRenderer;
  57373. /** @hidden (Backing field) */
  57374. _forceShowBoundingBoxes: boolean;
  57375. /**
  57376. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57377. */
  57378. forceShowBoundingBoxes: boolean;
  57379. /**
  57380. * Gets the bounding box renderer associated with the scene
  57381. * @returns a BoundingBoxRenderer
  57382. */
  57383. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57384. }
  57385. }
  57386. module "babylonjs/Meshes/abstractMesh" {
  57387. interface AbstractMesh {
  57388. /** @hidden (Backing field) */
  57389. _showBoundingBox: boolean;
  57390. /**
  57391. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57392. */
  57393. showBoundingBox: boolean;
  57394. }
  57395. }
  57396. /**
  57397. * Component responsible of rendering the bounding box of the meshes in a scene.
  57398. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57399. */
  57400. export class BoundingBoxRenderer implements ISceneComponent {
  57401. /**
  57402. * The component name helpfull to identify the component in the list of scene components.
  57403. */
  57404. readonly name: string;
  57405. /**
  57406. * The scene the component belongs to.
  57407. */
  57408. scene: Scene;
  57409. /**
  57410. * Color of the bounding box lines placed in front of an object
  57411. */
  57412. frontColor: Color3;
  57413. /**
  57414. * Color of the bounding box lines placed behind an object
  57415. */
  57416. backColor: Color3;
  57417. /**
  57418. * Defines if the renderer should show the back lines or not
  57419. */
  57420. showBackLines: boolean;
  57421. /**
  57422. * @hidden
  57423. */
  57424. renderList: SmartArray<BoundingBox>;
  57425. private _colorShader;
  57426. private _vertexBuffers;
  57427. private _indexBuffer;
  57428. /**
  57429. * Instantiates a new bounding box renderer in a scene.
  57430. * @param scene the scene the renderer renders in
  57431. */
  57432. constructor(scene: Scene);
  57433. /**
  57434. * Registers the component in a given scene
  57435. */
  57436. register(): void;
  57437. private _evaluateSubMesh;
  57438. private _activeMesh;
  57439. private _prepareRessources;
  57440. private _createIndexBuffer;
  57441. /**
  57442. * Rebuilds the elements related to this component in case of
  57443. * context lost for instance.
  57444. */
  57445. rebuild(): void;
  57446. /**
  57447. * @hidden
  57448. */
  57449. reset(): void;
  57450. /**
  57451. * Render the bounding boxes of a specific rendering group
  57452. * @param renderingGroupId defines the rendering group to render
  57453. */
  57454. render(renderingGroupId: number): void;
  57455. /**
  57456. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57457. * @param mesh Define the mesh to render the occlusion bounding box for
  57458. */
  57459. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57460. /**
  57461. * Dispose and release the resources attached to this renderer.
  57462. */
  57463. dispose(): void;
  57464. }
  57465. }
  57466. declare module "babylonjs/Shaders/depth.fragment" {
  57467. /** @hidden */
  57468. export var depthPixelShader: {
  57469. name: string;
  57470. shader: string;
  57471. };
  57472. }
  57473. declare module "babylonjs/Rendering/depthRenderer" {
  57474. import { Nullable } from "babylonjs/types";
  57475. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57476. import { Scene } from "babylonjs/scene";
  57477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57478. import { Camera } from "babylonjs/Cameras/camera";
  57479. import "babylonjs/Shaders/depth.fragment";
  57480. import "babylonjs/Shaders/depth.vertex";
  57481. /**
  57482. * This represents a depth renderer in Babylon.
  57483. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57484. */
  57485. export class DepthRenderer {
  57486. private _scene;
  57487. private _depthMap;
  57488. private _effect;
  57489. private _cachedDefines;
  57490. private _camera;
  57491. /**
  57492. * Specifiess that the depth renderer will only be used within
  57493. * the camera it is created for.
  57494. * This can help forcing its rendering during the camera processing.
  57495. */
  57496. useOnlyInActiveCamera: boolean;
  57497. /** @hidden */
  57498. static _SceneComponentInitialization: (scene: Scene) => void;
  57499. /**
  57500. * Instantiates a depth renderer
  57501. * @param scene The scene the renderer belongs to
  57502. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57503. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57504. */
  57505. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57506. /**
  57507. * Creates the depth rendering effect and checks if the effect is ready.
  57508. * @param subMesh The submesh to be used to render the depth map of
  57509. * @param useInstances If multiple world instances should be used
  57510. * @returns if the depth renderer is ready to render the depth map
  57511. */
  57512. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57513. /**
  57514. * Gets the texture which the depth map will be written to.
  57515. * @returns The depth map texture
  57516. */
  57517. getDepthMap(): RenderTargetTexture;
  57518. /**
  57519. * Disposes of the depth renderer.
  57520. */
  57521. dispose(): void;
  57522. }
  57523. }
  57524. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57525. import { Nullable } from "babylonjs/types";
  57526. import { Scene } from "babylonjs/scene";
  57527. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57528. import { Camera } from "babylonjs/Cameras/camera";
  57529. import { ISceneComponent } from "babylonjs/sceneComponent";
  57530. module "babylonjs/scene" {
  57531. interface Scene {
  57532. /** @hidden (Backing field) */
  57533. _depthRenderer: {
  57534. [id: string]: DepthRenderer;
  57535. };
  57536. /**
  57537. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57538. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57539. * @returns the created depth renderer
  57540. */
  57541. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57542. /**
  57543. * Disables a depth renderer for a given camera
  57544. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57545. */
  57546. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57547. }
  57548. }
  57549. /**
  57550. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57551. * in several rendering techniques.
  57552. */
  57553. export class DepthRendererSceneComponent implements ISceneComponent {
  57554. /**
  57555. * The component name helpfull to identify the component in the list of scene components.
  57556. */
  57557. readonly name: string;
  57558. /**
  57559. * The scene the component belongs to.
  57560. */
  57561. scene: Scene;
  57562. /**
  57563. * Creates a new instance of the component for the given scene
  57564. * @param scene Defines the scene to register the component in
  57565. */
  57566. constructor(scene: Scene);
  57567. /**
  57568. * Registers the component in a given scene
  57569. */
  57570. register(): void;
  57571. /**
  57572. * Rebuilds the elements related to this component in case of
  57573. * context lost for instance.
  57574. */
  57575. rebuild(): void;
  57576. /**
  57577. * Disposes the component and the associated ressources
  57578. */
  57579. dispose(): void;
  57580. private _gatherRenderTargets;
  57581. private _gatherActiveCameraRenderTargets;
  57582. }
  57583. }
  57584. declare module "babylonjs/Shaders/outline.fragment" {
  57585. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57586. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57587. /** @hidden */
  57588. export var outlinePixelShader: {
  57589. name: string;
  57590. shader: string;
  57591. };
  57592. }
  57593. declare module "babylonjs/Shaders/outline.vertex" {
  57594. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57595. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57596. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57597. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57598. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57599. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57600. /** @hidden */
  57601. export var outlineVertexShader: {
  57602. name: string;
  57603. shader: string;
  57604. };
  57605. }
  57606. declare module "babylonjs/Rendering/outlineRenderer" {
  57607. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57608. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57609. import { Scene } from "babylonjs/scene";
  57610. import { ISceneComponent } from "babylonjs/sceneComponent";
  57611. import "babylonjs/Shaders/outline.fragment";
  57612. import "babylonjs/Shaders/outline.vertex";
  57613. module "babylonjs/scene" {
  57614. interface Scene {
  57615. /** @hidden */
  57616. _outlineRenderer: OutlineRenderer;
  57617. /**
  57618. * Gets the outline renderer associated with the scene
  57619. * @returns a OutlineRenderer
  57620. */
  57621. getOutlineRenderer(): OutlineRenderer;
  57622. }
  57623. }
  57624. module "babylonjs/Meshes/abstractMesh" {
  57625. interface AbstractMesh {
  57626. /** @hidden (Backing field) */
  57627. _renderOutline: boolean;
  57628. /**
  57629. * Gets or sets a boolean indicating if the outline must be rendered as well
  57630. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57631. */
  57632. renderOutline: boolean;
  57633. /** @hidden (Backing field) */
  57634. _renderOverlay: boolean;
  57635. /**
  57636. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57637. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57638. */
  57639. renderOverlay: boolean;
  57640. }
  57641. }
  57642. /**
  57643. * This class is responsible to draw bothe outline/overlay of meshes.
  57644. * It should not be used directly but through the available method on mesh.
  57645. */
  57646. export class OutlineRenderer implements ISceneComponent {
  57647. /**
  57648. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57649. */
  57650. private static _StencilReference;
  57651. /**
  57652. * The name of the component. Each component must have a unique name.
  57653. */
  57654. name: string;
  57655. /**
  57656. * The scene the component belongs to.
  57657. */
  57658. scene: Scene;
  57659. /**
  57660. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57661. */
  57662. zOffset: number;
  57663. private _engine;
  57664. private _effect;
  57665. private _cachedDefines;
  57666. private _savedDepthWrite;
  57667. /**
  57668. * Instantiates a new outline renderer. (There could be only one per scene).
  57669. * @param scene Defines the scene it belongs to
  57670. */
  57671. constructor(scene: Scene);
  57672. /**
  57673. * Register the component to one instance of a scene.
  57674. */
  57675. register(): void;
  57676. /**
  57677. * Rebuilds the elements related to this component in case of
  57678. * context lost for instance.
  57679. */
  57680. rebuild(): void;
  57681. /**
  57682. * Disposes the component and the associated ressources.
  57683. */
  57684. dispose(): void;
  57685. /**
  57686. * Renders the outline in the canvas.
  57687. * @param subMesh Defines the sumesh to render
  57688. * @param batch Defines the batch of meshes in case of instances
  57689. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57690. */
  57691. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57692. /**
  57693. * Returns whether or not the outline renderer is ready for a given submesh.
  57694. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57695. * @param subMesh Defines the submesh to check readyness for
  57696. * @param useInstances Defines wheter wee are trying to render instances or not
  57697. * @returns true if ready otherwise false
  57698. */
  57699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57700. private _beforeRenderingMesh;
  57701. private _afterRenderingMesh;
  57702. }
  57703. }
  57704. declare module "babylonjs/Rendering/index" {
  57705. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57706. export * from "babylonjs/Rendering/depthRenderer";
  57707. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57708. export * from "babylonjs/Rendering/edgesRenderer";
  57709. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57710. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57711. export * from "babylonjs/Rendering/outlineRenderer";
  57712. export * from "babylonjs/Rendering/renderingGroup";
  57713. export * from "babylonjs/Rendering/renderingManager";
  57714. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57715. }
  57716. declare module "babylonjs/Sprites/index" {
  57717. export * from "babylonjs/Sprites/sprite";
  57718. export * from "babylonjs/Sprites/spriteManager";
  57719. export * from "babylonjs/Sprites/spriteSceneComponent";
  57720. }
  57721. declare module "babylonjs/Misc/assetsManager" {
  57722. import { Scene } from "babylonjs/scene";
  57723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57724. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57725. import { Skeleton } from "babylonjs/Bones/skeleton";
  57726. import { Observable } from "babylonjs/Misc/observable";
  57727. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57728. import { Texture } from "babylonjs/Materials/Textures/texture";
  57729. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57730. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57731. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57732. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57733. /**
  57734. * Defines the list of states available for a task inside a AssetsManager
  57735. */
  57736. export enum AssetTaskState {
  57737. /**
  57738. * Initialization
  57739. */
  57740. INIT = 0,
  57741. /**
  57742. * Running
  57743. */
  57744. RUNNING = 1,
  57745. /**
  57746. * Done
  57747. */
  57748. DONE = 2,
  57749. /**
  57750. * Error
  57751. */
  57752. ERROR = 3
  57753. }
  57754. /**
  57755. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57756. */
  57757. export abstract class AbstractAssetTask {
  57758. /**
  57759. * Task name
  57760. */ name: string;
  57761. /**
  57762. * Callback called when the task is successful
  57763. */
  57764. onSuccess: (task: any) => void;
  57765. /**
  57766. * Callback called when the task is not successful
  57767. */
  57768. onError: (task: any, message?: string, exception?: any) => void;
  57769. /**
  57770. * Creates a new AssetsManager
  57771. * @param name defines the name of the task
  57772. */
  57773. constructor(
  57774. /**
  57775. * Task name
  57776. */ name: string);
  57777. private _isCompleted;
  57778. private _taskState;
  57779. private _errorObject;
  57780. /**
  57781. * Get if the task is completed
  57782. */
  57783. readonly isCompleted: boolean;
  57784. /**
  57785. * Gets the current state of the task
  57786. */
  57787. readonly taskState: AssetTaskState;
  57788. /**
  57789. * Gets the current error object (if task is in error)
  57790. */
  57791. readonly errorObject: {
  57792. message?: string;
  57793. exception?: any;
  57794. };
  57795. /**
  57796. * Internal only
  57797. * @hidden
  57798. */
  57799. _setErrorObject(message?: string, exception?: any): void;
  57800. /**
  57801. * Execute the current task
  57802. * @param scene defines the scene where you want your assets to be loaded
  57803. * @param onSuccess is a callback called when the task is successfully executed
  57804. * @param onError is a callback called if an error occurs
  57805. */
  57806. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57807. /**
  57808. * Execute the current task
  57809. * @param scene defines the scene where you want your assets to be loaded
  57810. * @param onSuccess is a callback called when the task is successfully executed
  57811. * @param onError is a callback called if an error occurs
  57812. */
  57813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57814. /**
  57815. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57816. * This can be used with failed tasks that have the reason for failure fixed.
  57817. */
  57818. reset(): void;
  57819. private onErrorCallback;
  57820. private onDoneCallback;
  57821. }
  57822. /**
  57823. * Define the interface used by progress events raised during assets loading
  57824. */
  57825. export interface IAssetsProgressEvent {
  57826. /**
  57827. * Defines the number of remaining tasks to process
  57828. */
  57829. remainingCount: number;
  57830. /**
  57831. * Defines the total number of tasks
  57832. */
  57833. totalCount: number;
  57834. /**
  57835. * Defines the task that was just processed
  57836. */
  57837. task: AbstractAssetTask;
  57838. }
  57839. /**
  57840. * Class used to share progress information about assets loading
  57841. */
  57842. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57843. /**
  57844. * Defines the number of remaining tasks to process
  57845. */
  57846. remainingCount: number;
  57847. /**
  57848. * Defines the total number of tasks
  57849. */
  57850. totalCount: number;
  57851. /**
  57852. * Defines the task that was just processed
  57853. */
  57854. task: AbstractAssetTask;
  57855. /**
  57856. * Creates a AssetsProgressEvent
  57857. * @param remainingCount defines the number of remaining tasks to process
  57858. * @param totalCount defines the total number of tasks
  57859. * @param task defines the task that was just processed
  57860. */
  57861. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57862. }
  57863. /**
  57864. * Define a task used by AssetsManager to load meshes
  57865. */
  57866. export class MeshAssetTask extends AbstractAssetTask {
  57867. /**
  57868. * Defines the name of the task
  57869. */
  57870. name: string;
  57871. /**
  57872. * Defines the list of mesh's names you want to load
  57873. */
  57874. meshesNames: any;
  57875. /**
  57876. * Defines the root url to use as a base to load your meshes and associated resources
  57877. */
  57878. rootUrl: string;
  57879. /**
  57880. * Defines the filename of the scene to load from
  57881. */
  57882. sceneFilename: string;
  57883. /**
  57884. * Gets the list of loaded meshes
  57885. */
  57886. loadedMeshes: Array<AbstractMesh>;
  57887. /**
  57888. * Gets the list of loaded particle systems
  57889. */
  57890. loadedParticleSystems: Array<IParticleSystem>;
  57891. /**
  57892. * Gets the list of loaded skeletons
  57893. */
  57894. loadedSkeletons: Array<Skeleton>;
  57895. /**
  57896. * Gets the list of loaded animation groups
  57897. */
  57898. loadedAnimationGroups: Array<AnimationGroup>;
  57899. /**
  57900. * Callback called when the task is successful
  57901. */
  57902. onSuccess: (task: MeshAssetTask) => void;
  57903. /**
  57904. * Callback called when the task is successful
  57905. */
  57906. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57907. /**
  57908. * Creates a new MeshAssetTask
  57909. * @param name defines the name of the task
  57910. * @param meshesNames defines the list of mesh's names you want to load
  57911. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57912. * @param sceneFilename defines the filename of the scene to load from
  57913. */
  57914. constructor(
  57915. /**
  57916. * Defines the name of the task
  57917. */
  57918. name: string,
  57919. /**
  57920. * Defines the list of mesh's names you want to load
  57921. */
  57922. meshesNames: any,
  57923. /**
  57924. * Defines the root url to use as a base to load your meshes and associated resources
  57925. */
  57926. rootUrl: string,
  57927. /**
  57928. * Defines the filename of the scene to load from
  57929. */
  57930. sceneFilename: string);
  57931. /**
  57932. * Execute the current task
  57933. * @param scene defines the scene where you want your assets to be loaded
  57934. * @param onSuccess is a callback called when the task is successfully executed
  57935. * @param onError is a callback called if an error occurs
  57936. */
  57937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57938. }
  57939. /**
  57940. * Define a task used by AssetsManager to load text content
  57941. */
  57942. export class TextFileAssetTask extends AbstractAssetTask {
  57943. /**
  57944. * Defines the name of the task
  57945. */
  57946. name: string;
  57947. /**
  57948. * Defines the location of the file to load
  57949. */
  57950. url: string;
  57951. /**
  57952. * Gets the loaded text string
  57953. */
  57954. text: string;
  57955. /**
  57956. * Callback called when the task is successful
  57957. */
  57958. onSuccess: (task: TextFileAssetTask) => void;
  57959. /**
  57960. * Callback called when the task is successful
  57961. */
  57962. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57963. /**
  57964. * Creates a new TextFileAssetTask object
  57965. * @param name defines the name of the task
  57966. * @param url defines the location of the file to load
  57967. */
  57968. constructor(
  57969. /**
  57970. * Defines the name of the task
  57971. */
  57972. name: string,
  57973. /**
  57974. * Defines the location of the file to load
  57975. */
  57976. url: string);
  57977. /**
  57978. * Execute the current task
  57979. * @param scene defines the scene where you want your assets to be loaded
  57980. * @param onSuccess is a callback called when the task is successfully executed
  57981. * @param onError is a callback called if an error occurs
  57982. */
  57983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57984. }
  57985. /**
  57986. * Define a task used by AssetsManager to load binary data
  57987. */
  57988. export class BinaryFileAssetTask extends AbstractAssetTask {
  57989. /**
  57990. * Defines the name of the task
  57991. */
  57992. name: string;
  57993. /**
  57994. * Defines the location of the file to load
  57995. */
  57996. url: string;
  57997. /**
  57998. * Gets the lodaded data (as an array buffer)
  57999. */
  58000. data: ArrayBuffer;
  58001. /**
  58002. * Callback called when the task is successful
  58003. */
  58004. onSuccess: (task: BinaryFileAssetTask) => void;
  58005. /**
  58006. * Callback called when the task is successful
  58007. */
  58008. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58009. /**
  58010. * Creates a new BinaryFileAssetTask object
  58011. * @param name defines the name of the new task
  58012. * @param url defines the location of the file to load
  58013. */
  58014. constructor(
  58015. /**
  58016. * Defines the name of the task
  58017. */
  58018. name: string,
  58019. /**
  58020. * Defines the location of the file to load
  58021. */
  58022. url: string);
  58023. /**
  58024. * Execute the current task
  58025. * @param scene defines the scene where you want your assets to be loaded
  58026. * @param onSuccess is a callback called when the task is successfully executed
  58027. * @param onError is a callback called if an error occurs
  58028. */
  58029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58030. }
  58031. /**
  58032. * Define a task used by AssetsManager to load images
  58033. */
  58034. export class ImageAssetTask extends AbstractAssetTask {
  58035. /**
  58036. * Defines the name of the task
  58037. */
  58038. name: string;
  58039. /**
  58040. * Defines the location of the image to load
  58041. */
  58042. url: string;
  58043. /**
  58044. * Gets the loaded images
  58045. */
  58046. image: HTMLImageElement;
  58047. /**
  58048. * Callback called when the task is successful
  58049. */
  58050. onSuccess: (task: ImageAssetTask) => void;
  58051. /**
  58052. * Callback called when the task is successful
  58053. */
  58054. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58055. /**
  58056. * Creates a new ImageAssetTask
  58057. * @param name defines the name of the task
  58058. * @param url defines the location of the image to load
  58059. */
  58060. constructor(
  58061. /**
  58062. * Defines the name of the task
  58063. */
  58064. name: string,
  58065. /**
  58066. * Defines the location of the image to load
  58067. */
  58068. url: string);
  58069. /**
  58070. * Execute the current task
  58071. * @param scene defines the scene where you want your assets to be loaded
  58072. * @param onSuccess is a callback called when the task is successfully executed
  58073. * @param onError is a callback called if an error occurs
  58074. */
  58075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58076. }
  58077. /**
  58078. * Defines the interface used by texture loading tasks
  58079. */
  58080. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58081. /**
  58082. * Gets the loaded texture
  58083. */
  58084. texture: TEX;
  58085. }
  58086. /**
  58087. * Define a task used by AssetsManager to load 2D textures
  58088. */
  58089. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58090. /**
  58091. * Defines the name of the task
  58092. */
  58093. name: string;
  58094. /**
  58095. * Defines the location of the file to load
  58096. */
  58097. url: string;
  58098. /**
  58099. * Defines if mipmap should not be generated (default is false)
  58100. */
  58101. noMipmap?: boolean | undefined;
  58102. /**
  58103. * Defines if texture must be inverted on Y axis (default is false)
  58104. */
  58105. invertY?: boolean | undefined;
  58106. /**
  58107. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58108. */
  58109. samplingMode: number;
  58110. /**
  58111. * Gets the loaded texture
  58112. */
  58113. texture: Texture;
  58114. /**
  58115. * Callback called when the task is successful
  58116. */
  58117. onSuccess: (task: TextureAssetTask) => void;
  58118. /**
  58119. * Callback called when the task is successful
  58120. */
  58121. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58122. /**
  58123. * Creates a new TextureAssetTask object
  58124. * @param name defines the name of the task
  58125. * @param url defines the location of the file to load
  58126. * @param noMipmap defines if mipmap should not be generated (default is false)
  58127. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58128. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58129. */
  58130. constructor(
  58131. /**
  58132. * Defines the name of the task
  58133. */
  58134. name: string,
  58135. /**
  58136. * Defines the location of the file to load
  58137. */
  58138. url: string,
  58139. /**
  58140. * Defines if mipmap should not be generated (default is false)
  58141. */
  58142. noMipmap?: boolean | undefined,
  58143. /**
  58144. * Defines if texture must be inverted on Y axis (default is false)
  58145. */
  58146. invertY?: boolean | undefined,
  58147. /**
  58148. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58149. */
  58150. samplingMode?: number);
  58151. /**
  58152. * Execute the current task
  58153. * @param scene defines the scene where you want your assets to be loaded
  58154. * @param onSuccess is a callback called when the task is successfully executed
  58155. * @param onError is a callback called if an error occurs
  58156. */
  58157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58158. }
  58159. /**
  58160. * Define a task used by AssetsManager to load cube textures
  58161. */
  58162. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58163. /**
  58164. * Defines the name of the task
  58165. */
  58166. name: string;
  58167. /**
  58168. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58169. */
  58170. url: string;
  58171. /**
  58172. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58173. */
  58174. extensions?: string[] | undefined;
  58175. /**
  58176. * Defines if mipmaps should not be generated (default is false)
  58177. */
  58178. noMipmap?: boolean | undefined;
  58179. /**
  58180. * Defines the explicit list of files (undefined by default)
  58181. */
  58182. files?: string[] | undefined;
  58183. /**
  58184. * Gets the loaded texture
  58185. */
  58186. texture: CubeTexture;
  58187. /**
  58188. * Callback called when the task is successful
  58189. */
  58190. onSuccess: (task: CubeTextureAssetTask) => void;
  58191. /**
  58192. * Callback called when the task is successful
  58193. */
  58194. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58195. /**
  58196. * Creates a new CubeTextureAssetTask
  58197. * @param name defines the name of the task
  58198. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58199. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58200. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58201. * @param files defines the explicit list of files (undefined by default)
  58202. */
  58203. constructor(
  58204. /**
  58205. * Defines the name of the task
  58206. */
  58207. name: string,
  58208. /**
  58209. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58210. */
  58211. url: string,
  58212. /**
  58213. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58214. */
  58215. extensions?: string[] | undefined,
  58216. /**
  58217. * Defines if mipmaps should not be generated (default is false)
  58218. */
  58219. noMipmap?: boolean | undefined,
  58220. /**
  58221. * Defines the explicit list of files (undefined by default)
  58222. */
  58223. files?: string[] | undefined);
  58224. /**
  58225. * Execute the current task
  58226. * @param scene defines the scene where you want your assets to be loaded
  58227. * @param onSuccess is a callback called when the task is successfully executed
  58228. * @param onError is a callback called if an error occurs
  58229. */
  58230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58231. }
  58232. /**
  58233. * Define a task used by AssetsManager to load HDR cube textures
  58234. */
  58235. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58236. /**
  58237. * Defines the name of the task
  58238. */
  58239. name: string;
  58240. /**
  58241. * Defines the location of the file to load
  58242. */
  58243. url: string;
  58244. /**
  58245. * Defines the desired size (the more it increases the longer the generation will be)
  58246. */
  58247. size: number;
  58248. /**
  58249. * Defines if mipmaps should not be generated (default is false)
  58250. */
  58251. noMipmap: boolean;
  58252. /**
  58253. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58254. */
  58255. generateHarmonics: boolean;
  58256. /**
  58257. * 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)
  58258. */
  58259. gammaSpace: boolean;
  58260. /**
  58261. * Internal Use Only
  58262. */
  58263. reserved: boolean;
  58264. /**
  58265. * Gets the loaded texture
  58266. */
  58267. texture: HDRCubeTexture;
  58268. /**
  58269. * Callback called when the task is successful
  58270. */
  58271. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58272. /**
  58273. * Callback called when the task is successful
  58274. */
  58275. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58276. /**
  58277. * Creates a new HDRCubeTextureAssetTask object
  58278. * @param name defines the name of the task
  58279. * @param url defines the location of the file to load
  58280. * @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.
  58281. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58282. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58283. * @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)
  58284. * @param reserved Internal use only
  58285. */
  58286. constructor(
  58287. /**
  58288. * Defines the name of the task
  58289. */
  58290. name: string,
  58291. /**
  58292. * Defines the location of the file to load
  58293. */
  58294. url: string,
  58295. /**
  58296. * Defines the desired size (the more it increases the longer the generation will be)
  58297. */
  58298. size: number,
  58299. /**
  58300. * Defines if mipmaps should not be generated (default is false)
  58301. */
  58302. noMipmap?: boolean,
  58303. /**
  58304. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58305. */
  58306. generateHarmonics?: boolean,
  58307. /**
  58308. * 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)
  58309. */
  58310. gammaSpace?: boolean,
  58311. /**
  58312. * Internal Use Only
  58313. */
  58314. reserved?: boolean);
  58315. /**
  58316. * Execute the current task
  58317. * @param scene defines the scene where you want your assets to be loaded
  58318. * @param onSuccess is a callback called when the task is successfully executed
  58319. * @param onError is a callback called if an error occurs
  58320. */
  58321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58322. }
  58323. /**
  58324. * Define a task used by AssetsManager to load Equirectangular cube textures
  58325. */
  58326. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58327. /**
  58328. * Defines the name of the task
  58329. */
  58330. name: string;
  58331. /**
  58332. * Defines the location of the file to load
  58333. */
  58334. url: string;
  58335. /**
  58336. * Defines the desired size (the more it increases the longer the generation will be)
  58337. */
  58338. size: number;
  58339. /**
  58340. * Defines if mipmaps should not be generated (default is false)
  58341. */
  58342. noMipmap: boolean;
  58343. /**
  58344. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58345. * but the standard material would require them in Gamma space) (default is true)
  58346. */
  58347. gammaSpace: boolean;
  58348. /**
  58349. * Gets the loaded texture
  58350. */
  58351. texture: EquiRectangularCubeTexture;
  58352. /**
  58353. * Callback called when the task is successful
  58354. */
  58355. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58356. /**
  58357. * Callback called when the task is successful
  58358. */
  58359. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58360. /**
  58361. * Creates a new EquiRectangularCubeTextureAssetTask object
  58362. * @param name defines the name of the task
  58363. * @param url defines the location of the file to load
  58364. * @param size defines the desired size (the more it increases the longer the generation will be)
  58365. * If the size is omitted this implies you are using a preprocessed cubemap.
  58366. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58367. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58368. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58369. * (default is true)
  58370. */
  58371. constructor(
  58372. /**
  58373. * Defines the name of the task
  58374. */
  58375. name: string,
  58376. /**
  58377. * Defines the location of the file to load
  58378. */
  58379. url: string,
  58380. /**
  58381. * Defines the desired size (the more it increases the longer the generation will be)
  58382. */
  58383. size: number,
  58384. /**
  58385. * Defines if mipmaps should not be generated (default is false)
  58386. */
  58387. noMipmap?: boolean,
  58388. /**
  58389. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58390. * but the standard material would require them in Gamma space) (default is true)
  58391. */
  58392. gammaSpace?: boolean);
  58393. /**
  58394. * Execute the current task
  58395. * @param scene defines the scene where you want your assets to be loaded
  58396. * @param onSuccess is a callback called when the task is successfully executed
  58397. * @param onError is a callback called if an error occurs
  58398. */
  58399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58400. }
  58401. /**
  58402. * This class can be used to easily import assets into a scene
  58403. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58404. */
  58405. export class AssetsManager {
  58406. private _scene;
  58407. private _isLoading;
  58408. protected _tasks: AbstractAssetTask[];
  58409. protected _waitingTasksCount: number;
  58410. protected _totalTasksCount: number;
  58411. /**
  58412. * Callback called when all tasks are processed
  58413. */
  58414. onFinish: (tasks: AbstractAssetTask[]) => void;
  58415. /**
  58416. * Callback called when a task is successful
  58417. */
  58418. onTaskSuccess: (task: AbstractAssetTask) => void;
  58419. /**
  58420. * Callback called when a task had an error
  58421. */
  58422. onTaskError: (task: AbstractAssetTask) => void;
  58423. /**
  58424. * Callback called when a task is done (whatever the result is)
  58425. */
  58426. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58427. /**
  58428. * Observable called when all tasks are processed
  58429. */
  58430. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58431. /**
  58432. * Observable called when a task had an error
  58433. */
  58434. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58435. /**
  58436. * Observable called when all tasks were executed
  58437. */
  58438. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58439. /**
  58440. * Observable called when a task is done (whatever the result is)
  58441. */
  58442. onProgressObservable: Observable<IAssetsProgressEvent>;
  58443. /**
  58444. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58446. */
  58447. useDefaultLoadingScreen: boolean;
  58448. /**
  58449. * Creates a new AssetsManager
  58450. * @param scene defines the scene to work on
  58451. */
  58452. constructor(scene: Scene);
  58453. /**
  58454. * Add a MeshAssetTask to the list of active tasks
  58455. * @param taskName defines the name of the new task
  58456. * @param meshesNames defines the name of meshes to load
  58457. * @param rootUrl defines the root url to use to locate files
  58458. * @param sceneFilename defines the filename of the scene file
  58459. * @returns a new MeshAssetTask object
  58460. */
  58461. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58462. /**
  58463. * Add a TextFileAssetTask to the list of active tasks
  58464. * @param taskName defines the name of the new task
  58465. * @param url defines the url of the file to load
  58466. * @returns a new TextFileAssetTask object
  58467. */
  58468. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58469. /**
  58470. * Add a BinaryFileAssetTask to the list of active tasks
  58471. * @param taskName defines the name of the new task
  58472. * @param url defines the url of the file to load
  58473. * @returns a new BinaryFileAssetTask object
  58474. */
  58475. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58476. /**
  58477. * Add a ImageAssetTask to the list of active tasks
  58478. * @param taskName defines the name of the new task
  58479. * @param url defines the url of the file to load
  58480. * @returns a new ImageAssetTask object
  58481. */
  58482. addImageTask(taskName: string, url: string): ImageAssetTask;
  58483. /**
  58484. * Add a TextureAssetTask to the list of active tasks
  58485. * @param taskName defines the name of the new task
  58486. * @param url defines the url of the file to load
  58487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58488. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58489. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58490. * @returns a new TextureAssetTask object
  58491. */
  58492. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58493. /**
  58494. * Add a CubeTextureAssetTask to the list of active tasks
  58495. * @param taskName defines the name of the new task
  58496. * @param url defines the url of the file to load
  58497. * @param extensions defines the extension to use to load the cube map (can be null)
  58498. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58499. * @param files defines the list of files to load (can be null)
  58500. * @returns a new CubeTextureAssetTask object
  58501. */
  58502. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58503. /**
  58504. *
  58505. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58506. * @param taskName defines the name of the new task
  58507. * @param url defines the url of the file to load
  58508. * @param size defines the size you want for the cubemap (can be null)
  58509. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58510. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58511. * @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)
  58512. * @param reserved Internal use only
  58513. * @returns a new HDRCubeTextureAssetTask object
  58514. */
  58515. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58516. /**
  58517. *
  58518. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58519. * @param taskName defines the name of the new task
  58520. * @param url defines the url of the file to load
  58521. * @param size defines the size you want for the cubemap (can be null)
  58522. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58523. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58524. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58525. * @returns a new EquiRectangularCubeTextureAssetTask object
  58526. */
  58527. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58528. /**
  58529. * Remove a task from the assets manager.
  58530. * @param task the task to remove
  58531. */
  58532. removeTask(task: AbstractAssetTask): void;
  58533. private _decreaseWaitingTasksCount;
  58534. private _runTask;
  58535. /**
  58536. * Reset the AssetsManager and remove all tasks
  58537. * @return the current instance of the AssetsManager
  58538. */
  58539. reset(): AssetsManager;
  58540. /**
  58541. * Start the loading process
  58542. * @return the current instance of the AssetsManager
  58543. */
  58544. load(): AssetsManager;
  58545. /**
  58546. * Start the loading process as an async operation
  58547. * @return a promise returning the list of failed tasks
  58548. */
  58549. loadAsync(): Promise<void>;
  58550. }
  58551. }
  58552. declare module "babylonjs/Misc/deferred" {
  58553. /**
  58554. * Wrapper class for promise with external resolve and reject.
  58555. */
  58556. export class Deferred<T> {
  58557. /**
  58558. * The promise associated with this deferred object.
  58559. */
  58560. readonly promise: Promise<T>;
  58561. private _resolve;
  58562. private _reject;
  58563. /**
  58564. * The resolve method of the promise associated with this deferred object.
  58565. */
  58566. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58567. /**
  58568. * The reject method of the promise associated with this deferred object.
  58569. */
  58570. readonly reject: (reason?: any) => void;
  58571. /**
  58572. * Constructor for this deferred object.
  58573. */
  58574. constructor();
  58575. }
  58576. }
  58577. declare module "babylonjs/Misc/meshExploder" {
  58578. import { Mesh } from "babylonjs/Meshes/mesh";
  58579. /**
  58580. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58581. */
  58582. export class MeshExploder {
  58583. private _centerMesh;
  58584. private _meshes;
  58585. private _meshesOrigins;
  58586. private _toCenterVectors;
  58587. private _scaledDirection;
  58588. private _newPosition;
  58589. private _centerPosition;
  58590. /**
  58591. * Explodes meshes from a center mesh.
  58592. * @param meshes The meshes to explode.
  58593. * @param centerMesh The mesh to be center of explosion.
  58594. */
  58595. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58596. private _setCenterMesh;
  58597. /**
  58598. * Get class name
  58599. * @returns "MeshExploder"
  58600. */
  58601. getClassName(): string;
  58602. /**
  58603. * "Exploded meshes"
  58604. * @returns Array of meshes with the centerMesh at index 0.
  58605. */
  58606. getMeshes(): Array<Mesh>;
  58607. /**
  58608. * Explodes meshes giving a specific direction
  58609. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58610. */
  58611. explode(direction?: number): void;
  58612. }
  58613. }
  58614. declare module "babylonjs/Misc/filesInput" {
  58615. import { Engine } from "babylonjs/Engines/engine";
  58616. import { Scene } from "babylonjs/scene";
  58617. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58618. /**
  58619. * Class used to help managing file picking and drag'n'drop
  58620. */
  58621. export class FilesInput {
  58622. /**
  58623. * List of files ready to be loaded
  58624. */
  58625. static readonly FilesToLoad: {
  58626. [key: string]: File;
  58627. };
  58628. /**
  58629. * Callback called when a file is processed
  58630. */
  58631. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58632. private _engine;
  58633. private _currentScene;
  58634. private _sceneLoadedCallback;
  58635. private _progressCallback;
  58636. private _additionalRenderLoopLogicCallback;
  58637. private _textureLoadingCallback;
  58638. private _startingProcessingFilesCallback;
  58639. private _onReloadCallback;
  58640. private _errorCallback;
  58641. private _elementToMonitor;
  58642. private _sceneFileToLoad;
  58643. private _filesToLoad;
  58644. /**
  58645. * Creates a new FilesInput
  58646. * @param engine defines the rendering engine
  58647. * @param scene defines the hosting scene
  58648. * @param sceneLoadedCallback callback called when scene is loaded
  58649. * @param progressCallback callback called to track progress
  58650. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58651. * @param textureLoadingCallback callback called when a texture is loading
  58652. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58653. * @param onReloadCallback callback called when a reload is requested
  58654. * @param errorCallback callback call if an error occurs
  58655. */
  58656. 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);
  58657. private _dragEnterHandler;
  58658. private _dragOverHandler;
  58659. private _dropHandler;
  58660. /**
  58661. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58662. * @param elementToMonitor defines the DOM element to track
  58663. */
  58664. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58665. /**
  58666. * Release all associated resources
  58667. */
  58668. dispose(): void;
  58669. private renderFunction;
  58670. private drag;
  58671. private drop;
  58672. private _traverseFolder;
  58673. private _processFiles;
  58674. /**
  58675. * Load files from a drop event
  58676. * @param event defines the drop event to use as source
  58677. */
  58678. loadFiles(event: any): void;
  58679. private _processReload;
  58680. /**
  58681. * Reload the current scene from the loaded files
  58682. */
  58683. reload(): void;
  58684. }
  58685. }
  58686. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58687. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58688. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58689. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58690. }
  58691. declare module "babylonjs/Misc/sceneOptimizer" {
  58692. import { Scene, IDisposable } from "babylonjs/scene";
  58693. import { Observable } from "babylonjs/Misc/observable";
  58694. /**
  58695. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58697. */
  58698. export class SceneOptimization {
  58699. /**
  58700. * Defines the priority of this optimization (0 by default which means first in the list)
  58701. */
  58702. priority: number;
  58703. /**
  58704. * Gets a string describing the action executed by the current optimization
  58705. * @returns description string
  58706. */
  58707. getDescription(): string;
  58708. /**
  58709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58710. * @param scene defines the current scene where to apply this optimization
  58711. * @param optimizer defines the current optimizer
  58712. * @returns true if everything that can be done was applied
  58713. */
  58714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58715. /**
  58716. * Creates the SceneOptimization object
  58717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58718. * @param desc defines the description associated with the optimization
  58719. */
  58720. constructor(
  58721. /**
  58722. * Defines the priority of this optimization (0 by default which means first in the list)
  58723. */
  58724. priority?: number);
  58725. }
  58726. /**
  58727. * Defines an optimization used to reduce the size of render target textures
  58728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58729. */
  58730. export class TextureOptimization extends SceneOptimization {
  58731. /**
  58732. * Defines the priority of this optimization (0 by default which means first in the list)
  58733. */
  58734. priority: number;
  58735. /**
  58736. * 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
  58737. */
  58738. maximumSize: number;
  58739. /**
  58740. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58741. */
  58742. step: number;
  58743. /**
  58744. * Gets a string describing the action executed by the current optimization
  58745. * @returns description string
  58746. */
  58747. getDescription(): string;
  58748. /**
  58749. * Creates the TextureOptimization object
  58750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58751. * @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
  58752. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58753. */
  58754. constructor(
  58755. /**
  58756. * Defines the priority of this optimization (0 by default which means first in the list)
  58757. */
  58758. priority?: number,
  58759. /**
  58760. * 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
  58761. */
  58762. maximumSize?: number,
  58763. /**
  58764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58765. */
  58766. step?: number);
  58767. /**
  58768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58769. * @param scene defines the current scene where to apply this optimization
  58770. * @param optimizer defines the current optimizer
  58771. * @returns true if everything that can be done was applied
  58772. */
  58773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58774. }
  58775. /**
  58776. * Defines an optimization used to increase or decrease the rendering resolution
  58777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58778. */
  58779. export class HardwareScalingOptimization extends SceneOptimization {
  58780. /**
  58781. * Defines the priority of this optimization (0 by default which means first in the list)
  58782. */
  58783. priority: number;
  58784. /**
  58785. * Defines the maximum scale to use (2 by default)
  58786. */
  58787. maximumScale: number;
  58788. /**
  58789. * Defines the step to use between two passes (0.5 by default)
  58790. */
  58791. step: number;
  58792. private _currentScale;
  58793. private _directionOffset;
  58794. /**
  58795. * Gets a string describing the action executed by the current optimization
  58796. * @return description string
  58797. */
  58798. getDescription(): string;
  58799. /**
  58800. * Creates the HardwareScalingOptimization object
  58801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58802. * @param maximumScale defines the maximum scale to use (2 by default)
  58803. * @param step defines the step to use between two passes (0.5 by default)
  58804. */
  58805. constructor(
  58806. /**
  58807. * Defines the priority of this optimization (0 by default which means first in the list)
  58808. */
  58809. priority?: number,
  58810. /**
  58811. * Defines the maximum scale to use (2 by default)
  58812. */
  58813. maximumScale?: number,
  58814. /**
  58815. * Defines the step to use between two passes (0.5 by default)
  58816. */
  58817. step?: number);
  58818. /**
  58819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58820. * @param scene defines the current scene where to apply this optimization
  58821. * @param optimizer defines the current optimizer
  58822. * @returns true if everything that can be done was applied
  58823. */
  58824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58825. }
  58826. /**
  58827. * Defines an optimization used to remove shadows
  58828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58829. */
  58830. export class ShadowsOptimization extends SceneOptimization {
  58831. /**
  58832. * Gets a string describing the action executed by the current optimization
  58833. * @return description string
  58834. */
  58835. getDescription(): string;
  58836. /**
  58837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58838. * @param scene defines the current scene where to apply this optimization
  58839. * @param optimizer defines the current optimizer
  58840. * @returns true if everything that can be done was applied
  58841. */
  58842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58843. }
  58844. /**
  58845. * Defines an optimization used to turn post-processes off
  58846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58847. */
  58848. export class PostProcessesOptimization extends SceneOptimization {
  58849. /**
  58850. * Gets a string describing the action executed by the current optimization
  58851. * @return description string
  58852. */
  58853. getDescription(): string;
  58854. /**
  58855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58856. * @param scene defines the current scene where to apply this optimization
  58857. * @param optimizer defines the current optimizer
  58858. * @returns true if everything that can be done was applied
  58859. */
  58860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58861. }
  58862. /**
  58863. * Defines an optimization used to turn lens flares off
  58864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58865. */
  58866. export class LensFlaresOptimization extends SceneOptimization {
  58867. /**
  58868. * Gets a string describing the action executed by the current optimization
  58869. * @return description string
  58870. */
  58871. getDescription(): string;
  58872. /**
  58873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58874. * @param scene defines the current scene where to apply this optimization
  58875. * @param optimizer defines the current optimizer
  58876. * @returns true if everything that can be done was applied
  58877. */
  58878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58879. }
  58880. /**
  58881. * Defines an optimization based on user defined callback.
  58882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58883. */
  58884. export class CustomOptimization extends SceneOptimization {
  58885. /**
  58886. * Callback called to apply the custom optimization.
  58887. */
  58888. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58889. /**
  58890. * Callback called to get custom description
  58891. */
  58892. onGetDescription: () => string;
  58893. /**
  58894. * Gets a string describing the action executed by the current optimization
  58895. * @returns description string
  58896. */
  58897. getDescription(): string;
  58898. /**
  58899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58900. * @param scene defines the current scene where to apply this optimization
  58901. * @param optimizer defines the current optimizer
  58902. * @returns true if everything that can be done was applied
  58903. */
  58904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58905. }
  58906. /**
  58907. * Defines an optimization used to turn particles off
  58908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58909. */
  58910. export class ParticlesOptimization extends SceneOptimization {
  58911. /**
  58912. * Gets a string describing the action executed by the current optimization
  58913. * @return description string
  58914. */
  58915. getDescription(): string;
  58916. /**
  58917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58918. * @param scene defines the current scene where to apply this optimization
  58919. * @param optimizer defines the current optimizer
  58920. * @returns true if everything that can be done was applied
  58921. */
  58922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58923. }
  58924. /**
  58925. * Defines an optimization used to turn render targets off
  58926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58927. */
  58928. export class RenderTargetsOptimization extends SceneOptimization {
  58929. /**
  58930. * Gets a string describing the action executed by the current optimization
  58931. * @return description string
  58932. */
  58933. getDescription(): string;
  58934. /**
  58935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58936. * @param scene defines the current scene where to apply this optimization
  58937. * @param optimizer defines the current optimizer
  58938. * @returns true if everything that can be done was applied
  58939. */
  58940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58941. }
  58942. /**
  58943. * Defines an optimization used to merge meshes with compatible materials
  58944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58945. */
  58946. export class MergeMeshesOptimization extends SceneOptimization {
  58947. private static _UpdateSelectionTree;
  58948. /**
  58949. * Gets or sets a boolean which defines if optimization octree has to be updated
  58950. */
  58951. /**
  58952. * Gets or sets a boolean which defines if optimization octree has to be updated
  58953. */
  58954. static UpdateSelectionTree: boolean;
  58955. /**
  58956. * Gets a string describing the action executed by the current optimization
  58957. * @return description string
  58958. */
  58959. getDescription(): string;
  58960. private _canBeMerged;
  58961. /**
  58962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58963. * @param scene defines the current scene where to apply this optimization
  58964. * @param optimizer defines the current optimizer
  58965. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58966. * @returns true if everything that can be done was applied
  58967. */
  58968. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58969. }
  58970. /**
  58971. * Defines a list of options used by SceneOptimizer
  58972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58973. */
  58974. export class SceneOptimizerOptions {
  58975. /**
  58976. * Defines the target frame rate to reach (60 by default)
  58977. */
  58978. targetFrameRate: number;
  58979. /**
  58980. * Defines the interval between two checkes (2000ms by default)
  58981. */
  58982. trackerDuration: number;
  58983. /**
  58984. * Gets the list of optimizations to apply
  58985. */
  58986. optimizations: SceneOptimization[];
  58987. /**
  58988. * Creates a new list of options used by SceneOptimizer
  58989. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58990. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58991. */
  58992. constructor(
  58993. /**
  58994. * Defines the target frame rate to reach (60 by default)
  58995. */
  58996. targetFrameRate?: number,
  58997. /**
  58998. * Defines the interval between two checkes (2000ms by default)
  58999. */
  59000. trackerDuration?: number);
  59001. /**
  59002. * Add a new optimization
  59003. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59004. * @returns the current SceneOptimizerOptions
  59005. */
  59006. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59007. /**
  59008. * Add a new custom optimization
  59009. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59010. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59011. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59012. * @returns the current SceneOptimizerOptions
  59013. */
  59014. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59015. /**
  59016. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59017. * @param targetFrameRate defines the target frame rate (60 by default)
  59018. * @returns a SceneOptimizerOptions object
  59019. */
  59020. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59021. /**
  59022. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59023. * @param targetFrameRate defines the target frame rate (60 by default)
  59024. * @returns a SceneOptimizerOptions object
  59025. */
  59026. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59027. /**
  59028. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59029. * @param targetFrameRate defines the target frame rate (60 by default)
  59030. * @returns a SceneOptimizerOptions object
  59031. */
  59032. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59033. }
  59034. /**
  59035. * Class used to run optimizations in order to reach a target frame rate
  59036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59037. */
  59038. export class SceneOptimizer implements IDisposable {
  59039. private _isRunning;
  59040. private _options;
  59041. private _scene;
  59042. private _currentPriorityLevel;
  59043. private _targetFrameRate;
  59044. private _trackerDuration;
  59045. private _currentFrameRate;
  59046. private _sceneDisposeObserver;
  59047. private _improvementMode;
  59048. /**
  59049. * Defines an observable called when the optimizer reaches the target frame rate
  59050. */
  59051. onSuccessObservable: Observable<SceneOptimizer>;
  59052. /**
  59053. * Defines an observable called when the optimizer enables an optimization
  59054. */
  59055. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59056. /**
  59057. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59058. */
  59059. onFailureObservable: Observable<SceneOptimizer>;
  59060. /**
  59061. * Gets a boolean indicating if the optimizer is in improvement mode
  59062. */
  59063. readonly isInImprovementMode: boolean;
  59064. /**
  59065. * Gets the current priority level (0 at start)
  59066. */
  59067. readonly currentPriorityLevel: number;
  59068. /**
  59069. * Gets the current frame rate checked by the SceneOptimizer
  59070. */
  59071. readonly currentFrameRate: number;
  59072. /**
  59073. * Gets or sets the current target frame rate (60 by default)
  59074. */
  59075. /**
  59076. * Gets or sets the current target frame rate (60 by default)
  59077. */
  59078. targetFrameRate: number;
  59079. /**
  59080. * Gets or sets the current interval between two checks (every 2000ms by default)
  59081. */
  59082. /**
  59083. * Gets or sets the current interval between two checks (every 2000ms by default)
  59084. */
  59085. trackerDuration: number;
  59086. /**
  59087. * Gets the list of active optimizations
  59088. */
  59089. readonly optimizations: SceneOptimization[];
  59090. /**
  59091. * Creates a new SceneOptimizer
  59092. * @param scene defines the scene to work on
  59093. * @param options defines the options to use with the SceneOptimizer
  59094. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59095. * @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)
  59096. */
  59097. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59098. /**
  59099. * Stops the current optimizer
  59100. */
  59101. stop(): void;
  59102. /**
  59103. * Reset the optimizer to initial step (current priority level = 0)
  59104. */
  59105. reset(): void;
  59106. /**
  59107. * Start the optimizer. By default it will try to reach a specific framerate
  59108. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59109. */
  59110. start(): void;
  59111. private _checkCurrentState;
  59112. /**
  59113. * Release all resources
  59114. */
  59115. dispose(): void;
  59116. /**
  59117. * Helper function to create a SceneOptimizer with one single line of code
  59118. * @param scene defines the scene to work on
  59119. * @param options defines the options to use with the SceneOptimizer
  59120. * @param onSuccess defines a callback to call on success
  59121. * @param onFailure defines a callback to call on failure
  59122. * @returns the new SceneOptimizer object
  59123. */
  59124. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59125. }
  59126. }
  59127. declare module "babylonjs/Misc/sceneSerializer" {
  59128. import { Scene } from "babylonjs/scene";
  59129. /**
  59130. * Class used to serialize a scene into a string
  59131. */
  59132. export class SceneSerializer {
  59133. /**
  59134. * Clear cache used by a previous serialization
  59135. */
  59136. static ClearCache(): void;
  59137. /**
  59138. * Serialize a scene into a JSON compatible object
  59139. * @param scene defines the scene to serialize
  59140. * @returns a JSON compatible object
  59141. */
  59142. static Serialize(scene: Scene): any;
  59143. /**
  59144. * Serialize a mesh into a JSON compatible object
  59145. * @param toSerialize defines the mesh to serialize
  59146. * @param withParents defines if parents must be serialized as well
  59147. * @param withChildren defines if children must be serialized as well
  59148. * @returns a JSON compatible object
  59149. */
  59150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59151. }
  59152. }
  59153. declare module "babylonjs/Misc/textureTools" {
  59154. import { Texture } from "babylonjs/Materials/Textures/texture";
  59155. /**
  59156. * Class used to host texture specific utilities
  59157. */
  59158. export class TextureTools {
  59159. /**
  59160. * Uses the GPU to create a copy texture rescaled at a given size
  59161. * @param texture Texture to copy from
  59162. * @param width defines the desired width
  59163. * @param height defines the desired height
  59164. * @param useBilinearMode defines if bilinear mode has to be used
  59165. * @return the generated texture
  59166. */
  59167. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59168. }
  59169. }
  59170. declare module "babylonjs/Misc/videoRecorder" {
  59171. import { Nullable } from "babylonjs/types";
  59172. import { Engine } from "babylonjs/Engines/engine";
  59173. /**
  59174. * This represents the different options avilable for the video capture.
  59175. */
  59176. export interface VideoRecorderOptions {
  59177. /** Defines the mime type of the video */
  59178. mimeType: string;
  59179. /** Defines the video the video should be recorded at */
  59180. fps: number;
  59181. /** Defines the chunk size for the recording data */
  59182. recordChunckSize: number;
  59183. /** The audio tracks to attach to the record */
  59184. audioTracks?: MediaStreamTrack[];
  59185. }
  59186. /**
  59187. * This can helps recording videos from BabylonJS.
  59188. * This is based on the available WebRTC functionalities of the browser.
  59189. *
  59190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59191. */
  59192. export class VideoRecorder {
  59193. private static readonly _defaultOptions;
  59194. /**
  59195. * Returns wehther or not the VideoRecorder is available in your browser.
  59196. * @param engine Defines the Babylon Engine to check the support for
  59197. * @returns true if supported otherwise false
  59198. */
  59199. static IsSupported(engine: Engine): boolean;
  59200. private readonly _options;
  59201. private _canvas;
  59202. private _mediaRecorder;
  59203. private _recordedChunks;
  59204. private _fileName;
  59205. private _resolve;
  59206. private _reject;
  59207. /**
  59208. * True wether a recording is already in progress.
  59209. */
  59210. readonly isRecording: boolean;
  59211. /**
  59212. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59213. * a video file.
  59214. * @param engine Defines the BabylonJS Engine you wish to record
  59215. * @param options Defines options that can be used to customized the capture
  59216. */
  59217. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59218. /**
  59219. * Stops the current recording before the default capture timeout passed in the startRecording
  59220. * functions.
  59221. */
  59222. stopRecording(): void;
  59223. /**
  59224. * Starts recording the canvas for a max duration specified in parameters.
  59225. * @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.
  59226. * @param maxDuration Defines the maximum recording time in seconds.
  59227. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59228. * @return a promise callback at the end of the recording with the video data in Blob.
  59229. */
  59230. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59231. /**
  59232. * Releases internal resources used during the recording.
  59233. */
  59234. dispose(): void;
  59235. private _handleDataAvailable;
  59236. private _handleError;
  59237. private _handleStop;
  59238. }
  59239. }
  59240. declare module "babylonjs/Misc/screenshotTools" {
  59241. import { Camera } from "babylonjs/Cameras/camera";
  59242. import { Engine } from "babylonjs/Engines/engine";
  59243. /**
  59244. * Class containing a set of static utilities functions for screenshots
  59245. */
  59246. export class ScreenshotTools {
  59247. /**
  59248. * Captures a screenshot of the current rendering
  59249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59250. * @param engine defines the rendering engine
  59251. * @param camera defines the source camera
  59252. * @param size This parameter can be set to a single number or to an object with the
  59253. * following (optional) properties: precision, width, height. If a single number is passed,
  59254. * it will be used for both width and height. If an object is passed, the screenshot size
  59255. * will be derived from the parameters. The precision property is a multiplier allowing
  59256. * rendering at a higher or lower resolution
  59257. * @param successCallback defines the callback receives a single parameter which contains the
  59258. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59259. * src parameter of an <img> to display it
  59260. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59261. * Check your browser for supported MIME types
  59262. */
  59263. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59264. /**
  59265. * Generates an image screenshot from the specified camera.
  59266. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59267. * @param engine The engine to use for rendering
  59268. * @param camera The camera to use for rendering
  59269. * @param size This parameter can be set to a single number or to an object with the
  59270. * following (optional) properties: precision, width, height. If a single number is passed,
  59271. * it will be used for both width and height. If an object is passed, the screenshot size
  59272. * will be derived from the parameters. The precision property is a multiplier allowing
  59273. * rendering at a higher or lower resolution
  59274. * @param successCallback The callback receives a single parameter which contains the
  59275. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59276. * src parameter of an <img> to display it
  59277. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59278. * Check your browser for supported MIME types
  59279. * @param samples Texture samples (default: 1)
  59280. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59281. * @param fileName A name for for the downloaded file.
  59282. */
  59283. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59284. }
  59285. }
  59286. declare module "babylonjs/Misc/index" {
  59287. export * from "babylonjs/Misc/andOrNotEvaluator";
  59288. export * from "babylonjs/Misc/assetsManager";
  59289. export * from "babylonjs/Misc/dds";
  59290. export * from "babylonjs/Misc/decorators";
  59291. export * from "babylonjs/Misc/deferred";
  59292. export * from "babylonjs/Misc/environmentTextureTools";
  59293. export * from "babylonjs/Misc/meshExploder";
  59294. export * from "babylonjs/Misc/filesInput";
  59295. export * from "babylonjs/Misc/HighDynamicRange/index";
  59296. export * from "babylonjs/Misc/khronosTextureContainer";
  59297. export * from "babylonjs/Misc/observable";
  59298. export * from "babylonjs/Misc/performanceMonitor";
  59299. export * from "babylonjs/Misc/promise";
  59300. export * from "babylonjs/Misc/sceneOptimizer";
  59301. export * from "babylonjs/Misc/sceneSerializer";
  59302. export * from "babylonjs/Misc/smartArray";
  59303. export * from "babylonjs/Misc/stringDictionary";
  59304. export * from "babylonjs/Misc/tags";
  59305. export * from "babylonjs/Misc/textureTools";
  59306. export * from "babylonjs/Misc/tga";
  59307. export * from "babylonjs/Misc/tools";
  59308. export * from "babylonjs/Misc/videoRecorder";
  59309. export * from "babylonjs/Misc/virtualJoystick";
  59310. export * from "babylonjs/Misc/workerPool";
  59311. export * from "babylonjs/Misc/logger";
  59312. export * from "babylonjs/Misc/typeStore";
  59313. export * from "babylonjs/Misc/filesInputStore";
  59314. export * from "babylonjs/Misc/deepCopier";
  59315. export * from "babylonjs/Misc/pivotTools";
  59316. export * from "babylonjs/Misc/precisionDate";
  59317. export * from "babylonjs/Misc/screenshotTools";
  59318. export * from "babylonjs/Misc/typeStore";
  59319. export * from "babylonjs/Misc/webRequest";
  59320. export * from "babylonjs/Misc/iInspectable";
  59321. }
  59322. declare module "babylonjs/index" {
  59323. export * from "babylonjs/abstractScene";
  59324. export * from "babylonjs/Actions/index";
  59325. export * from "babylonjs/Animations/index";
  59326. export * from "babylonjs/assetContainer";
  59327. export * from "babylonjs/Audio/index";
  59328. export * from "babylonjs/Behaviors/index";
  59329. export * from "babylonjs/Bones/index";
  59330. export * from "babylonjs/Cameras/index";
  59331. export * from "babylonjs/Collisions/index";
  59332. export * from "babylonjs/Culling/index";
  59333. export * from "babylonjs/Debug/index";
  59334. export * from "babylonjs/Engines/index";
  59335. export * from "babylonjs/Events/index";
  59336. export * from "babylonjs/Gamepads/index";
  59337. export * from "babylonjs/Gizmos/index";
  59338. export * from "babylonjs/Helpers/index";
  59339. export * from "babylonjs/Instrumentation/index";
  59340. export * from "babylonjs/Layers/index";
  59341. export * from "babylonjs/LensFlares/index";
  59342. export * from "babylonjs/Lights/index";
  59343. export * from "babylonjs/Loading/index";
  59344. export * from "babylonjs/Materials/index";
  59345. export * from "babylonjs/Maths/index";
  59346. export * from "babylonjs/Meshes/index";
  59347. export * from "babylonjs/Morph/index";
  59348. export * from "babylonjs/node";
  59349. export * from "babylonjs/Offline/index";
  59350. export * from "babylonjs/Particles/index";
  59351. export * from "babylonjs/Physics/index";
  59352. export * from "babylonjs/PostProcesses/index";
  59353. export * from "babylonjs/Probes/index";
  59354. export * from "babylonjs/Rendering/index";
  59355. export * from "babylonjs/scene";
  59356. export * from "babylonjs/sceneComponent";
  59357. export * from "babylonjs/Sprites/index";
  59358. export * from "babylonjs/States/index";
  59359. export * from "babylonjs/Misc/index";
  59360. export * from "babylonjs/types";
  59361. }
  59362. declare module "babylonjs/Animations/pathCursor" {
  59363. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59364. /**
  59365. * A cursor which tracks a point on a path
  59366. */
  59367. export class PathCursor {
  59368. private path;
  59369. /**
  59370. * Stores path cursor callbacks for when an onchange event is triggered
  59371. */
  59372. private _onchange;
  59373. /**
  59374. * The value of the path cursor
  59375. */
  59376. value: number;
  59377. /**
  59378. * The animation array of the path cursor
  59379. */
  59380. animations: Animation[];
  59381. /**
  59382. * Initializes the path cursor
  59383. * @param path The path to track
  59384. */
  59385. constructor(path: Path2);
  59386. /**
  59387. * Gets the cursor point on the path
  59388. * @returns A point on the path cursor at the cursor location
  59389. */
  59390. getPoint(): Vector3;
  59391. /**
  59392. * Moves the cursor ahead by the step amount
  59393. * @param step The amount to move the cursor forward
  59394. * @returns This path cursor
  59395. */
  59396. moveAhead(step?: number): PathCursor;
  59397. /**
  59398. * Moves the cursor behind by the step amount
  59399. * @param step The amount to move the cursor back
  59400. * @returns This path cursor
  59401. */
  59402. moveBack(step?: number): PathCursor;
  59403. /**
  59404. * Moves the cursor by the step amount
  59405. * If the step amount is greater than one, an exception is thrown
  59406. * @param step The amount to move the cursor
  59407. * @returns This path cursor
  59408. */
  59409. move(step: number): PathCursor;
  59410. /**
  59411. * Ensures that the value is limited between zero and one
  59412. * @returns This path cursor
  59413. */
  59414. private ensureLimits;
  59415. /**
  59416. * Runs onchange callbacks on change (used by the animation engine)
  59417. * @returns This path cursor
  59418. */
  59419. private raiseOnChange;
  59420. /**
  59421. * Executes a function on change
  59422. * @param f A path cursor onchange callback
  59423. * @returns This path cursor
  59424. */
  59425. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59426. }
  59427. }
  59428. declare module "babylonjs/Legacy/legacy" {
  59429. import * as Babylon from "babylonjs/index";
  59430. export * from "babylonjs/index";
  59431. }
  59432. declare module "babylonjs/Shaders/blur.fragment" {
  59433. /** @hidden */
  59434. export var blurPixelShader: {
  59435. name: string;
  59436. shader: string;
  59437. };
  59438. }
  59439. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59440. /** @hidden */
  59441. export var bones300Declaration: {
  59442. name: string;
  59443. shader: string;
  59444. };
  59445. }
  59446. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59447. /** @hidden */
  59448. export var instances300Declaration: {
  59449. name: string;
  59450. shader: string;
  59451. };
  59452. }
  59453. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59454. /** @hidden */
  59455. export var pointCloudVertexDeclaration: {
  59456. name: string;
  59457. shader: string;
  59458. };
  59459. }
  59460. // Mixins
  59461. interface Window {
  59462. mozIndexedDB: IDBFactory;
  59463. webkitIndexedDB: IDBFactory;
  59464. msIndexedDB: IDBFactory;
  59465. webkitURL: typeof URL;
  59466. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59467. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59468. WebGLRenderingContext: WebGLRenderingContext;
  59469. MSGesture: MSGesture;
  59470. CANNON: any;
  59471. AudioContext: AudioContext;
  59472. webkitAudioContext: AudioContext;
  59473. PointerEvent: any;
  59474. Math: Math;
  59475. Uint8Array: Uint8ArrayConstructor;
  59476. Float32Array: Float32ArrayConstructor;
  59477. mozURL: typeof URL;
  59478. msURL: typeof URL;
  59479. VRFrameData: any; // WebVR, from specs 1.1
  59480. DracoDecoderModule: any;
  59481. setImmediate(handler: (...args: any[]) => void): number;
  59482. }
  59483. interface HTMLCanvasElement {
  59484. requestPointerLock(): void;
  59485. msRequestPointerLock?(): void;
  59486. mozRequestPointerLock?(): void;
  59487. webkitRequestPointerLock?(): void;
  59488. /** Track wether a record is in progress */
  59489. isRecording: boolean;
  59490. /** Capture Stream method defined by some browsers */
  59491. captureStream(fps?: number): MediaStream;
  59492. }
  59493. interface CanvasRenderingContext2D {
  59494. msImageSmoothingEnabled: boolean;
  59495. }
  59496. interface MouseEvent {
  59497. mozMovementX: number;
  59498. mozMovementY: number;
  59499. webkitMovementX: number;
  59500. webkitMovementY: number;
  59501. msMovementX: number;
  59502. msMovementY: number;
  59503. }
  59504. interface Navigator {
  59505. mozGetVRDevices: (any: any) => any;
  59506. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59507. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59508. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59509. webkitGetGamepads(): Gamepad[];
  59510. msGetGamepads(): Gamepad[];
  59511. webkitGamepads(): Gamepad[];
  59512. }
  59513. interface HTMLVideoElement {
  59514. mozSrcObject: any;
  59515. }
  59516. interface Math {
  59517. fround(x: number): number;
  59518. imul(a: number, b: number): number;
  59519. }
  59520. interface WebGLRenderingContext {
  59521. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59522. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59523. vertexAttribDivisor(index: number, divisor: number): void;
  59524. createVertexArray(): any;
  59525. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59526. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59527. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59528. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59529. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59530. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59531. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59532. // Queries
  59533. createQuery(): WebGLQuery;
  59534. deleteQuery(query: WebGLQuery): void;
  59535. beginQuery(target: number, query: WebGLQuery): void;
  59536. endQuery(target: number): void;
  59537. getQueryParameter(query: WebGLQuery, pname: number): any;
  59538. getQuery(target: number, pname: number): any;
  59539. MAX_SAMPLES: number;
  59540. RGBA8: number;
  59541. READ_FRAMEBUFFER: number;
  59542. DRAW_FRAMEBUFFER: number;
  59543. UNIFORM_BUFFER: number;
  59544. HALF_FLOAT_OES: number;
  59545. RGBA16F: number;
  59546. RGBA32F: number;
  59547. R32F: number;
  59548. RG32F: number;
  59549. RGB32F: number;
  59550. R16F: number;
  59551. RG16F: number;
  59552. RGB16F: number;
  59553. RED: number;
  59554. RG: number;
  59555. R8: number;
  59556. RG8: number;
  59557. UNSIGNED_INT_24_8: number;
  59558. DEPTH24_STENCIL8: number;
  59559. /* Multiple Render Targets */
  59560. drawBuffers(buffers: number[]): void;
  59561. readBuffer(src: number): void;
  59562. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59563. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59564. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59565. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59566. // Occlusion Query
  59567. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59568. ANY_SAMPLES_PASSED: number;
  59569. QUERY_RESULT_AVAILABLE: number;
  59570. QUERY_RESULT: number;
  59571. }
  59572. interface WebGLProgram {
  59573. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59574. }
  59575. interface EXT_disjoint_timer_query {
  59576. QUERY_COUNTER_BITS_EXT: number;
  59577. TIME_ELAPSED_EXT: number;
  59578. TIMESTAMP_EXT: number;
  59579. GPU_DISJOINT_EXT: number;
  59580. QUERY_RESULT_EXT: number;
  59581. QUERY_RESULT_AVAILABLE_EXT: number;
  59582. queryCounterEXT(query: WebGLQuery, target: number): void;
  59583. createQueryEXT(): WebGLQuery;
  59584. beginQueryEXT(target: number, query: WebGLQuery): void;
  59585. endQueryEXT(target: number): void;
  59586. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59587. deleteQueryEXT(query: WebGLQuery): void;
  59588. }
  59589. interface WebGLUniformLocation {
  59590. _currentState: any;
  59591. }
  59592. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59593. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59594. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59595. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59596. interface WebGLRenderingContext {
  59597. readonly RASTERIZER_DISCARD: number;
  59598. readonly DEPTH_COMPONENT24: number;
  59599. readonly TEXTURE_3D: number;
  59600. readonly TEXTURE_2D_ARRAY: number;
  59601. readonly TEXTURE_COMPARE_FUNC: number;
  59602. readonly TEXTURE_COMPARE_MODE: number;
  59603. readonly COMPARE_REF_TO_TEXTURE: number;
  59604. readonly TEXTURE_WRAP_R: number;
  59605. readonly HALF_FLOAT: number;
  59606. readonly RGB8: number;
  59607. readonly RED_INTEGER: number;
  59608. readonly RG_INTEGER: number;
  59609. readonly RGB_INTEGER: number;
  59610. readonly RGBA_INTEGER: number;
  59611. readonly R8_SNORM: number;
  59612. readonly RG8_SNORM: number;
  59613. readonly RGB8_SNORM: number;
  59614. readonly RGBA8_SNORM: number;
  59615. readonly R8I: number;
  59616. readonly RG8I: number;
  59617. readonly RGB8I: number;
  59618. readonly RGBA8I: number;
  59619. readonly R8UI: number;
  59620. readonly RG8UI: number;
  59621. readonly RGB8UI: number;
  59622. readonly RGBA8UI: number;
  59623. readonly R16I: number;
  59624. readonly RG16I: number;
  59625. readonly RGB16I: number;
  59626. readonly RGBA16I: number;
  59627. readonly R16UI: number;
  59628. readonly RG16UI: number;
  59629. readonly RGB16UI: number;
  59630. readonly RGBA16UI: number;
  59631. readonly R32I: number;
  59632. readonly RG32I: number;
  59633. readonly RGB32I: number;
  59634. readonly RGBA32I: number;
  59635. readonly R32UI: number;
  59636. readonly RG32UI: number;
  59637. readonly RGB32UI: number;
  59638. readonly RGBA32UI: number;
  59639. readonly RGB10_A2UI: number;
  59640. readonly R11F_G11F_B10F: number;
  59641. readonly RGB9_E5: number;
  59642. readonly RGB10_A2: number;
  59643. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59644. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59645. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59646. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59647. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59648. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59649. 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;
  59650. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59651. readonly TRANSFORM_FEEDBACK: number;
  59652. readonly INTERLEAVED_ATTRIBS: number;
  59653. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59654. createTransformFeedback(): WebGLTransformFeedback;
  59655. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59656. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59657. beginTransformFeedback(primitiveMode: number): void;
  59658. endTransformFeedback(): void;
  59659. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59660. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59661. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59662. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59663. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59664. }
  59665. interface ImageBitmap {
  59666. readonly width: number;
  59667. readonly height: number;
  59668. close(): void;
  59669. }
  59670. interface WebGLQuery extends WebGLObject {
  59671. }
  59672. declare var WebGLQuery: {
  59673. prototype: WebGLQuery;
  59674. new(): WebGLQuery;
  59675. };
  59676. interface WebGLSampler extends WebGLObject {
  59677. }
  59678. declare var WebGLSampler: {
  59679. prototype: WebGLSampler;
  59680. new(): WebGLSampler;
  59681. };
  59682. interface WebGLSync extends WebGLObject {
  59683. }
  59684. declare var WebGLSync: {
  59685. prototype: WebGLSync;
  59686. new(): WebGLSync;
  59687. };
  59688. interface WebGLTransformFeedback extends WebGLObject {
  59689. }
  59690. declare var WebGLTransformFeedback: {
  59691. prototype: WebGLTransformFeedback;
  59692. new(): WebGLTransformFeedback;
  59693. };
  59694. interface WebGLVertexArrayObject extends WebGLObject {
  59695. }
  59696. declare var WebGLVertexArrayObject: {
  59697. prototype: WebGLVertexArrayObject;
  59698. new(): WebGLVertexArrayObject;
  59699. };
  59700. // Type definitions for WebVR API
  59701. // Project: https://w3c.github.io/webvr/
  59702. // Definitions by: six a <https://github.com/lostfictions>
  59703. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59704. interface VRDisplay extends EventTarget {
  59705. /**
  59706. * Dictionary of capabilities describing the VRDisplay.
  59707. */
  59708. readonly capabilities: VRDisplayCapabilities;
  59709. /**
  59710. * z-depth defining the far plane of the eye view frustum
  59711. * enables mapping of values in the render target depth
  59712. * attachment to scene coordinates. Initially set to 10000.0.
  59713. */
  59714. depthFar: number;
  59715. /**
  59716. * z-depth defining the near plane of the eye view frustum
  59717. * enables mapping of values in the render target depth
  59718. * attachment to scene coordinates. Initially set to 0.01.
  59719. */
  59720. depthNear: number;
  59721. /**
  59722. * An identifier for this distinct VRDisplay. Used as an
  59723. * association point in the Gamepad API.
  59724. */
  59725. readonly displayId: number;
  59726. /**
  59727. * A display name, a user-readable name identifying it.
  59728. */
  59729. readonly displayName: string;
  59730. readonly isConnected: boolean;
  59731. readonly isPresenting: boolean;
  59732. /**
  59733. * If this VRDisplay supports room-scale experiences, the optional
  59734. * stage attribute contains details on the room-scale parameters.
  59735. */
  59736. readonly stageParameters: VRStageParameters | null;
  59737. /**
  59738. * Passing the value returned by `requestAnimationFrame` to
  59739. * `cancelAnimationFrame` will unregister the callback.
  59740. * @param handle Define the hanle of the request to cancel
  59741. */
  59742. cancelAnimationFrame(handle: number): void;
  59743. /**
  59744. * Stops presenting to the VRDisplay.
  59745. * @returns a promise to know when it stopped
  59746. */
  59747. exitPresent(): Promise<void>;
  59748. /**
  59749. * Return the current VREyeParameters for the given eye.
  59750. * @param whichEye Define the eye we want the parameter for
  59751. * @returns the eye parameters
  59752. */
  59753. getEyeParameters(whichEye: string): VREyeParameters;
  59754. /**
  59755. * Populates the passed VRFrameData with the information required to render
  59756. * the current frame.
  59757. * @param frameData Define the data structure to populate
  59758. * @returns true if ok otherwise false
  59759. */
  59760. getFrameData(frameData: VRFrameData): boolean;
  59761. /**
  59762. * Get the layers currently being presented.
  59763. * @returns the list of VR layers
  59764. */
  59765. getLayers(): VRLayer[];
  59766. /**
  59767. * Return a VRPose containing the future predicted pose of the VRDisplay
  59768. * when the current frame will be presented. The value returned will not
  59769. * change until JavaScript has returned control to the browser.
  59770. *
  59771. * The VRPose will contain the position, orientation, velocity,
  59772. * and acceleration of each of these properties.
  59773. * @returns the pose object
  59774. */
  59775. getPose(): VRPose;
  59776. /**
  59777. * Return the current instantaneous pose of the VRDisplay, with no
  59778. * prediction applied.
  59779. * @returns the current instantaneous pose
  59780. */
  59781. getImmediatePose(): VRPose;
  59782. /**
  59783. * The callback passed to `requestAnimationFrame` will be called
  59784. * any time a new frame should be rendered. When the VRDisplay is
  59785. * presenting the callback will be called at the native refresh
  59786. * rate of the HMD. When not presenting this function acts
  59787. * identically to how window.requestAnimationFrame acts. Content should
  59788. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59789. * asynchronously from other displays and at differing refresh rates.
  59790. * @param callback Define the eaction to run next frame
  59791. * @returns the request handle it
  59792. */
  59793. requestAnimationFrame(callback: FrameRequestCallback): number;
  59794. /**
  59795. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59796. * Repeat calls while already presenting will update the VRLayers being displayed.
  59797. * @param layers Define the list of layer to present
  59798. * @returns a promise to know when the request has been fulfilled
  59799. */
  59800. requestPresent(layers: VRLayer[]): Promise<void>;
  59801. /**
  59802. * Reset the pose for this display, treating its current position and
  59803. * orientation as the "origin/zero" values. VRPose.position,
  59804. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59805. * updated when calling resetPose(). This should be called in only
  59806. * sitting-space experiences.
  59807. */
  59808. resetPose(): void;
  59809. /**
  59810. * The VRLayer provided to the VRDisplay will be captured and presented
  59811. * in the HMD. Calling this function has the same effect on the source
  59812. * canvas as any other operation that uses its source image, and canvases
  59813. * created without preserveDrawingBuffer set to true will be cleared.
  59814. * @param pose Define the pose to submit
  59815. */
  59816. submitFrame(pose?: VRPose): void;
  59817. }
  59818. declare var VRDisplay: {
  59819. prototype: VRDisplay;
  59820. new(): VRDisplay;
  59821. };
  59822. interface VRLayer {
  59823. leftBounds?: number[] | Float32Array | null;
  59824. rightBounds?: number[] | Float32Array | null;
  59825. source?: HTMLCanvasElement | null;
  59826. }
  59827. interface VRDisplayCapabilities {
  59828. readonly canPresent: boolean;
  59829. readonly hasExternalDisplay: boolean;
  59830. readonly hasOrientation: boolean;
  59831. readonly hasPosition: boolean;
  59832. readonly maxLayers: number;
  59833. }
  59834. interface VREyeParameters {
  59835. /** @deprecated */
  59836. readonly fieldOfView: VRFieldOfView;
  59837. readonly offset: Float32Array;
  59838. readonly renderHeight: number;
  59839. readonly renderWidth: number;
  59840. }
  59841. interface VRFieldOfView {
  59842. readonly downDegrees: number;
  59843. readonly leftDegrees: number;
  59844. readonly rightDegrees: number;
  59845. readonly upDegrees: number;
  59846. }
  59847. interface VRFrameData {
  59848. readonly leftProjectionMatrix: Float32Array;
  59849. readonly leftViewMatrix: Float32Array;
  59850. readonly pose: VRPose;
  59851. readonly rightProjectionMatrix: Float32Array;
  59852. readonly rightViewMatrix: Float32Array;
  59853. readonly timestamp: number;
  59854. }
  59855. interface VRPose {
  59856. readonly angularAcceleration: Float32Array | null;
  59857. readonly angularVelocity: Float32Array | null;
  59858. readonly linearAcceleration: Float32Array | null;
  59859. readonly linearVelocity: Float32Array | null;
  59860. readonly orientation: Float32Array | null;
  59861. readonly position: Float32Array | null;
  59862. readonly timestamp: number;
  59863. }
  59864. interface VRStageParameters {
  59865. sittingToStandingTransform?: Float32Array;
  59866. sizeX?: number;
  59867. sizeY?: number;
  59868. }
  59869. interface Navigator {
  59870. getVRDisplays(): Promise<VRDisplay[]>;
  59871. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59872. }
  59873. interface Window {
  59874. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59875. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59876. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59877. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59878. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59879. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59880. }
  59881. interface Gamepad {
  59882. readonly displayId: number;
  59883. }
  59884. interface XRDevice {
  59885. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59886. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59887. }
  59888. interface XRSession {
  59889. getInputSources(): Array<any>;
  59890. baseLayer: XRWebGLLayer;
  59891. requestFrameOfReference(type: string): Promise<void>;
  59892. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59893. end(): Promise<void>;
  59894. requestAnimationFrame: Function;
  59895. addEventListener: Function;
  59896. }
  59897. interface XRSessionCreationOptions {
  59898. outputContext?: WebGLRenderingContext | null;
  59899. immersive?: boolean;
  59900. environmentIntegration?: boolean;
  59901. }
  59902. interface XRLayer {
  59903. getViewport: Function;
  59904. framebufferWidth: number;
  59905. framebufferHeight: number;
  59906. }
  59907. interface XRView {
  59908. projectionMatrix: Float32Array;
  59909. }
  59910. interface XRFrame {
  59911. getDevicePose: Function;
  59912. getInputPose: Function;
  59913. views: Array<XRView>;
  59914. baseLayer: XRLayer;
  59915. }
  59916. interface XRFrameOfReference {
  59917. }
  59918. interface XRWebGLLayer extends XRLayer {
  59919. framebuffer: WebGLFramebuffer;
  59920. }
  59921. declare var XRWebGLLayer: {
  59922. prototype: XRWebGLLayer;
  59923. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59924. };
  59925. declare module "babylonjs" {
  59926. export * from "babylonjs/Legacy/legacy";
  59927. }
  59928. declare module BABYLON {
  59929. /** Alias type for value that can be null */
  59930. export type Nullable<T> = T | null;
  59931. /**
  59932. * Alias type for number that are floats
  59933. * @ignorenaming
  59934. */
  59935. export type float = number;
  59936. /**
  59937. * Alias type for number that are doubles.
  59938. * @ignorenaming
  59939. */
  59940. export type double = number;
  59941. /**
  59942. * Alias type for number that are integer
  59943. * @ignorenaming
  59944. */
  59945. export type int = number;
  59946. /** Alias type for number array or Float32Array */
  59947. export type FloatArray = number[] | Float32Array;
  59948. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59949. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59950. /**
  59951. * Alias for types that can be used by a Buffer or VertexBuffer.
  59952. */
  59953. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59954. /**
  59955. * Alias type for primitive types
  59956. * @ignorenaming
  59957. */
  59958. type Primitive = undefined | null | boolean | string | number | Function;
  59959. /**
  59960. * Type modifier to make all the properties of an object Readonly
  59961. */
  59962. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59963. /**
  59964. * Type modifier to make all the properties of an object Readonly recursively
  59965. */
  59966. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59967. /** @hidden */
  59968. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59969. }
  59970. /** @hidden */
  59971. /** @hidden */
  59972. type DeepImmutableObject<T> = {
  59973. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59974. };
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * Class containing a set of static utilities functions for arrays.
  59979. */
  59980. export class ArrayTools {
  59981. /**
  59982. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59983. * @param size the number of element to construct and put in the array
  59984. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59985. * @returns a new array filled with new objects
  59986. */
  59987. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59988. }
  59989. }
  59990. declare module BABYLON {
  59991. /**
  59992. * Scalar computation library
  59993. */
  59994. export class Scalar {
  59995. /**
  59996. * Two pi constants convenient for computation.
  59997. */
  59998. static TwoPi: number;
  59999. /**
  60000. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60001. * @param a number
  60002. * @param b number
  60003. * @param epsilon (default = 1.401298E-45)
  60004. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60005. */
  60006. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60007. /**
  60008. * Returns a string : the upper case translation of the number i to hexadecimal.
  60009. * @param i number
  60010. * @returns the upper case translation of the number i to hexadecimal.
  60011. */
  60012. static ToHex(i: number): string;
  60013. /**
  60014. * Returns -1 if value is negative and +1 is value is positive.
  60015. * @param value the value
  60016. * @returns the value itself if it's equal to zero.
  60017. */
  60018. static Sign(value: number): number;
  60019. /**
  60020. * Returns the value itself if it's between min and max.
  60021. * Returns min if the value is lower than min.
  60022. * Returns max if the value is greater than max.
  60023. * @param value the value to clmap
  60024. * @param min the min value to clamp to (default: 0)
  60025. * @param max the max value to clamp to (default: 1)
  60026. * @returns the clamped value
  60027. */
  60028. static Clamp(value: number, min?: number, max?: number): number;
  60029. /**
  60030. * the log2 of value.
  60031. * @param value the value to compute log2 of
  60032. * @returns the log2 of value.
  60033. */
  60034. static Log2(value: number): number;
  60035. /**
  60036. * Loops the value, so that it is never larger than length and never smaller than 0.
  60037. *
  60038. * This is similar to the modulo operator but it works with floating point numbers.
  60039. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60040. * With t = 5 and length = 2.5, the result would be 0.0.
  60041. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60042. * @param value the value
  60043. * @param length the length
  60044. * @returns the looped value
  60045. */
  60046. static Repeat(value: number, length: number): number;
  60047. /**
  60048. * Normalize the value between 0.0 and 1.0 using min and max values
  60049. * @param value value to normalize
  60050. * @param min max to normalize between
  60051. * @param max min to normalize between
  60052. * @returns the normalized value
  60053. */
  60054. static Normalize(value: number, min: number, max: number): number;
  60055. /**
  60056. * Denormalize the value from 0.0 and 1.0 using min and max values
  60057. * @param normalized value to denormalize
  60058. * @param min max to denormalize between
  60059. * @param max min to denormalize between
  60060. * @returns the denormalized value
  60061. */
  60062. static Denormalize(normalized: number, min: number, max: number): number;
  60063. /**
  60064. * Calculates the shortest difference between two given angles given in degrees.
  60065. * @param current current angle in degrees
  60066. * @param target target angle in degrees
  60067. * @returns the delta
  60068. */
  60069. static DeltaAngle(current: number, target: number): number;
  60070. /**
  60071. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60072. * @param tx value
  60073. * @param length length
  60074. * @returns The returned value will move back and forth between 0 and length
  60075. */
  60076. static PingPong(tx: number, length: number): number;
  60077. /**
  60078. * Interpolates between min and max with smoothing at the limits.
  60079. *
  60080. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60081. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60082. * @param from from
  60083. * @param to to
  60084. * @param tx value
  60085. * @returns the smooth stepped value
  60086. */
  60087. static SmoothStep(from: number, to: number, tx: number): number;
  60088. /**
  60089. * Moves a value current towards target.
  60090. *
  60091. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60092. * Negative values of maxDelta pushes the value away from target.
  60093. * @param current current value
  60094. * @param target target value
  60095. * @param maxDelta max distance to move
  60096. * @returns resulting value
  60097. */
  60098. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60099. /**
  60100. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60101. *
  60102. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60103. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60104. * @param current current value
  60105. * @param target target value
  60106. * @param maxDelta max distance to move
  60107. * @returns resulting angle
  60108. */
  60109. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60110. /**
  60111. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60112. * @param start start value
  60113. * @param end target value
  60114. * @param amount amount to lerp between
  60115. * @returns the lerped value
  60116. */
  60117. static Lerp(start: number, end: number, amount: number): number;
  60118. /**
  60119. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60120. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60121. * @param start start value
  60122. * @param end target value
  60123. * @param amount amount to lerp between
  60124. * @returns the lerped value
  60125. */
  60126. static LerpAngle(start: number, end: number, amount: number): number;
  60127. /**
  60128. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60129. * @param a start value
  60130. * @param b target value
  60131. * @param value value between a and b
  60132. * @returns the inverseLerp value
  60133. */
  60134. static InverseLerp(a: number, b: number, value: number): number;
  60135. /**
  60136. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60137. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60138. * @param value1 spline value
  60139. * @param tangent1 spline value
  60140. * @param value2 spline value
  60141. * @param tangent2 spline value
  60142. * @param amount input value
  60143. * @returns hermite result
  60144. */
  60145. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60146. /**
  60147. * Returns a random float number between and min and max values
  60148. * @param min min value of random
  60149. * @param max max value of random
  60150. * @returns random value
  60151. */
  60152. static RandomRange(min: number, max: number): number;
  60153. /**
  60154. * This function returns percentage of a number in a given range.
  60155. *
  60156. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60157. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60158. * @param number to convert to percentage
  60159. * @param min min range
  60160. * @param max max range
  60161. * @returns the percentage
  60162. */
  60163. static RangeToPercent(number: number, min: number, max: number): number;
  60164. /**
  60165. * This function returns number that corresponds to the percentage in a given range.
  60166. *
  60167. * PercentToRange(0.34,0,100) will return 34.
  60168. * @param percent to convert to number
  60169. * @param min min range
  60170. * @param max max range
  60171. * @returns the number
  60172. */
  60173. static PercentToRange(percent: number, min: number, max: number): number;
  60174. /**
  60175. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60176. * @param angle The angle to normalize in radian.
  60177. * @return The converted angle.
  60178. */
  60179. static NormalizeRadians(angle: number): number;
  60180. }
  60181. }
  60182. declare module BABYLON {
  60183. /**
  60184. * Constant used to convert a value to gamma space
  60185. * @ignorenaming
  60186. */
  60187. export const ToGammaSpace: number;
  60188. /**
  60189. * Constant used to convert a value to linear space
  60190. * @ignorenaming
  60191. */
  60192. export const ToLinearSpace = 2.2;
  60193. /**
  60194. * Constant used to define the minimal number value in Babylon.js
  60195. * @ignorenaming
  60196. */
  60197. let Epsilon: number;
  60198. /**
  60199. * Class used to hold a RBG color
  60200. */
  60201. export class Color3 {
  60202. /**
  60203. * Defines the red component (between 0 and 1, default is 0)
  60204. */
  60205. r: number;
  60206. /**
  60207. * Defines the green component (between 0 and 1, default is 0)
  60208. */
  60209. g: number;
  60210. /**
  60211. * Defines the blue component (between 0 and 1, default is 0)
  60212. */
  60213. b: number;
  60214. /**
  60215. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60216. * @param r defines the red component (between 0 and 1, default is 0)
  60217. * @param g defines the green component (between 0 and 1, default is 0)
  60218. * @param b defines the blue component (between 0 and 1, default is 0)
  60219. */
  60220. constructor(
  60221. /**
  60222. * Defines the red component (between 0 and 1, default is 0)
  60223. */
  60224. r?: number,
  60225. /**
  60226. * Defines the green component (between 0 and 1, default is 0)
  60227. */
  60228. g?: number,
  60229. /**
  60230. * Defines the blue component (between 0 and 1, default is 0)
  60231. */
  60232. b?: number);
  60233. /**
  60234. * Creates a string with the Color3 current values
  60235. * @returns the string representation of the Color3 object
  60236. */
  60237. toString(): string;
  60238. /**
  60239. * Returns the string "Color3"
  60240. * @returns "Color3"
  60241. */
  60242. getClassName(): string;
  60243. /**
  60244. * Compute the Color3 hash code
  60245. * @returns an unique number that can be used to hash Color3 objects
  60246. */
  60247. getHashCode(): number;
  60248. /**
  60249. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60250. * @param array defines the array where to store the r,g,b components
  60251. * @param index defines an optional index in the target array to define where to start storing values
  60252. * @returns the current Color3 object
  60253. */
  60254. toArray(array: FloatArray, index?: number): Color3;
  60255. /**
  60256. * Returns a new Color4 object from the current Color3 and the given alpha
  60257. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60258. * @returns a new Color4 object
  60259. */
  60260. toColor4(alpha?: number): Color4;
  60261. /**
  60262. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60263. * @returns the new array
  60264. */
  60265. asArray(): number[];
  60266. /**
  60267. * Returns the luminance value
  60268. * @returns a float value
  60269. */
  60270. toLuminance(): number;
  60271. /**
  60272. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60273. * @param otherColor defines the second operand
  60274. * @returns the new Color3 object
  60275. */
  60276. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60277. /**
  60278. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60279. * @param otherColor defines the second operand
  60280. * @param result defines the Color3 object where to store the result
  60281. * @returns the current Color3
  60282. */
  60283. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60284. /**
  60285. * Determines equality between Color3 objects
  60286. * @param otherColor defines the second operand
  60287. * @returns true if the rgb values are equal to the given ones
  60288. */
  60289. equals(otherColor: DeepImmutable<Color3>): boolean;
  60290. /**
  60291. * Determines equality between the current Color3 object and a set of r,b,g values
  60292. * @param r defines the red component to check
  60293. * @param g defines the green component to check
  60294. * @param b defines the blue component to check
  60295. * @returns true if the rgb values are equal to the given ones
  60296. */
  60297. equalsFloats(r: number, g: number, b: number): boolean;
  60298. /**
  60299. * Multiplies in place each rgb value by scale
  60300. * @param scale defines the scaling factor
  60301. * @returns the updated Color3
  60302. */
  60303. scale(scale: number): Color3;
  60304. /**
  60305. * Multiplies the rgb values by scale and stores the result into "result"
  60306. * @param scale defines the scaling factor
  60307. * @param result defines the Color3 object where to store the result
  60308. * @returns the unmodified current Color3
  60309. */
  60310. scaleToRef(scale: number, result: Color3): Color3;
  60311. /**
  60312. * Scale the current Color3 values by a factor and add the result to a given Color3
  60313. * @param scale defines the scale factor
  60314. * @param result defines color to store the result into
  60315. * @returns the unmodified current Color3
  60316. */
  60317. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60318. /**
  60319. * Clamps the rgb values by the min and max values and stores the result into "result"
  60320. * @param min defines minimum clamping value (default is 0)
  60321. * @param max defines maximum clamping value (default is 1)
  60322. * @param result defines color to store the result into
  60323. * @returns the original Color3
  60324. */
  60325. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60326. /**
  60327. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60328. * @param otherColor defines the second operand
  60329. * @returns the new Color3
  60330. */
  60331. add(otherColor: DeepImmutable<Color3>): Color3;
  60332. /**
  60333. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60334. * @param otherColor defines the second operand
  60335. * @param result defines Color3 object to store the result into
  60336. * @returns the unmodified current Color3
  60337. */
  60338. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60339. /**
  60340. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60341. * @param otherColor defines the second operand
  60342. * @returns the new Color3
  60343. */
  60344. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60345. /**
  60346. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60347. * @param otherColor defines the second operand
  60348. * @param result defines Color3 object to store the result into
  60349. * @returns the unmodified current Color3
  60350. */
  60351. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60352. /**
  60353. * Copy the current object
  60354. * @returns a new Color3 copied the current one
  60355. */
  60356. clone(): Color3;
  60357. /**
  60358. * Copies the rgb values from the source in the current Color3
  60359. * @param source defines the source Color3 object
  60360. * @returns the updated Color3 object
  60361. */
  60362. copyFrom(source: DeepImmutable<Color3>): Color3;
  60363. /**
  60364. * Updates the Color3 rgb values from the given floats
  60365. * @param r defines the red component to read from
  60366. * @param g defines the green component to read from
  60367. * @param b defines the blue component to read from
  60368. * @returns the current Color3 object
  60369. */
  60370. copyFromFloats(r: number, g: number, b: number): Color3;
  60371. /**
  60372. * Updates the Color3 rgb values from the given floats
  60373. * @param r defines the red component to read from
  60374. * @param g defines the green component to read from
  60375. * @param b defines the blue component to read from
  60376. * @returns the current Color3 object
  60377. */
  60378. set(r: number, g: number, b: number): Color3;
  60379. /**
  60380. * Compute the Color3 hexadecimal code as a string
  60381. * @returns a string containing the hexadecimal representation of the Color3 object
  60382. */
  60383. toHexString(): string;
  60384. /**
  60385. * Computes a new Color3 converted from the current one to linear space
  60386. * @returns a new Color3 object
  60387. */
  60388. toLinearSpace(): Color3;
  60389. /**
  60390. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60391. * @param convertedColor defines the Color3 object where to store the linear space version
  60392. * @returns the unmodified Color3
  60393. */
  60394. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60395. /**
  60396. * Computes a new Color3 converted from the current one to gamma space
  60397. * @returns a new Color3 object
  60398. */
  60399. toGammaSpace(): Color3;
  60400. /**
  60401. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60402. * @param convertedColor defines the Color3 object where to store the gamma space version
  60403. * @returns the unmodified Color3
  60404. */
  60405. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60406. private static _BlackReadOnly;
  60407. /**
  60408. * Creates a new Color3 from the string containing valid hexadecimal values
  60409. * @param hex defines a string containing valid hexadecimal values
  60410. * @returns a new Color3 object
  60411. */
  60412. static FromHexString(hex: string): Color3;
  60413. /**
  60414. * Creates a new Color3 from the starting index of the given array
  60415. * @param array defines the source array
  60416. * @param offset defines an offset in the source array
  60417. * @returns a new Color3 object
  60418. */
  60419. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60420. /**
  60421. * Creates a new Color3 from integer values (< 256)
  60422. * @param r defines the red component to read from (value between 0 and 255)
  60423. * @param g defines the green component to read from (value between 0 and 255)
  60424. * @param b defines the blue component to read from (value between 0 and 255)
  60425. * @returns a new Color3 object
  60426. */
  60427. static FromInts(r: number, g: number, b: number): Color3;
  60428. /**
  60429. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60430. * @param start defines the start Color3 value
  60431. * @param end defines the end Color3 value
  60432. * @param amount defines the gradient value between start and end
  60433. * @returns a new Color3 object
  60434. */
  60435. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60436. /**
  60437. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60438. * @param left defines the start value
  60439. * @param right defines the end value
  60440. * @param amount defines the gradient factor
  60441. * @param result defines the Color3 object where to store the result
  60442. */
  60443. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60444. /**
  60445. * Returns a Color3 value containing a red color
  60446. * @returns a new Color3 object
  60447. */
  60448. static Red(): Color3;
  60449. /**
  60450. * Returns a Color3 value containing a green color
  60451. * @returns a new Color3 object
  60452. */
  60453. static Green(): Color3;
  60454. /**
  60455. * Returns a Color3 value containing a blue color
  60456. * @returns a new Color3 object
  60457. */
  60458. static Blue(): Color3;
  60459. /**
  60460. * Returns a Color3 value containing a black color
  60461. * @returns a new Color3 object
  60462. */
  60463. static Black(): Color3;
  60464. /**
  60465. * Gets a Color3 value containing a black color that must not be updated
  60466. */
  60467. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60468. /**
  60469. * Returns a Color3 value containing a white color
  60470. * @returns a new Color3 object
  60471. */
  60472. static White(): Color3;
  60473. /**
  60474. * Returns a Color3 value containing a purple color
  60475. * @returns a new Color3 object
  60476. */
  60477. static Purple(): Color3;
  60478. /**
  60479. * Returns a Color3 value containing a magenta color
  60480. * @returns a new Color3 object
  60481. */
  60482. static Magenta(): Color3;
  60483. /**
  60484. * Returns a Color3 value containing a yellow color
  60485. * @returns a new Color3 object
  60486. */
  60487. static Yellow(): Color3;
  60488. /**
  60489. * Returns a Color3 value containing a gray color
  60490. * @returns a new Color3 object
  60491. */
  60492. static Gray(): Color3;
  60493. /**
  60494. * Returns a Color3 value containing a teal color
  60495. * @returns a new Color3 object
  60496. */
  60497. static Teal(): Color3;
  60498. /**
  60499. * Returns a Color3 value containing a random color
  60500. * @returns a new Color3 object
  60501. */
  60502. static Random(): Color3;
  60503. }
  60504. /**
  60505. * Class used to hold a RBGA color
  60506. */
  60507. export class Color4 {
  60508. /**
  60509. * Defines the red component (between 0 and 1, default is 0)
  60510. */
  60511. r: number;
  60512. /**
  60513. * Defines the green component (between 0 and 1, default is 0)
  60514. */
  60515. g: number;
  60516. /**
  60517. * Defines the blue component (between 0 and 1, default is 0)
  60518. */
  60519. b: number;
  60520. /**
  60521. * Defines the alpha component (between 0 and 1, default is 1)
  60522. */
  60523. a: number;
  60524. /**
  60525. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60526. * @param r defines the red component (between 0 and 1, default is 0)
  60527. * @param g defines the green component (between 0 and 1, default is 0)
  60528. * @param b defines the blue component (between 0 and 1, default is 0)
  60529. * @param a defines the alpha component (between 0 and 1, default is 1)
  60530. */
  60531. constructor(
  60532. /**
  60533. * Defines the red component (between 0 and 1, default is 0)
  60534. */
  60535. r?: number,
  60536. /**
  60537. * Defines the green component (between 0 and 1, default is 0)
  60538. */
  60539. g?: number,
  60540. /**
  60541. * Defines the blue component (between 0 and 1, default is 0)
  60542. */
  60543. b?: number,
  60544. /**
  60545. * Defines the alpha component (between 0 and 1, default is 1)
  60546. */
  60547. a?: number);
  60548. /**
  60549. * Adds in place the given Color4 values to the current Color4 object
  60550. * @param right defines the second operand
  60551. * @returns the current updated Color4 object
  60552. */
  60553. addInPlace(right: DeepImmutable<Color4>): Color4;
  60554. /**
  60555. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60556. * @returns the new array
  60557. */
  60558. asArray(): number[];
  60559. /**
  60560. * Stores from the starting index in the given array the Color4 successive values
  60561. * @param array defines the array where to store the r,g,b components
  60562. * @param index defines an optional index in the target array to define where to start storing values
  60563. * @returns the current Color4 object
  60564. */
  60565. toArray(array: number[], index?: number): Color4;
  60566. /**
  60567. * Determines equality between Color4 objects
  60568. * @param otherColor defines the second operand
  60569. * @returns true if the rgba values are equal to the given ones
  60570. */
  60571. equals(otherColor: DeepImmutable<Color4>): boolean;
  60572. /**
  60573. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60574. * @param right defines the second operand
  60575. * @returns a new Color4 object
  60576. */
  60577. add(right: DeepImmutable<Color4>): Color4;
  60578. /**
  60579. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60580. * @param right defines the second operand
  60581. * @returns a new Color4 object
  60582. */
  60583. subtract(right: DeepImmutable<Color4>): Color4;
  60584. /**
  60585. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60586. * @param right defines the second operand
  60587. * @param result defines the Color4 object where to store the result
  60588. * @returns the current Color4 object
  60589. */
  60590. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60591. /**
  60592. * Creates a new Color4 with the current Color4 values multiplied by scale
  60593. * @param scale defines the scaling factor to apply
  60594. * @returns a new Color4 object
  60595. */
  60596. scale(scale: number): Color4;
  60597. /**
  60598. * Multiplies the current Color4 values by scale and stores the result in "result"
  60599. * @param scale defines the scaling factor to apply
  60600. * @param result defines the Color4 object where to store the result
  60601. * @returns the current unmodified Color4
  60602. */
  60603. scaleToRef(scale: number, result: Color4): Color4;
  60604. /**
  60605. * Scale the current Color4 values by a factor and add the result to a given Color4
  60606. * @param scale defines the scale factor
  60607. * @param result defines the Color4 object where to store the result
  60608. * @returns the unmodified current Color4
  60609. */
  60610. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60611. /**
  60612. * Clamps the rgb values by the min and max values and stores the result into "result"
  60613. * @param min defines minimum clamping value (default is 0)
  60614. * @param max defines maximum clamping value (default is 1)
  60615. * @param result defines color to store the result into.
  60616. * @returns the cuurent Color4
  60617. */
  60618. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60619. /**
  60620. * Multipy an Color4 value by another and return a new Color4 object
  60621. * @param color defines the Color4 value to multiply by
  60622. * @returns a new Color4 object
  60623. */
  60624. multiply(color: Color4): Color4;
  60625. /**
  60626. * Multipy a Color4 value by another and push the result in a reference value
  60627. * @param color defines the Color4 value to multiply by
  60628. * @param result defines the Color4 to fill the result in
  60629. * @returns the result Color4
  60630. */
  60631. multiplyToRef(color: Color4, result: Color4): Color4;
  60632. /**
  60633. * Creates a string with the Color4 current values
  60634. * @returns the string representation of the Color4 object
  60635. */
  60636. toString(): string;
  60637. /**
  60638. * Returns the string "Color4"
  60639. * @returns "Color4"
  60640. */
  60641. getClassName(): string;
  60642. /**
  60643. * Compute the Color4 hash code
  60644. * @returns an unique number that can be used to hash Color4 objects
  60645. */
  60646. getHashCode(): number;
  60647. /**
  60648. * Creates a new Color4 copied from the current one
  60649. * @returns a new Color4 object
  60650. */
  60651. clone(): Color4;
  60652. /**
  60653. * Copies the given Color4 values into the current one
  60654. * @param source defines the source Color4 object
  60655. * @returns the current updated Color4 object
  60656. */
  60657. copyFrom(source: Color4): Color4;
  60658. /**
  60659. * Copies the given float values into the current one
  60660. * @param r defines the red component to read from
  60661. * @param g defines the green component to read from
  60662. * @param b defines the blue component to read from
  60663. * @param a defines the alpha component to read from
  60664. * @returns the current updated Color4 object
  60665. */
  60666. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60667. /**
  60668. * Copies the given float values into the current one
  60669. * @param r defines the red component to read from
  60670. * @param g defines the green component to read from
  60671. * @param b defines the blue component to read from
  60672. * @param a defines the alpha component to read from
  60673. * @returns the current updated Color4 object
  60674. */
  60675. set(r: number, g: number, b: number, a: number): Color4;
  60676. /**
  60677. * Compute the Color4 hexadecimal code as a string
  60678. * @returns a string containing the hexadecimal representation of the Color4 object
  60679. */
  60680. toHexString(): string;
  60681. /**
  60682. * Computes a new Color4 converted from the current one to linear space
  60683. * @returns a new Color4 object
  60684. */
  60685. toLinearSpace(): Color4;
  60686. /**
  60687. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60688. * @param convertedColor defines the Color4 object where to store the linear space version
  60689. * @returns the unmodified Color4
  60690. */
  60691. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60692. /**
  60693. * Computes a new Color4 converted from the current one to gamma space
  60694. * @returns a new Color4 object
  60695. */
  60696. toGammaSpace(): Color4;
  60697. /**
  60698. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60699. * @param convertedColor defines the Color4 object where to store the gamma space version
  60700. * @returns the unmodified Color4
  60701. */
  60702. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60703. /**
  60704. * Creates a new Color4 from the string containing valid hexadecimal values
  60705. * @param hex defines a string containing valid hexadecimal values
  60706. * @returns a new Color4 object
  60707. */
  60708. static FromHexString(hex: string): Color4;
  60709. /**
  60710. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60711. * @param left defines the start value
  60712. * @param right defines the end value
  60713. * @param amount defines the gradient factor
  60714. * @returns a new Color4 object
  60715. */
  60716. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60717. /**
  60718. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60719. * @param left defines the start value
  60720. * @param right defines the end value
  60721. * @param amount defines the gradient factor
  60722. * @param result defines the Color4 object where to store data
  60723. */
  60724. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60725. /**
  60726. * Creates a new Color4 from a Color3 and an alpha value
  60727. * @param color3 defines the source Color3 to read from
  60728. * @param alpha defines the alpha component (1.0 by default)
  60729. * @returns a new Color4 object
  60730. */
  60731. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60732. /**
  60733. * Creates a new Color4 from the starting index element of the given array
  60734. * @param array defines the source array to read from
  60735. * @param offset defines the offset in the source array
  60736. * @returns a new Color4 object
  60737. */
  60738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60739. /**
  60740. * Creates a new Color3 from integer values (< 256)
  60741. * @param r defines the red component to read from (value between 0 and 255)
  60742. * @param g defines the green component to read from (value between 0 and 255)
  60743. * @param b defines the blue component to read from (value between 0 and 255)
  60744. * @param a defines the alpha component to read from (value between 0 and 255)
  60745. * @returns a new Color3 object
  60746. */
  60747. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60748. /**
  60749. * Check the content of a given array and convert it to an array containing RGBA data
  60750. * If the original array was already containing count * 4 values then it is returned directly
  60751. * @param colors defines the array to check
  60752. * @param count defines the number of RGBA data to expect
  60753. * @returns an array containing count * 4 values (RGBA)
  60754. */
  60755. static CheckColors4(colors: number[], count: number): number[];
  60756. }
  60757. /**
  60758. * Class representing a vector containing 2 coordinates
  60759. */
  60760. export class Vector2 {
  60761. /** defines the first coordinate */
  60762. x: number;
  60763. /** defines the second coordinate */
  60764. y: number;
  60765. /**
  60766. * Creates a new Vector2 from the given x and y coordinates
  60767. * @param x defines the first coordinate
  60768. * @param y defines the second coordinate
  60769. */
  60770. constructor(
  60771. /** defines the first coordinate */
  60772. x?: number,
  60773. /** defines the second coordinate */
  60774. y?: number);
  60775. /**
  60776. * Gets a string with the Vector2 coordinates
  60777. * @returns a string with the Vector2 coordinates
  60778. */
  60779. toString(): string;
  60780. /**
  60781. * Gets class name
  60782. * @returns the string "Vector2"
  60783. */
  60784. getClassName(): string;
  60785. /**
  60786. * Gets current vector hash code
  60787. * @returns the Vector2 hash code as a number
  60788. */
  60789. getHashCode(): number;
  60790. /**
  60791. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60792. * @param array defines the source array
  60793. * @param index defines the offset in source array
  60794. * @returns the current Vector2
  60795. */
  60796. toArray(array: FloatArray, index?: number): Vector2;
  60797. /**
  60798. * Copy the current vector to an array
  60799. * @returns a new array with 2 elements: the Vector2 coordinates.
  60800. */
  60801. asArray(): number[];
  60802. /**
  60803. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60804. * @param source defines the source Vector2
  60805. * @returns the current updated Vector2
  60806. */
  60807. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60808. /**
  60809. * Sets the Vector2 coordinates with the given floats
  60810. * @param x defines the first coordinate
  60811. * @param y defines the second coordinate
  60812. * @returns the current updated Vector2
  60813. */
  60814. copyFromFloats(x: number, y: number): Vector2;
  60815. /**
  60816. * Sets the Vector2 coordinates with the given floats
  60817. * @param x defines the first coordinate
  60818. * @param y defines the second coordinate
  60819. * @returns the current updated Vector2
  60820. */
  60821. set(x: number, y: number): Vector2;
  60822. /**
  60823. * Add another vector with the current one
  60824. * @param otherVector defines the other vector
  60825. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60826. */
  60827. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60828. /**
  60829. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60830. * @param otherVector defines the other vector
  60831. * @param result defines the target vector
  60832. * @returns the unmodified current Vector2
  60833. */
  60834. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60835. /**
  60836. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60837. * @param otherVector defines the other vector
  60838. * @returns the current updated Vector2
  60839. */
  60840. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60841. /**
  60842. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60843. * @param otherVector defines the other vector
  60844. * @returns a new Vector2
  60845. */
  60846. addVector3(otherVector: Vector3): Vector2;
  60847. /**
  60848. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60849. * @param otherVector defines the other vector
  60850. * @returns a new Vector2
  60851. */
  60852. subtract(otherVector: Vector2): Vector2;
  60853. /**
  60854. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60855. * @param otherVector defines the other vector
  60856. * @param result defines the target vector
  60857. * @returns the unmodified current Vector2
  60858. */
  60859. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60860. /**
  60861. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60862. * @param otherVector defines the other vector
  60863. * @returns the current updated Vector2
  60864. */
  60865. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60866. /**
  60867. * Multiplies in place the current Vector2 coordinates by the given ones
  60868. * @param otherVector defines the other vector
  60869. * @returns the current updated Vector2
  60870. */
  60871. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60872. /**
  60873. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60874. * @param otherVector defines the other vector
  60875. * @returns a new Vector2
  60876. */
  60877. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60878. /**
  60879. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60880. * @param otherVector defines the other vector
  60881. * @param result defines the target vector
  60882. * @returns the unmodified current Vector2
  60883. */
  60884. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60885. /**
  60886. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60887. * @param x defines the first coordinate
  60888. * @param y defines the second coordinate
  60889. * @returns a new Vector2
  60890. */
  60891. multiplyByFloats(x: number, y: number): Vector2;
  60892. /**
  60893. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60894. * @param otherVector defines the other vector
  60895. * @returns a new Vector2
  60896. */
  60897. divide(otherVector: Vector2): Vector2;
  60898. /**
  60899. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60900. * @param otherVector defines the other vector
  60901. * @param result defines the target vector
  60902. * @returns the unmodified current Vector2
  60903. */
  60904. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60905. /**
  60906. * Divides the current Vector2 coordinates by the given ones
  60907. * @param otherVector defines the other vector
  60908. * @returns the current updated Vector2
  60909. */
  60910. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60911. /**
  60912. * Gets a new Vector2 with current Vector2 negated coordinates
  60913. * @returns a new Vector2
  60914. */
  60915. negate(): Vector2;
  60916. /**
  60917. * Multiply the Vector2 coordinates by scale
  60918. * @param scale defines the scaling factor
  60919. * @returns the current updated Vector2
  60920. */
  60921. scaleInPlace(scale: number): Vector2;
  60922. /**
  60923. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60924. * @param scale defines the scaling factor
  60925. * @returns a new Vector2
  60926. */
  60927. scale(scale: number): Vector2;
  60928. /**
  60929. * Scale the current Vector2 values by a factor to a given Vector2
  60930. * @param scale defines the scale factor
  60931. * @param result defines the Vector2 object where to store the result
  60932. * @returns the unmodified current Vector2
  60933. */
  60934. scaleToRef(scale: number, result: Vector2): Vector2;
  60935. /**
  60936. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60937. * @param scale defines the scale factor
  60938. * @param result defines the Vector2 object where to store the result
  60939. * @returns the unmodified current Vector2
  60940. */
  60941. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60942. /**
  60943. * Gets a boolean if two vectors are equals
  60944. * @param otherVector defines the other vector
  60945. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60946. */
  60947. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60948. /**
  60949. * Gets a boolean if two vectors are equals (using an epsilon value)
  60950. * @param otherVector defines the other vector
  60951. * @param epsilon defines the minimal distance to consider equality
  60952. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60953. */
  60954. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60955. /**
  60956. * Gets a new Vector2 from current Vector2 floored values
  60957. * @returns a new Vector2
  60958. */
  60959. floor(): Vector2;
  60960. /**
  60961. * Gets a new Vector2 from current Vector2 floored values
  60962. * @returns a new Vector2
  60963. */
  60964. fract(): Vector2;
  60965. /**
  60966. * Gets the length of the vector
  60967. * @returns the vector length (float)
  60968. */
  60969. length(): number;
  60970. /**
  60971. * Gets the vector squared length
  60972. * @returns the vector squared length (float)
  60973. */
  60974. lengthSquared(): number;
  60975. /**
  60976. * Normalize the vector
  60977. * @returns the current updated Vector2
  60978. */
  60979. normalize(): Vector2;
  60980. /**
  60981. * Gets a new Vector2 copied from the Vector2
  60982. * @returns a new Vector2
  60983. */
  60984. clone(): Vector2;
  60985. /**
  60986. * Gets a new Vector2(0, 0)
  60987. * @returns a new Vector2
  60988. */
  60989. static Zero(): Vector2;
  60990. /**
  60991. * Gets a new Vector2(1, 1)
  60992. * @returns a new Vector2
  60993. */
  60994. static One(): Vector2;
  60995. /**
  60996. * Gets a new Vector2 set from the given index element of the given array
  60997. * @param array defines the data source
  60998. * @param offset defines the offset in the data source
  60999. * @returns a new Vector2
  61000. */
  61001. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61002. /**
  61003. * Sets "result" from the given index element of the given array
  61004. * @param array defines the data source
  61005. * @param offset defines the offset in the data source
  61006. * @param result defines the target vector
  61007. */
  61008. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61009. /**
  61010. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61011. * @param value1 defines 1st point of control
  61012. * @param value2 defines 2nd point of control
  61013. * @param value3 defines 3rd point of control
  61014. * @param value4 defines 4th point of control
  61015. * @param amount defines the interpolation factor
  61016. * @returns a new Vector2
  61017. */
  61018. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61019. /**
  61020. * 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".
  61021. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61022. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61023. * @param value defines the value to clamp
  61024. * @param min defines the lower limit
  61025. * @param max defines the upper limit
  61026. * @returns a new Vector2
  61027. */
  61028. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61029. /**
  61030. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61031. * @param value1 defines the 1st control point
  61032. * @param tangent1 defines the outgoing tangent
  61033. * @param value2 defines the 2nd control point
  61034. * @param tangent2 defines the incoming tangent
  61035. * @param amount defines the interpolation factor
  61036. * @returns a new Vector2
  61037. */
  61038. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61039. /**
  61040. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61041. * @param start defines the start vector
  61042. * @param end defines the end vector
  61043. * @param amount defines the interpolation factor
  61044. * @returns a new Vector2
  61045. */
  61046. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61047. /**
  61048. * Gets the dot product of the vector "left" and the vector "right"
  61049. * @param left defines first vector
  61050. * @param right defines second vector
  61051. * @returns the dot product (float)
  61052. */
  61053. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61054. /**
  61055. * Returns a new Vector2 equal to the normalized given vector
  61056. * @param vector defines the vector to normalize
  61057. * @returns a new Vector2
  61058. */
  61059. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61060. /**
  61061. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61062. * @param left defines 1st vector
  61063. * @param right defines 2nd vector
  61064. * @returns a new Vector2
  61065. */
  61066. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61067. /**
  61068. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61069. * @param left defines 1st vector
  61070. * @param right defines 2nd vector
  61071. * @returns a new Vector2
  61072. */
  61073. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61074. /**
  61075. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61076. * @param vector defines the vector to transform
  61077. * @param transformation defines the matrix to apply
  61078. * @returns a new Vector2
  61079. */
  61080. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61081. /**
  61082. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61083. * @param vector defines the vector to transform
  61084. * @param transformation defines the matrix to apply
  61085. * @param result defines the target vector
  61086. */
  61087. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61088. /**
  61089. * Determines if a given vector is included in a triangle
  61090. * @param p defines the vector to test
  61091. * @param p0 defines 1st triangle point
  61092. * @param p1 defines 2nd triangle point
  61093. * @param p2 defines 3rd triangle point
  61094. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61095. */
  61096. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61097. /**
  61098. * Gets the distance between the vectors "value1" and "value2"
  61099. * @param value1 defines first vector
  61100. * @param value2 defines second vector
  61101. * @returns the distance between vectors
  61102. */
  61103. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61104. /**
  61105. * Returns the squared distance between the vectors "value1" and "value2"
  61106. * @param value1 defines first vector
  61107. * @param value2 defines second vector
  61108. * @returns the squared distance between vectors
  61109. */
  61110. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61111. /**
  61112. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61113. * @param value1 defines first vector
  61114. * @param value2 defines second vector
  61115. * @returns a new Vector2
  61116. */
  61117. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61118. /**
  61119. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61120. * @param p defines the middle point
  61121. * @param segA defines one point of the segment
  61122. * @param segB defines the other point of the segment
  61123. * @returns the shortest distance
  61124. */
  61125. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61126. }
  61127. /**
  61128. * Classed used to store (x,y,z) vector representation
  61129. * A Vector3 is the main object used in 3D geometry
  61130. * It can represent etiher the coordinates of a point the space, either a direction
  61131. * Reminder: js uses a left handed forward facing system
  61132. */
  61133. export class Vector3 {
  61134. /**
  61135. * Defines the first coordinates (on X axis)
  61136. */
  61137. x: number;
  61138. /**
  61139. * Defines the second coordinates (on Y axis)
  61140. */
  61141. y: number;
  61142. /**
  61143. * Defines the third coordinates (on Z axis)
  61144. */
  61145. z: number;
  61146. private static _UpReadOnly;
  61147. /**
  61148. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61149. * @param x defines the first coordinates (on X axis)
  61150. * @param y defines the second coordinates (on Y axis)
  61151. * @param z defines the third coordinates (on Z axis)
  61152. */
  61153. constructor(
  61154. /**
  61155. * Defines the first coordinates (on X axis)
  61156. */
  61157. x?: number,
  61158. /**
  61159. * Defines the second coordinates (on Y axis)
  61160. */
  61161. y?: number,
  61162. /**
  61163. * Defines the third coordinates (on Z axis)
  61164. */
  61165. z?: number);
  61166. /**
  61167. * Creates a string representation of the Vector3
  61168. * @returns a string with the Vector3 coordinates.
  61169. */
  61170. toString(): string;
  61171. /**
  61172. * Gets the class name
  61173. * @returns the string "Vector3"
  61174. */
  61175. getClassName(): string;
  61176. /**
  61177. * Creates the Vector3 hash code
  61178. * @returns a number which tends to be unique between Vector3 instances
  61179. */
  61180. getHashCode(): number;
  61181. /**
  61182. * Creates an array containing three elements : the coordinates of the Vector3
  61183. * @returns a new array of numbers
  61184. */
  61185. asArray(): number[];
  61186. /**
  61187. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61188. * @param array defines the destination array
  61189. * @param index defines the offset in the destination array
  61190. * @returns the current Vector3
  61191. */
  61192. toArray(array: FloatArray, index?: number): Vector3;
  61193. /**
  61194. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61195. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61196. */
  61197. toQuaternion(): Quaternion;
  61198. /**
  61199. * Adds the given vector to the current Vector3
  61200. * @param otherVector defines the second operand
  61201. * @returns the current updated Vector3
  61202. */
  61203. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61204. /**
  61205. * Adds the given coordinates to the current Vector3
  61206. * @param x defines the x coordinate of the operand
  61207. * @param y defines the y coordinate of the operand
  61208. * @param z defines the z coordinate of the operand
  61209. * @returns the current updated Vector3
  61210. */
  61211. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61212. /**
  61213. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61214. * @param otherVector defines the second operand
  61215. * @returns the resulting Vector3
  61216. */
  61217. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61218. /**
  61219. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61220. * @param otherVector defines the second operand
  61221. * @param result defines the Vector3 object where to store the result
  61222. * @returns the current Vector3
  61223. */
  61224. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61225. /**
  61226. * Subtract the given vector from the current Vector3
  61227. * @param otherVector defines the second operand
  61228. * @returns the current updated Vector3
  61229. */
  61230. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61231. /**
  61232. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61233. * @param otherVector defines the second operand
  61234. * @returns the resulting Vector3
  61235. */
  61236. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61237. /**
  61238. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61239. * @param otherVector defines the second operand
  61240. * @param result defines the Vector3 object where to store the result
  61241. * @returns the current Vector3
  61242. */
  61243. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61244. /**
  61245. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61246. * @param x defines the x coordinate of the operand
  61247. * @param y defines the y coordinate of the operand
  61248. * @param z defines the z coordinate of the operand
  61249. * @returns the resulting Vector3
  61250. */
  61251. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61252. /**
  61253. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61254. * @param x defines the x coordinate of the operand
  61255. * @param y defines the y coordinate of the operand
  61256. * @param z defines the z coordinate of the operand
  61257. * @param result defines the Vector3 object where to store the result
  61258. * @returns the current Vector3
  61259. */
  61260. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61261. /**
  61262. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61263. * @returns a new Vector3
  61264. */
  61265. negate(): Vector3;
  61266. /**
  61267. * Multiplies the Vector3 coordinates by the float "scale"
  61268. * @param scale defines the multiplier factor
  61269. * @returns the current updated Vector3
  61270. */
  61271. scaleInPlace(scale: number): Vector3;
  61272. /**
  61273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61274. * @param scale defines the multiplier factor
  61275. * @returns a new Vector3
  61276. */
  61277. scale(scale: number): Vector3;
  61278. /**
  61279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61280. * @param scale defines the multiplier factor
  61281. * @param result defines the Vector3 object where to store the result
  61282. * @returns the current Vector3
  61283. */
  61284. scaleToRef(scale: number, result: Vector3): Vector3;
  61285. /**
  61286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61287. * @param scale defines the scale factor
  61288. * @param result defines the Vector3 object where to store the result
  61289. * @returns the unmodified current Vector3
  61290. */
  61291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61292. /**
  61293. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61294. * @param otherVector defines the second operand
  61295. * @returns true if both vectors are equals
  61296. */
  61297. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61298. /**
  61299. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61300. * @param otherVector defines the second operand
  61301. * @param epsilon defines the minimal distance to define values as equals
  61302. * @returns true if both vectors are distant less than epsilon
  61303. */
  61304. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61305. /**
  61306. * Returns true if the current Vector3 coordinates equals the given floats
  61307. * @param x defines the x coordinate of the operand
  61308. * @param y defines the y coordinate of the operand
  61309. * @param z defines the z coordinate of the operand
  61310. * @returns true if both vectors are equals
  61311. */
  61312. equalsToFloats(x: number, y: number, z: number): boolean;
  61313. /**
  61314. * Multiplies the current Vector3 coordinates by the given ones
  61315. * @param otherVector defines the second operand
  61316. * @returns the current updated Vector3
  61317. */
  61318. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61319. /**
  61320. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61321. * @param otherVector defines the second operand
  61322. * @returns the new Vector3
  61323. */
  61324. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61325. /**
  61326. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61327. * @param otherVector defines the second operand
  61328. * @param result defines the Vector3 object where to store the result
  61329. * @returns the current Vector3
  61330. */
  61331. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61332. /**
  61333. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61334. * @param x defines the x coordinate of the operand
  61335. * @param y defines the y coordinate of the operand
  61336. * @param z defines the z coordinate of the operand
  61337. * @returns the new Vector3
  61338. */
  61339. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61340. /**
  61341. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61342. * @param otherVector defines the second operand
  61343. * @returns the new Vector3
  61344. */
  61345. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61346. /**
  61347. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61348. * @param otherVector defines the second operand
  61349. * @param result defines the Vector3 object where to store the result
  61350. * @returns the current Vector3
  61351. */
  61352. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61353. /**
  61354. * Divides the current Vector3 coordinates by the given ones.
  61355. * @param otherVector defines the second operand
  61356. * @returns the current updated Vector3
  61357. */
  61358. divideInPlace(otherVector: Vector3): Vector3;
  61359. /**
  61360. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61361. * @param other defines the second operand
  61362. * @returns the current updated Vector3
  61363. */
  61364. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61365. /**
  61366. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61367. * @param other defines the second operand
  61368. * @returns the current updated Vector3
  61369. */
  61370. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61371. /**
  61372. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61373. * @param x defines the x coordinate of the operand
  61374. * @param y defines the y coordinate of the operand
  61375. * @param z defines the z coordinate of the operand
  61376. * @returns the current updated Vector3
  61377. */
  61378. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61379. /**
  61380. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61381. * @param x defines the x coordinate of the operand
  61382. * @param y defines the y coordinate of the operand
  61383. * @param z defines the z coordinate of the operand
  61384. * @returns the current updated Vector3
  61385. */
  61386. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61387. /**
  61388. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61389. * Check if is non uniform within a certain amount of decimal places to account for this
  61390. * @param epsilon the amount the values can differ
  61391. * @returns if the the vector is non uniform to a certain number of decimal places
  61392. */
  61393. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61394. /**
  61395. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61396. */
  61397. readonly isNonUniform: boolean;
  61398. /**
  61399. * Gets a new Vector3 from current Vector3 floored values
  61400. * @returns a new Vector3
  61401. */
  61402. floor(): Vector3;
  61403. /**
  61404. * Gets a new Vector3 from current Vector3 floored values
  61405. * @returns a new Vector3
  61406. */
  61407. fract(): Vector3;
  61408. /**
  61409. * Gets the length of the Vector3
  61410. * @returns the length of the Vecto3
  61411. */
  61412. length(): number;
  61413. /**
  61414. * Gets the squared length of the Vector3
  61415. * @returns squared length of the Vector3
  61416. */
  61417. lengthSquared(): number;
  61418. /**
  61419. * Normalize the current Vector3.
  61420. * Please note that this is an in place operation.
  61421. * @returns the current updated Vector3
  61422. */
  61423. normalize(): Vector3;
  61424. /**
  61425. * Reorders the x y z properties of the vector in place
  61426. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61427. * @returns the current updated vector
  61428. */
  61429. reorderInPlace(order: string): this;
  61430. /**
  61431. * Rotates the vector around 0,0,0 by a quaternion
  61432. * @param quaternion the rotation quaternion
  61433. * @param result vector to store the result
  61434. * @returns the resulting vector
  61435. */
  61436. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61437. /**
  61438. * Rotates a vector around a given point
  61439. * @param quaternion the rotation quaternion
  61440. * @param point the point to rotate around
  61441. * @param result vector to store the result
  61442. * @returns the resulting vector
  61443. */
  61444. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61445. /**
  61446. * Normalize the current Vector3 with the given input length.
  61447. * Please note that this is an in place operation.
  61448. * @param len the length of the vector
  61449. * @returns the current updated Vector3
  61450. */
  61451. normalizeFromLength(len: number): Vector3;
  61452. /**
  61453. * Normalize the current Vector3 to a new vector
  61454. * @returns the new Vector3
  61455. */
  61456. normalizeToNew(): Vector3;
  61457. /**
  61458. * Normalize the current Vector3 to the reference
  61459. * @param reference define the Vector3 to update
  61460. * @returns the updated Vector3
  61461. */
  61462. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61463. /**
  61464. * Creates a new Vector3 copied from the current Vector3
  61465. * @returns the new Vector3
  61466. */
  61467. clone(): Vector3;
  61468. /**
  61469. * Copies the given vector coordinates to the current Vector3 ones
  61470. * @param source defines the source Vector3
  61471. * @returns the current updated Vector3
  61472. */
  61473. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61474. /**
  61475. * Copies the given floats to the current Vector3 coordinates
  61476. * @param x defines the x coordinate of the operand
  61477. * @param y defines the y coordinate of the operand
  61478. * @param z defines the z coordinate of the operand
  61479. * @returns the current updated Vector3
  61480. */
  61481. copyFromFloats(x: number, y: number, z: number): Vector3;
  61482. /**
  61483. * Copies the given floats to the current Vector3 coordinates
  61484. * @param x defines the x coordinate of the operand
  61485. * @param y defines the y coordinate of the operand
  61486. * @param z defines the z coordinate of the operand
  61487. * @returns the current updated Vector3
  61488. */
  61489. set(x: number, y: number, z: number): Vector3;
  61490. /**
  61491. * Copies the given float to the current Vector3 coordinates
  61492. * @param v defines the x, y and z coordinates of the operand
  61493. * @returns the current updated Vector3
  61494. */
  61495. setAll(v: number): Vector3;
  61496. /**
  61497. * Get the clip factor between two vectors
  61498. * @param vector0 defines the first operand
  61499. * @param vector1 defines the second operand
  61500. * @param axis defines the axis to use
  61501. * @param size defines the size along the axis
  61502. * @returns the clip factor
  61503. */
  61504. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61505. /**
  61506. * Get angle between two vectors
  61507. * @param vector0 angle between vector0 and vector1
  61508. * @param vector1 angle between vector0 and vector1
  61509. * @param normal direction of the normal
  61510. * @return the angle between vector0 and vector1
  61511. */
  61512. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61513. /**
  61514. * Returns a new Vector3 set from the index "offset" of the given array
  61515. * @param array defines the source array
  61516. * @param offset defines the offset in the source array
  61517. * @returns the new Vector3
  61518. */
  61519. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61520. /**
  61521. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61522. * This function is deprecated. Use FromArray instead
  61523. * @param array defines the source array
  61524. * @param offset defines the offset in the source array
  61525. * @returns the new Vector3
  61526. */
  61527. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61528. /**
  61529. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61530. * @param array defines the source array
  61531. * @param offset defines the offset in the source array
  61532. * @param result defines the Vector3 where to store the result
  61533. */
  61534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61535. /**
  61536. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61537. * This function is deprecated. Use FromArrayToRef instead.
  61538. * @param array defines the source array
  61539. * @param offset defines the offset in the source array
  61540. * @param result defines the Vector3 where to store the result
  61541. */
  61542. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61543. /**
  61544. * Sets the given vector "result" with the given floats.
  61545. * @param x defines the x coordinate of the source
  61546. * @param y defines the y coordinate of the source
  61547. * @param z defines the z coordinate of the source
  61548. * @param result defines the Vector3 where to store the result
  61549. */
  61550. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61551. /**
  61552. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61553. * @returns a new empty Vector3
  61554. */
  61555. static Zero(): Vector3;
  61556. /**
  61557. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61558. * @returns a new unit Vector3
  61559. */
  61560. static One(): Vector3;
  61561. /**
  61562. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61563. * @returns a new up Vector3
  61564. */
  61565. static Up(): Vector3;
  61566. /**
  61567. * Gets a up Vector3 that must not be updated
  61568. */
  61569. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61570. /**
  61571. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61572. * @returns a new down Vector3
  61573. */
  61574. static Down(): Vector3;
  61575. /**
  61576. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61577. * @returns a new forward Vector3
  61578. */
  61579. static Forward(): Vector3;
  61580. /**
  61581. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61582. * @returns a new forward Vector3
  61583. */
  61584. static Backward(): Vector3;
  61585. /**
  61586. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61587. * @returns a new right Vector3
  61588. */
  61589. static Right(): Vector3;
  61590. /**
  61591. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61592. * @returns a new left Vector3
  61593. */
  61594. static Left(): Vector3;
  61595. /**
  61596. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61597. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61598. * @param vector defines the Vector3 to transform
  61599. * @param transformation defines the transformation matrix
  61600. * @returns the transformed Vector3
  61601. */
  61602. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61603. /**
  61604. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61605. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61606. * @param vector defines the Vector3 to transform
  61607. * @param transformation defines the transformation matrix
  61608. * @param result defines the Vector3 where to store the result
  61609. */
  61610. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61611. /**
  61612. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61613. * This method computes tranformed coordinates only, not transformed direction vectors
  61614. * @param x define the x coordinate of the source vector
  61615. * @param y define the y coordinate of the source vector
  61616. * @param z define the z coordinate of the source vector
  61617. * @param transformation defines the transformation matrix
  61618. * @param result defines the Vector3 where to store the result
  61619. */
  61620. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61621. /**
  61622. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61623. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61624. * @param vector defines the Vector3 to transform
  61625. * @param transformation defines the transformation matrix
  61626. * @returns the new Vector3
  61627. */
  61628. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61629. /**
  61630. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61631. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61632. * @param vector defines the Vector3 to transform
  61633. * @param transformation defines the transformation matrix
  61634. * @param result defines the Vector3 where to store the result
  61635. */
  61636. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61637. /**
  61638. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61639. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61640. * @param x define the x coordinate of the source vector
  61641. * @param y define the y coordinate of the source vector
  61642. * @param z define the z coordinate of the source vector
  61643. * @param transformation defines the transformation matrix
  61644. * @param result defines the Vector3 where to store the result
  61645. */
  61646. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61647. /**
  61648. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61649. * @param value1 defines the first control point
  61650. * @param value2 defines the second control point
  61651. * @param value3 defines the third control point
  61652. * @param value4 defines the fourth control point
  61653. * @param amount defines the amount on the spline to use
  61654. * @returns the new Vector3
  61655. */
  61656. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61657. /**
  61658. * 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"
  61659. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61660. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61661. * @param value defines the current value
  61662. * @param min defines the lower range value
  61663. * @param max defines the upper range value
  61664. * @returns the new Vector3
  61665. */
  61666. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61667. /**
  61668. * 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"
  61669. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61670. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61671. * @param value defines the current value
  61672. * @param min defines the lower range value
  61673. * @param max defines the upper range value
  61674. * @param result defines the Vector3 where to store the result
  61675. */
  61676. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61677. /**
  61678. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61679. * @param value1 defines the first control point
  61680. * @param tangent1 defines the first tangent vector
  61681. * @param value2 defines the second control point
  61682. * @param tangent2 defines the second tangent vector
  61683. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61684. * @returns the new Vector3
  61685. */
  61686. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61687. /**
  61688. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61689. * @param start defines the start value
  61690. * @param end defines the end value
  61691. * @param amount max defines amount between both (between 0 and 1)
  61692. * @returns the new Vector3
  61693. */
  61694. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61695. /**
  61696. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61697. * @param start defines the start value
  61698. * @param end defines the end value
  61699. * @param amount max defines amount between both (between 0 and 1)
  61700. * @param result defines the Vector3 where to store the result
  61701. */
  61702. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61703. /**
  61704. * Returns the dot product (float) between the vectors "left" and "right"
  61705. * @param left defines the left operand
  61706. * @param right defines the right operand
  61707. * @returns the dot product
  61708. */
  61709. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61710. /**
  61711. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61712. * The cross product is then orthogonal to both "left" and "right"
  61713. * @param left defines the left operand
  61714. * @param right defines the right operand
  61715. * @returns the cross product
  61716. */
  61717. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61718. /**
  61719. * Sets the given vector "result" with the cross product of "left" and "right"
  61720. * The cross product is then orthogonal to both "left" and "right"
  61721. * @param left defines the left operand
  61722. * @param right defines the right operand
  61723. * @param result defines the Vector3 where to store the result
  61724. */
  61725. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61726. /**
  61727. * Returns a new Vector3 as the normalization of the given vector
  61728. * @param vector defines the Vector3 to normalize
  61729. * @returns the new Vector3
  61730. */
  61731. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61732. /**
  61733. * Sets the given vector "result" with the normalization of the given first vector
  61734. * @param vector defines the Vector3 to normalize
  61735. * @param result defines the Vector3 where to store the result
  61736. */
  61737. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61738. /**
  61739. * Project a Vector3 onto screen space
  61740. * @param vector defines the Vector3 to project
  61741. * @param world defines the world matrix to use
  61742. * @param transform defines the transform (view x projection) matrix to use
  61743. * @param viewport defines the screen viewport to use
  61744. * @returns the new Vector3
  61745. */
  61746. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61747. /** @hidden */
  61748. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61749. /**
  61750. * Unproject from screen space to object space
  61751. * @param source defines the screen space Vector3 to use
  61752. * @param viewportWidth defines the current width of the viewport
  61753. * @param viewportHeight defines the current height of the viewport
  61754. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61755. * @param transform defines the transform (view x projection) matrix to use
  61756. * @returns the new Vector3
  61757. */
  61758. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61759. /**
  61760. * Unproject from screen space to object space
  61761. * @param source defines the screen space Vector3 to use
  61762. * @param viewportWidth defines the current width of the viewport
  61763. * @param viewportHeight defines the current height of the viewport
  61764. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61765. * @param view defines the view matrix to use
  61766. * @param projection defines the projection matrix to use
  61767. * @returns the new Vector3
  61768. */
  61769. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61770. /**
  61771. * Unproject from screen space to object space
  61772. * @param source defines the screen space Vector3 to use
  61773. * @param viewportWidth defines the current width of the viewport
  61774. * @param viewportHeight defines the current height of the viewport
  61775. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61776. * @param view defines the view matrix to use
  61777. * @param projection defines the projection matrix to use
  61778. * @param result defines the Vector3 where to store the result
  61779. */
  61780. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61781. /**
  61782. * Unproject from screen space to object space
  61783. * @param sourceX defines the screen space x coordinate to use
  61784. * @param sourceY defines the screen space y coordinate to use
  61785. * @param sourceZ defines the screen space z coordinate to use
  61786. * @param viewportWidth defines the current width of the viewport
  61787. * @param viewportHeight defines the current height of the viewport
  61788. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61789. * @param view defines the view matrix to use
  61790. * @param projection defines the projection matrix to use
  61791. * @param result defines the Vector3 where to store the result
  61792. */
  61793. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61794. /**
  61795. * Gets the minimal coordinate values between two Vector3
  61796. * @param left defines the first operand
  61797. * @param right defines the second operand
  61798. * @returns the new Vector3
  61799. */
  61800. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61801. /**
  61802. * Gets the maximal coordinate values between two Vector3
  61803. * @param left defines the first operand
  61804. * @param right defines the second operand
  61805. * @returns the new Vector3
  61806. */
  61807. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61808. /**
  61809. * Returns the distance between the vectors "value1" and "value2"
  61810. * @param value1 defines the first operand
  61811. * @param value2 defines the second operand
  61812. * @returns the distance
  61813. */
  61814. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61815. /**
  61816. * Returns the squared distance between the vectors "value1" and "value2"
  61817. * @param value1 defines the first operand
  61818. * @param value2 defines the second operand
  61819. * @returns the squared distance
  61820. */
  61821. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61822. /**
  61823. * Returns a new Vector3 located at the center between "value1" and "value2"
  61824. * @param value1 defines the first operand
  61825. * @param value2 defines the second operand
  61826. * @returns the new Vector3
  61827. */
  61828. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61829. /**
  61830. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61831. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61832. * to something in order to rotate it from its local system to the given target system
  61833. * Note: axis1, axis2 and axis3 are normalized during this operation
  61834. * @param axis1 defines the first axis
  61835. * @param axis2 defines the second axis
  61836. * @param axis3 defines the third axis
  61837. * @returns a new Vector3
  61838. */
  61839. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61840. /**
  61841. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61842. * @param axis1 defines the first axis
  61843. * @param axis2 defines the second axis
  61844. * @param axis3 defines the third axis
  61845. * @param ref defines the Vector3 where to store the result
  61846. */
  61847. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61848. }
  61849. /**
  61850. * Vector4 class created for EulerAngle class conversion to Quaternion
  61851. */
  61852. export class Vector4 {
  61853. /** x value of the vector */
  61854. x: number;
  61855. /** y value of the vector */
  61856. y: number;
  61857. /** z value of the vector */
  61858. z: number;
  61859. /** w value of the vector */
  61860. w: number;
  61861. /**
  61862. * Creates a Vector4 object from the given floats.
  61863. * @param x x value of the vector
  61864. * @param y y value of the vector
  61865. * @param z z value of the vector
  61866. * @param w w value of the vector
  61867. */
  61868. constructor(
  61869. /** x value of the vector */
  61870. x: number,
  61871. /** y value of the vector */
  61872. y: number,
  61873. /** z value of the vector */
  61874. z: number,
  61875. /** w value of the vector */
  61876. w: number);
  61877. /**
  61878. * Returns the string with the Vector4 coordinates.
  61879. * @returns a string containing all the vector values
  61880. */
  61881. toString(): string;
  61882. /**
  61883. * Returns the string "Vector4".
  61884. * @returns "Vector4"
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Returns the Vector4 hash code.
  61889. * @returns a unique hash code
  61890. */
  61891. getHashCode(): number;
  61892. /**
  61893. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61894. * @returns the resulting array
  61895. */
  61896. asArray(): number[];
  61897. /**
  61898. * Populates the given array from the given index with the Vector4 coordinates.
  61899. * @param array array to populate
  61900. * @param index index of the array to start at (default: 0)
  61901. * @returns the Vector4.
  61902. */
  61903. toArray(array: FloatArray, index?: number): Vector4;
  61904. /**
  61905. * Adds the given vector to the current Vector4.
  61906. * @param otherVector the vector to add
  61907. * @returns the updated Vector4.
  61908. */
  61909. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61910. /**
  61911. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61912. * @param otherVector the vector to add
  61913. * @returns the resulting vector
  61914. */
  61915. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61916. /**
  61917. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61918. * @param otherVector the vector to add
  61919. * @param result the vector to store the result
  61920. * @returns the current Vector4.
  61921. */
  61922. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61923. /**
  61924. * Subtract in place the given vector from the current Vector4.
  61925. * @param otherVector the vector to subtract
  61926. * @returns the updated Vector4.
  61927. */
  61928. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61929. /**
  61930. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61931. * @param otherVector the vector to add
  61932. * @returns the new vector with the result
  61933. */
  61934. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61935. /**
  61936. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61937. * @param otherVector the vector to subtract
  61938. * @param result the vector to store the result
  61939. * @returns the current Vector4.
  61940. */
  61941. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61942. /**
  61943. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61944. */
  61945. /**
  61946. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61947. * @param x value to subtract
  61948. * @param y value to subtract
  61949. * @param z value to subtract
  61950. * @param w value to subtract
  61951. * @returns new vector containing the result
  61952. */
  61953. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61954. /**
  61955. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61956. * @param x value to subtract
  61957. * @param y value to subtract
  61958. * @param z value to subtract
  61959. * @param w value to subtract
  61960. * @param result the vector to store the result in
  61961. * @returns the current Vector4.
  61962. */
  61963. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61964. /**
  61965. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61966. * @returns a new vector with the negated values
  61967. */
  61968. negate(): Vector4;
  61969. /**
  61970. * Multiplies the current Vector4 coordinates by scale (float).
  61971. * @param scale the number to scale with
  61972. * @returns the updated Vector4.
  61973. */
  61974. scaleInPlace(scale: number): Vector4;
  61975. /**
  61976. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61977. * @param scale the number to scale with
  61978. * @returns a new vector with the result
  61979. */
  61980. scale(scale: number): Vector4;
  61981. /**
  61982. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61983. * @param scale the number to scale with
  61984. * @param result a vector to store the result in
  61985. * @returns the current Vector4.
  61986. */
  61987. scaleToRef(scale: number, result: Vector4): Vector4;
  61988. /**
  61989. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61990. * @param scale defines the scale factor
  61991. * @param result defines the Vector4 object where to store the result
  61992. * @returns the unmodified current Vector4
  61993. */
  61994. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61995. /**
  61996. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61997. * @param otherVector the vector to compare against
  61998. * @returns true if they are equal
  61999. */
  62000. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62001. /**
  62002. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62003. * @param otherVector vector to compare against
  62004. * @param epsilon (Default: very small number)
  62005. * @returns true if they are equal
  62006. */
  62007. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62008. /**
  62009. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62010. * @param x x value to compare against
  62011. * @param y y value to compare against
  62012. * @param z z value to compare against
  62013. * @param w w value to compare against
  62014. * @returns true if equal
  62015. */
  62016. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62017. /**
  62018. * Multiplies in place the current Vector4 by the given one.
  62019. * @param otherVector vector to multiple with
  62020. * @returns the updated Vector4.
  62021. */
  62022. multiplyInPlace(otherVector: Vector4): Vector4;
  62023. /**
  62024. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62025. * @param otherVector vector to multiple with
  62026. * @returns resulting new vector
  62027. */
  62028. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62029. /**
  62030. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62031. * @param otherVector vector to multiple with
  62032. * @param result vector to store the result
  62033. * @returns the current Vector4.
  62034. */
  62035. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62036. /**
  62037. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62038. * @param x x value multiply with
  62039. * @param y y value multiply with
  62040. * @param z z value multiply with
  62041. * @param w w value multiply with
  62042. * @returns resulting new vector
  62043. */
  62044. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62045. /**
  62046. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62047. * @param otherVector vector to devide with
  62048. * @returns resulting new vector
  62049. */
  62050. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62051. /**
  62052. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62053. * @param otherVector vector to devide with
  62054. * @param result vector to store the result
  62055. * @returns the current Vector4.
  62056. */
  62057. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62058. /**
  62059. * Divides the current Vector3 coordinates by the given ones.
  62060. * @param otherVector vector to devide with
  62061. * @returns the updated Vector3.
  62062. */
  62063. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62064. /**
  62065. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62066. * @param other defines the second operand
  62067. * @returns the current updated Vector4
  62068. */
  62069. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62070. /**
  62071. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62072. * @param other defines the second operand
  62073. * @returns the current updated Vector4
  62074. */
  62075. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62076. /**
  62077. * Gets a new Vector4 from current Vector4 floored values
  62078. * @returns a new Vector4
  62079. */
  62080. floor(): Vector4;
  62081. /**
  62082. * Gets a new Vector4 from current Vector3 floored values
  62083. * @returns a new Vector4
  62084. */
  62085. fract(): Vector4;
  62086. /**
  62087. * Returns the Vector4 length (float).
  62088. * @returns the length
  62089. */
  62090. length(): number;
  62091. /**
  62092. * Returns the Vector4 squared length (float).
  62093. * @returns the length squared
  62094. */
  62095. lengthSquared(): number;
  62096. /**
  62097. * Normalizes in place the Vector4.
  62098. * @returns the updated Vector4.
  62099. */
  62100. normalize(): Vector4;
  62101. /**
  62102. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62103. * @returns this converted to a new vector3
  62104. */
  62105. toVector3(): Vector3;
  62106. /**
  62107. * Returns a new Vector4 copied from the current one.
  62108. * @returns the new cloned vector
  62109. */
  62110. clone(): Vector4;
  62111. /**
  62112. * Updates the current Vector4 with the given one coordinates.
  62113. * @param source the source vector to copy from
  62114. * @returns the updated Vector4.
  62115. */
  62116. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62117. /**
  62118. * Updates the current Vector4 coordinates with the given floats.
  62119. * @param x float to copy from
  62120. * @param y float to copy from
  62121. * @param z float to copy from
  62122. * @param w float to copy from
  62123. * @returns the updated Vector4.
  62124. */
  62125. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62126. /**
  62127. * Updates the current Vector4 coordinates with the given floats.
  62128. * @param x float to set from
  62129. * @param y float to set from
  62130. * @param z float to set from
  62131. * @param w float to set from
  62132. * @returns the updated Vector4.
  62133. */
  62134. set(x: number, y: number, z: number, w: number): Vector4;
  62135. /**
  62136. * Copies the given float to the current Vector3 coordinates
  62137. * @param v defines the x, y, z and w coordinates of the operand
  62138. * @returns the current updated Vector3
  62139. */
  62140. setAll(v: number): Vector4;
  62141. /**
  62142. * Returns a new Vector4 set from the starting index of the given array.
  62143. * @param array the array to pull values from
  62144. * @param offset the offset into the array to start at
  62145. * @returns the new vector
  62146. */
  62147. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62148. /**
  62149. * Updates the given vector "result" from the starting index of the given array.
  62150. * @param array the array to pull values from
  62151. * @param offset the offset into the array to start at
  62152. * @param result the vector to store the result in
  62153. */
  62154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62155. /**
  62156. * Updates the given vector "result" from the starting index of the given Float32Array.
  62157. * @param array the array to pull values from
  62158. * @param offset the offset into the array to start at
  62159. * @param result the vector to store the result in
  62160. */
  62161. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62162. /**
  62163. * Updates the given vector "result" coordinates from the given floats.
  62164. * @param x float to set from
  62165. * @param y float to set from
  62166. * @param z float to set from
  62167. * @param w float to set from
  62168. * @param result the vector to the floats in
  62169. */
  62170. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62171. /**
  62172. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62173. * @returns the new vector
  62174. */
  62175. static Zero(): Vector4;
  62176. /**
  62177. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62178. * @returns the new vector
  62179. */
  62180. static One(): Vector4;
  62181. /**
  62182. * Returns a new normalized Vector4 from the given one.
  62183. * @param vector the vector to normalize
  62184. * @returns the vector
  62185. */
  62186. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62187. /**
  62188. * Updates the given vector "result" from the normalization of the given one.
  62189. * @param vector the vector to normalize
  62190. * @param result the vector to store the result in
  62191. */
  62192. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62193. /**
  62194. * Returns a vector with the minimum values from the left and right vectors
  62195. * @param left left vector to minimize
  62196. * @param right right vector to minimize
  62197. * @returns a new vector with the minimum of the left and right vector values
  62198. */
  62199. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62200. /**
  62201. * Returns a vector with the maximum values from the left and right vectors
  62202. * @param left left vector to maximize
  62203. * @param right right vector to maximize
  62204. * @returns a new vector with the maximum of the left and right vector values
  62205. */
  62206. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62207. /**
  62208. * Returns the distance (float) between the vectors "value1" and "value2".
  62209. * @param value1 value to calulate the distance between
  62210. * @param value2 value to calulate the distance between
  62211. * @return the distance between the two vectors
  62212. */
  62213. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62214. /**
  62215. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62216. * @param value1 value to calulate the distance between
  62217. * @param value2 value to calulate the distance between
  62218. * @return the distance between the two vectors squared
  62219. */
  62220. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62221. /**
  62222. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62223. * @param value1 value to calulate the center between
  62224. * @param value2 value to calulate the center between
  62225. * @return the center between the two vectors
  62226. */
  62227. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62228. /**
  62229. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62230. * This methods computes transformed normalized direction vectors only.
  62231. * @param vector the vector to transform
  62232. * @param transformation the transformation matrix to apply
  62233. * @returns the new vector
  62234. */
  62235. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62236. /**
  62237. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62238. * This methods computes transformed normalized direction vectors only.
  62239. * @param vector the vector to transform
  62240. * @param transformation the transformation matrix to apply
  62241. * @param result the vector to store the result in
  62242. */
  62243. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62244. /**
  62245. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62246. * This methods computes transformed normalized direction vectors only.
  62247. * @param x value to transform
  62248. * @param y value to transform
  62249. * @param z value to transform
  62250. * @param w value to transform
  62251. * @param transformation the transformation matrix to apply
  62252. * @param result the vector to store the results in
  62253. */
  62254. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62255. /**
  62256. * Creates a new Vector4 from a Vector3
  62257. * @param source defines the source data
  62258. * @param w defines the 4th component (default is 0)
  62259. * @returns a new Vector4
  62260. */
  62261. static FromVector3(source: Vector3, w?: number): Vector4;
  62262. }
  62263. /**
  62264. * Interface for the size containing width and height
  62265. */
  62266. export interface ISize {
  62267. /**
  62268. * Width
  62269. */
  62270. width: number;
  62271. /**
  62272. * Heighht
  62273. */
  62274. height: number;
  62275. }
  62276. /**
  62277. * Size containing widht and height
  62278. */
  62279. export class Size implements ISize {
  62280. /**
  62281. * Width
  62282. */
  62283. width: number;
  62284. /**
  62285. * Height
  62286. */
  62287. height: number;
  62288. /**
  62289. * Creates a Size object from the given width and height (floats).
  62290. * @param width width of the new size
  62291. * @param height height of the new size
  62292. */
  62293. constructor(width: number, height: number);
  62294. /**
  62295. * Returns a string with the Size width and height
  62296. * @returns a string with the Size width and height
  62297. */
  62298. toString(): string;
  62299. /**
  62300. * "Size"
  62301. * @returns the string "Size"
  62302. */
  62303. getClassName(): string;
  62304. /**
  62305. * Returns the Size hash code.
  62306. * @returns a hash code for a unique width and height
  62307. */
  62308. getHashCode(): number;
  62309. /**
  62310. * Updates the current size from the given one.
  62311. * @param src the given size
  62312. */
  62313. copyFrom(src: Size): void;
  62314. /**
  62315. * Updates in place the current Size from the given floats.
  62316. * @param width width of the new size
  62317. * @param height height of the new size
  62318. * @returns the updated Size.
  62319. */
  62320. copyFromFloats(width: number, height: number): Size;
  62321. /**
  62322. * Updates in place the current Size from the given floats.
  62323. * @param width width to set
  62324. * @param height height to set
  62325. * @returns the updated Size.
  62326. */
  62327. set(width: number, height: number): Size;
  62328. /**
  62329. * Multiplies the width and height by numbers
  62330. * @param w factor to multiple the width by
  62331. * @param h factor to multiple the height by
  62332. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62333. */
  62334. multiplyByFloats(w: number, h: number): Size;
  62335. /**
  62336. * Clones the size
  62337. * @returns a new Size copied from the given one.
  62338. */
  62339. clone(): Size;
  62340. /**
  62341. * True if the current Size and the given one width and height are strictly equal.
  62342. * @param other the other size to compare against
  62343. * @returns True if the current Size and the given one width and height are strictly equal.
  62344. */
  62345. equals(other: Size): boolean;
  62346. /**
  62347. * The surface of the Size : width * height (float).
  62348. */
  62349. readonly surface: number;
  62350. /**
  62351. * Create a new size of zero
  62352. * @returns a new Size set to (0.0, 0.0)
  62353. */
  62354. static Zero(): Size;
  62355. /**
  62356. * Sums the width and height of two sizes
  62357. * @param otherSize size to add to this size
  62358. * @returns a new Size set as the addition result of the current Size and the given one.
  62359. */
  62360. add(otherSize: Size): Size;
  62361. /**
  62362. * Subtracts the width and height of two
  62363. * @param otherSize size to subtract to this size
  62364. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62365. */
  62366. subtract(otherSize: Size): Size;
  62367. /**
  62368. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62369. * @param start starting size to lerp between
  62370. * @param end end size to lerp between
  62371. * @param amount amount to lerp between the start and end values
  62372. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62373. */
  62374. static Lerp(start: Size, end: Size, amount: number): Size;
  62375. }
  62376. /**
  62377. * Class used to store quaternion data
  62378. * @see https://en.wikipedia.org/wiki/Quaternion
  62379. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62380. */
  62381. export class Quaternion {
  62382. /** defines the first component (0 by default) */
  62383. x: number;
  62384. /** defines the second component (0 by default) */
  62385. y: number;
  62386. /** defines the third component (0 by default) */
  62387. z: number;
  62388. /** defines the fourth component (1.0 by default) */
  62389. w: number;
  62390. /**
  62391. * Creates a new Quaternion from the given floats
  62392. * @param x defines the first component (0 by default)
  62393. * @param y defines the second component (0 by default)
  62394. * @param z defines the third component (0 by default)
  62395. * @param w defines the fourth component (1.0 by default)
  62396. */
  62397. constructor(
  62398. /** defines the first component (0 by default) */
  62399. x?: number,
  62400. /** defines the second component (0 by default) */
  62401. y?: number,
  62402. /** defines the third component (0 by default) */
  62403. z?: number,
  62404. /** defines the fourth component (1.0 by default) */
  62405. w?: number);
  62406. /**
  62407. * Gets a string representation for the current quaternion
  62408. * @returns a string with the Quaternion coordinates
  62409. */
  62410. toString(): string;
  62411. /**
  62412. * Gets the class name of the quaternion
  62413. * @returns the string "Quaternion"
  62414. */
  62415. getClassName(): string;
  62416. /**
  62417. * Gets a hash code for this quaternion
  62418. * @returns the quaternion hash code
  62419. */
  62420. getHashCode(): number;
  62421. /**
  62422. * Copy the quaternion to an array
  62423. * @returns a new array populated with 4 elements from the quaternion coordinates
  62424. */
  62425. asArray(): number[];
  62426. /**
  62427. * Check if two quaternions are equals
  62428. * @param otherQuaternion defines the second operand
  62429. * @return true if the current quaternion and the given one coordinates are strictly equals
  62430. */
  62431. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62432. /**
  62433. * Clone the current quaternion
  62434. * @returns a new quaternion copied from the current one
  62435. */
  62436. clone(): Quaternion;
  62437. /**
  62438. * Copy a quaternion to the current one
  62439. * @param other defines the other quaternion
  62440. * @returns the updated current quaternion
  62441. */
  62442. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62443. /**
  62444. * Updates the current quaternion with the given float coordinates
  62445. * @param x defines the x coordinate
  62446. * @param y defines the y coordinate
  62447. * @param z defines the z coordinate
  62448. * @param w defines the w coordinate
  62449. * @returns the updated current quaternion
  62450. */
  62451. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62452. /**
  62453. * Updates the current quaternion from the given float coordinates
  62454. * @param x defines the x coordinate
  62455. * @param y defines the y coordinate
  62456. * @param z defines the z coordinate
  62457. * @param w defines the w coordinate
  62458. * @returns the updated current quaternion
  62459. */
  62460. set(x: number, y: number, z: number, w: number): Quaternion;
  62461. /**
  62462. * Adds two quaternions
  62463. * @param other defines the second operand
  62464. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62465. */
  62466. add(other: DeepImmutable<Quaternion>): Quaternion;
  62467. /**
  62468. * Add a quaternion to the current one
  62469. * @param other defines the quaternion to add
  62470. * @returns the current quaternion
  62471. */
  62472. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62473. /**
  62474. * Subtract two quaternions
  62475. * @param other defines the second operand
  62476. * @returns a new quaternion as the subtraction result of the given one from the current one
  62477. */
  62478. subtract(other: Quaternion): Quaternion;
  62479. /**
  62480. * Multiplies the current quaternion by a scale factor
  62481. * @param value defines the scale factor
  62482. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62483. */
  62484. scale(value: number): Quaternion;
  62485. /**
  62486. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62487. * @param scale defines the scale factor
  62488. * @param result defines the Quaternion object where to store the result
  62489. * @returns the unmodified current quaternion
  62490. */
  62491. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62492. /**
  62493. * Multiplies in place the current quaternion by a scale factor
  62494. * @param value defines the scale factor
  62495. * @returns the current modified quaternion
  62496. */
  62497. scaleInPlace(value: number): Quaternion;
  62498. /**
  62499. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62500. * @param scale defines the scale factor
  62501. * @param result defines the Quaternion object where to store the result
  62502. * @returns the unmodified current quaternion
  62503. */
  62504. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62505. /**
  62506. * Multiplies two quaternions
  62507. * @param q1 defines the second operand
  62508. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62509. */
  62510. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62511. /**
  62512. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62513. * @param q1 defines the second operand
  62514. * @param result defines the target quaternion
  62515. * @returns the current quaternion
  62516. */
  62517. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62518. /**
  62519. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62520. * @param q1 defines the second operand
  62521. * @returns the currentupdated quaternion
  62522. */
  62523. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62524. /**
  62525. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62526. * @param ref defines the target quaternion
  62527. * @returns the current quaternion
  62528. */
  62529. conjugateToRef(ref: Quaternion): Quaternion;
  62530. /**
  62531. * Conjugates in place (1-q) the current quaternion
  62532. * @returns the current updated quaternion
  62533. */
  62534. conjugateInPlace(): Quaternion;
  62535. /**
  62536. * Conjugates in place (1-q) the current quaternion
  62537. * @returns a new quaternion
  62538. */
  62539. conjugate(): Quaternion;
  62540. /**
  62541. * Gets length of current quaternion
  62542. * @returns the quaternion length (float)
  62543. */
  62544. length(): number;
  62545. /**
  62546. * Normalize in place the current quaternion
  62547. * @returns the current updated quaternion
  62548. */
  62549. normalize(): Quaternion;
  62550. /**
  62551. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62552. * @param order is a reserved parameter and is ignore for now
  62553. * @returns a new Vector3 containing the Euler angles
  62554. */
  62555. toEulerAngles(order?: string): Vector3;
  62556. /**
  62557. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62558. * @param result defines the vector which will be filled with the Euler angles
  62559. * @param order is a reserved parameter and is ignore for now
  62560. * @returns the current unchanged quaternion
  62561. */
  62562. toEulerAnglesToRef(result: Vector3): Quaternion;
  62563. /**
  62564. * Updates the given rotation matrix with the current quaternion values
  62565. * @param result defines the target matrix
  62566. * @returns the current unchanged quaternion
  62567. */
  62568. toRotationMatrix(result: Matrix): Quaternion;
  62569. /**
  62570. * Updates the current quaternion from the given rotation matrix values
  62571. * @param matrix defines the source matrix
  62572. * @returns the current updated quaternion
  62573. */
  62574. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62575. /**
  62576. * Creates a new quaternion from a rotation matrix
  62577. * @param matrix defines the source matrix
  62578. * @returns a new quaternion created from the given rotation matrix values
  62579. */
  62580. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62581. /**
  62582. * Updates the given quaternion with the given rotation matrix values
  62583. * @param matrix defines the source matrix
  62584. * @param result defines the target quaternion
  62585. */
  62586. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62587. /**
  62588. * Returns the dot product (float) between the quaternions "left" and "right"
  62589. * @param left defines the left operand
  62590. * @param right defines the right operand
  62591. * @returns the dot product
  62592. */
  62593. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62594. /**
  62595. * Checks if the two quaternions are close to each other
  62596. * @param quat0 defines the first quaternion to check
  62597. * @param quat1 defines the second quaternion to check
  62598. * @returns true if the two quaternions are close to each other
  62599. */
  62600. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62601. /**
  62602. * Creates an empty quaternion
  62603. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62604. */
  62605. static Zero(): Quaternion;
  62606. /**
  62607. * Inverse a given quaternion
  62608. * @param q defines the source quaternion
  62609. * @returns a new quaternion as the inverted current quaternion
  62610. */
  62611. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62612. /**
  62613. * Inverse a given quaternion
  62614. * @param q defines the source quaternion
  62615. * @param result the quaternion the result will be stored in
  62616. * @returns the result quaternion
  62617. */
  62618. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62619. /**
  62620. * Creates an identity quaternion
  62621. * @returns the identity quaternion
  62622. */
  62623. static Identity(): Quaternion;
  62624. /**
  62625. * Gets a boolean indicating if the given quaternion is identity
  62626. * @param quaternion defines the quaternion to check
  62627. * @returns true if the quaternion is identity
  62628. */
  62629. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62630. /**
  62631. * Creates a quaternion from a rotation around an axis
  62632. * @param axis defines the axis to use
  62633. * @param angle defines the angle to use
  62634. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62635. */
  62636. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62637. /**
  62638. * Creates a rotation around an axis and stores it into the given quaternion
  62639. * @param axis defines the axis to use
  62640. * @param angle defines the angle to use
  62641. * @param result defines the target quaternion
  62642. * @returns the target quaternion
  62643. */
  62644. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62645. /**
  62646. * Creates a new quaternion from data stored into an array
  62647. * @param array defines the data source
  62648. * @param offset defines the offset in the source array where the data starts
  62649. * @returns a new quaternion
  62650. */
  62651. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62652. /**
  62653. * Create a quaternion from Euler rotation angles
  62654. * @param x Pitch
  62655. * @param y Yaw
  62656. * @param z Roll
  62657. * @returns the new Quaternion
  62658. */
  62659. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62660. /**
  62661. * Updates a quaternion from Euler rotation angles
  62662. * @param x Pitch
  62663. * @param y Yaw
  62664. * @param z Roll
  62665. * @param result the quaternion to store the result
  62666. * @returns the updated quaternion
  62667. */
  62668. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62669. /**
  62670. * Create a quaternion from Euler rotation vector
  62671. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62672. * @returns the new Quaternion
  62673. */
  62674. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62675. /**
  62676. * Updates a quaternion from Euler rotation vector
  62677. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62678. * @param result the quaternion to store the result
  62679. * @returns the updated quaternion
  62680. */
  62681. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62682. /**
  62683. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62684. * @param yaw defines the rotation around Y axis
  62685. * @param pitch defines the rotation around X axis
  62686. * @param roll defines the rotation around Z axis
  62687. * @returns the new quaternion
  62688. */
  62689. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62690. /**
  62691. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62692. * @param yaw defines the rotation around Y axis
  62693. * @param pitch defines the rotation around X axis
  62694. * @param roll defines the rotation around Z axis
  62695. * @param result defines the target quaternion
  62696. */
  62697. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62698. /**
  62699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62700. * @param alpha defines the rotation around first axis
  62701. * @param beta defines the rotation around second axis
  62702. * @param gamma defines the rotation around third axis
  62703. * @returns the new quaternion
  62704. */
  62705. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62706. /**
  62707. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62708. * @param alpha defines the rotation around first axis
  62709. * @param beta defines the rotation around second axis
  62710. * @param gamma defines the rotation around third axis
  62711. * @param result defines the target quaternion
  62712. */
  62713. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62714. /**
  62715. * 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)
  62716. * @param axis1 defines the first axis
  62717. * @param axis2 defines the second axis
  62718. * @param axis3 defines the third axis
  62719. * @returns the new quaternion
  62720. */
  62721. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62722. /**
  62723. * 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
  62724. * @param axis1 defines the first axis
  62725. * @param axis2 defines the second axis
  62726. * @param axis3 defines the third axis
  62727. * @param ref defines the target quaternion
  62728. */
  62729. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62730. /**
  62731. * Interpolates between two quaternions
  62732. * @param left defines first quaternion
  62733. * @param right defines second quaternion
  62734. * @param amount defines the gradient to use
  62735. * @returns the new interpolated quaternion
  62736. */
  62737. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62738. /**
  62739. * Interpolates between two quaternions and stores it into a target quaternion
  62740. * @param left defines first quaternion
  62741. * @param right defines second quaternion
  62742. * @param amount defines the gradient to use
  62743. * @param result defines the target quaternion
  62744. */
  62745. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62746. /**
  62747. * Interpolate between two quaternions using Hermite interpolation
  62748. * @param value1 defines first quaternion
  62749. * @param tangent1 defines the incoming tangent
  62750. * @param value2 defines second quaternion
  62751. * @param tangent2 defines the outgoing tangent
  62752. * @param amount defines the target quaternion
  62753. * @returns the new interpolated quaternion
  62754. */
  62755. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62756. }
  62757. /**
  62758. * Class used to store matrix data (4x4)
  62759. */
  62760. export class Matrix {
  62761. private static _updateFlagSeed;
  62762. private static _identityReadOnly;
  62763. private _isIdentity;
  62764. private _isIdentityDirty;
  62765. private _isIdentity3x2;
  62766. private _isIdentity3x2Dirty;
  62767. /**
  62768. * Gets the update flag of the matrix which is an unique number for the matrix.
  62769. * It will be incremented every time the matrix data change.
  62770. * You can use it to speed the comparison between two versions of the same matrix.
  62771. */
  62772. updateFlag: number;
  62773. private readonly _m;
  62774. /**
  62775. * Gets the internal data of the matrix
  62776. */
  62777. readonly m: DeepImmutable<Float32Array>;
  62778. /** @hidden */
  62779. _markAsUpdated(): void;
  62780. /** @hidden */
  62781. private _updateIdentityStatus;
  62782. /**
  62783. * Creates an empty matrix (filled with zeros)
  62784. */
  62785. constructor();
  62786. /**
  62787. * Check if the current matrix is identity
  62788. * @returns true is the matrix is the identity matrix
  62789. */
  62790. isIdentity(): boolean;
  62791. /**
  62792. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62793. * @returns true is the matrix is the identity matrix
  62794. */
  62795. isIdentityAs3x2(): boolean;
  62796. /**
  62797. * Gets the determinant of the matrix
  62798. * @returns the matrix determinant
  62799. */
  62800. determinant(): number;
  62801. /**
  62802. * Returns the matrix as a Float32Array
  62803. * @returns the matrix underlying array
  62804. */
  62805. toArray(): DeepImmutable<Float32Array>;
  62806. /**
  62807. * Returns the matrix as a Float32Array
  62808. * @returns the matrix underlying array.
  62809. */
  62810. asArray(): DeepImmutable<Float32Array>;
  62811. /**
  62812. * Inverts the current matrix in place
  62813. * @returns the current inverted matrix
  62814. */
  62815. invert(): Matrix;
  62816. /**
  62817. * Sets all the matrix elements to zero
  62818. * @returns the current matrix
  62819. */
  62820. reset(): Matrix;
  62821. /**
  62822. * Adds the current matrix with a second one
  62823. * @param other defines the matrix to add
  62824. * @returns a new matrix as the addition of the current matrix and the given one
  62825. */
  62826. add(other: DeepImmutable<Matrix>): Matrix;
  62827. /**
  62828. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62829. * @param other defines the matrix to add
  62830. * @param result defines the target matrix
  62831. * @returns the current matrix
  62832. */
  62833. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62834. /**
  62835. * Adds in place the given matrix to the current matrix
  62836. * @param other defines the second operand
  62837. * @returns the current updated matrix
  62838. */
  62839. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62840. /**
  62841. * Sets the given matrix to the current inverted Matrix
  62842. * @param other defines the target matrix
  62843. * @returns the unmodified current matrix
  62844. */
  62845. invertToRef(other: Matrix): Matrix;
  62846. /**
  62847. * add a value at the specified position in the current Matrix
  62848. * @param index the index of the value within the matrix. between 0 and 15.
  62849. * @param value the value to be added
  62850. * @returns the current updated matrix
  62851. */
  62852. addAtIndex(index: number, value: number): Matrix;
  62853. /**
  62854. * mutiply the specified position in the current Matrix by a value
  62855. * @param index the index of the value within the matrix. between 0 and 15.
  62856. * @param value the value to be added
  62857. * @returns the current updated matrix
  62858. */
  62859. multiplyAtIndex(index: number, value: number): Matrix;
  62860. /**
  62861. * Inserts the translation vector (using 3 floats) in the current matrix
  62862. * @param x defines the 1st component of the translation
  62863. * @param y defines the 2nd component of the translation
  62864. * @param z defines the 3rd component of the translation
  62865. * @returns the current updated matrix
  62866. */
  62867. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62868. /**
  62869. * Adds the translation vector (using 3 floats) in the current matrix
  62870. * @param x defines the 1st component of the translation
  62871. * @param y defines the 2nd component of the translation
  62872. * @param z defines the 3rd component of the translation
  62873. * @returns the current updated matrix
  62874. */
  62875. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62876. /**
  62877. * Inserts the translation vector in the current matrix
  62878. * @param vector3 defines the translation to insert
  62879. * @returns the current updated matrix
  62880. */
  62881. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62882. /**
  62883. * Gets the translation value of the current matrix
  62884. * @returns a new Vector3 as the extracted translation from the matrix
  62885. */
  62886. getTranslation(): Vector3;
  62887. /**
  62888. * Fill a Vector3 with the extracted translation from the matrix
  62889. * @param result defines the Vector3 where to store the translation
  62890. * @returns the current matrix
  62891. */
  62892. getTranslationToRef(result: Vector3): Matrix;
  62893. /**
  62894. * Remove rotation and scaling part from the matrix
  62895. * @returns the updated matrix
  62896. */
  62897. removeRotationAndScaling(): Matrix;
  62898. /**
  62899. * Multiply two matrices
  62900. * @param other defines the second operand
  62901. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62902. */
  62903. multiply(other: DeepImmutable<Matrix>): Matrix;
  62904. /**
  62905. * Copy the current matrix from the given one
  62906. * @param other defines the source matrix
  62907. * @returns the current updated matrix
  62908. */
  62909. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62910. /**
  62911. * Populates the given array from the starting index with the current matrix values
  62912. * @param array defines the target array
  62913. * @param offset defines the offset in the target array where to start storing values
  62914. * @returns the current matrix
  62915. */
  62916. copyToArray(array: Float32Array, offset?: number): Matrix;
  62917. /**
  62918. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62919. * @param other defines the second operand
  62920. * @param result defines the matrix where to store the multiplication
  62921. * @returns the current matrix
  62922. */
  62923. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62924. /**
  62925. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62926. * @param other defines the second operand
  62927. * @param result defines the array where to store the multiplication
  62928. * @param offset defines the offset in the target array where to start storing values
  62929. * @returns the current matrix
  62930. */
  62931. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62932. /**
  62933. * Check equality between this matrix and a second one
  62934. * @param value defines the second matrix to compare
  62935. * @returns true is the current matrix and the given one values are strictly equal
  62936. */
  62937. equals(value: DeepImmutable<Matrix>): boolean;
  62938. /**
  62939. * Clone the current matrix
  62940. * @returns a new matrix from the current matrix
  62941. */
  62942. clone(): Matrix;
  62943. /**
  62944. * Returns the name of the current matrix class
  62945. * @returns the string "Matrix"
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the hash code of the current matrix
  62950. * @returns the hash code
  62951. */
  62952. getHashCode(): number;
  62953. /**
  62954. * Decomposes the current Matrix into a translation, rotation and scaling components
  62955. * @param scale defines the scale vector3 given as a reference to update
  62956. * @param rotation defines the rotation quaternion given as a reference to update
  62957. * @param translation defines the translation vector3 given as a reference to update
  62958. * @returns true if operation was successful
  62959. */
  62960. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62961. /**
  62962. * Gets specific row of the matrix
  62963. * @param index defines the number of the row to get
  62964. * @returns the index-th row of the current matrix as a new Vector4
  62965. */
  62966. getRow(index: number): Nullable<Vector4>;
  62967. /**
  62968. * Sets the index-th row of the current matrix to the vector4 values
  62969. * @param index defines the number of the row to set
  62970. * @param row defines the target vector4
  62971. * @returns the updated current matrix
  62972. */
  62973. setRow(index: number, row: Vector4): Matrix;
  62974. /**
  62975. * Compute the transpose of the matrix
  62976. * @returns the new transposed matrix
  62977. */
  62978. transpose(): Matrix;
  62979. /**
  62980. * Compute the transpose of the matrix and store it in a given matrix
  62981. * @param result defines the target matrix
  62982. * @returns the current matrix
  62983. */
  62984. transposeToRef(result: Matrix): Matrix;
  62985. /**
  62986. * Sets the index-th row of the current matrix with the given 4 x float values
  62987. * @param index defines the row index
  62988. * @param x defines the x component to set
  62989. * @param y defines the y component to set
  62990. * @param z defines the z component to set
  62991. * @param w defines the w component to set
  62992. * @returns the updated current matrix
  62993. */
  62994. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62995. /**
  62996. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62997. * @param scale defines the scale factor
  62998. * @returns a new matrix
  62999. */
  63000. scale(scale: number): Matrix;
  63001. /**
  63002. * Scale the current matrix values by a factor to a given result matrix
  63003. * @param scale defines the scale factor
  63004. * @param result defines the matrix to store the result
  63005. * @returns the current matrix
  63006. */
  63007. scaleToRef(scale: number, result: Matrix): Matrix;
  63008. /**
  63009. * Scale the current matrix values by a factor and add the result to a given matrix
  63010. * @param scale defines the scale factor
  63011. * @param result defines the Matrix to store the result
  63012. * @returns the current matrix
  63013. */
  63014. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63015. /**
  63016. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63017. * @param ref matrix to store the result
  63018. */
  63019. toNormalMatrix(ref: Matrix): void;
  63020. /**
  63021. * Gets only rotation part of the current matrix
  63022. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63023. */
  63024. getRotationMatrix(): Matrix;
  63025. /**
  63026. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63027. * @param result defines the target matrix to store data to
  63028. * @returns the current matrix
  63029. */
  63030. getRotationMatrixToRef(result: Matrix): Matrix;
  63031. /**
  63032. * Toggles model matrix from being right handed to left handed in place and vice versa
  63033. */
  63034. toggleModelMatrixHandInPlace(): void;
  63035. /**
  63036. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63037. */
  63038. toggleProjectionMatrixHandInPlace(): void;
  63039. /**
  63040. * Creates a matrix from an array
  63041. * @param array defines the source array
  63042. * @param offset defines an offset in the source array
  63043. * @returns a new Matrix set from the starting index of the given array
  63044. */
  63045. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63046. /**
  63047. * Copy the content of an array into a given matrix
  63048. * @param array defines the source array
  63049. * @param offset defines an offset in the source array
  63050. * @param result defines the target matrix
  63051. */
  63052. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63053. /**
  63054. * Stores an array into a matrix after having multiplied each component by a given factor
  63055. * @param array defines the source array
  63056. * @param offset defines the offset in the source array
  63057. * @param scale defines the scaling factor
  63058. * @param result defines the target matrix
  63059. */
  63060. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63061. /**
  63062. * Gets an identity matrix that must not be updated
  63063. */
  63064. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63065. /**
  63066. * Stores a list of values (16) inside a given matrix
  63067. * @param initialM11 defines 1st value of 1st row
  63068. * @param initialM12 defines 2nd value of 1st row
  63069. * @param initialM13 defines 3rd value of 1st row
  63070. * @param initialM14 defines 4th value of 1st row
  63071. * @param initialM21 defines 1st value of 2nd row
  63072. * @param initialM22 defines 2nd value of 2nd row
  63073. * @param initialM23 defines 3rd value of 2nd row
  63074. * @param initialM24 defines 4th value of 2nd row
  63075. * @param initialM31 defines 1st value of 3rd row
  63076. * @param initialM32 defines 2nd value of 3rd row
  63077. * @param initialM33 defines 3rd value of 3rd row
  63078. * @param initialM34 defines 4th value of 3rd row
  63079. * @param initialM41 defines 1st value of 4th row
  63080. * @param initialM42 defines 2nd value of 4th row
  63081. * @param initialM43 defines 3rd value of 4th row
  63082. * @param initialM44 defines 4th value of 4th row
  63083. * @param result defines the target matrix
  63084. */
  63085. 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;
  63086. /**
  63087. * Creates new matrix from a list of values (16)
  63088. * @param initialM11 defines 1st value of 1st row
  63089. * @param initialM12 defines 2nd value of 1st row
  63090. * @param initialM13 defines 3rd value of 1st row
  63091. * @param initialM14 defines 4th value of 1st row
  63092. * @param initialM21 defines 1st value of 2nd row
  63093. * @param initialM22 defines 2nd value of 2nd row
  63094. * @param initialM23 defines 3rd value of 2nd row
  63095. * @param initialM24 defines 4th value of 2nd row
  63096. * @param initialM31 defines 1st value of 3rd row
  63097. * @param initialM32 defines 2nd value of 3rd row
  63098. * @param initialM33 defines 3rd value of 3rd row
  63099. * @param initialM34 defines 4th value of 3rd row
  63100. * @param initialM41 defines 1st value of 4th row
  63101. * @param initialM42 defines 2nd value of 4th row
  63102. * @param initialM43 defines 3rd value of 4th row
  63103. * @param initialM44 defines 4th value of 4th row
  63104. * @returns the new matrix
  63105. */
  63106. 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;
  63107. /**
  63108. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63109. * @param scale defines the scale vector3
  63110. * @param rotation defines the rotation quaternion
  63111. * @param translation defines the translation vector3
  63112. * @returns a new matrix
  63113. */
  63114. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63115. /**
  63116. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63117. * @param scale defines the scale vector3
  63118. * @param rotation defines the rotation quaternion
  63119. * @param translation defines the translation vector3
  63120. * @param result defines the target matrix
  63121. */
  63122. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63123. /**
  63124. * Creates a new identity matrix
  63125. * @returns a new identity matrix
  63126. */
  63127. static Identity(): Matrix;
  63128. /**
  63129. * Creates a new identity matrix and stores the result in a given matrix
  63130. * @param result defines the target matrix
  63131. */
  63132. static IdentityToRef(result: Matrix): void;
  63133. /**
  63134. * Creates a new zero matrix
  63135. * @returns a new zero matrix
  63136. */
  63137. static Zero(): Matrix;
  63138. /**
  63139. * Creates a new rotation matrix for "angle" radians around the X axis
  63140. * @param angle defines the angle (in radians) to use
  63141. * @return the new matrix
  63142. */
  63143. static RotationX(angle: number): Matrix;
  63144. /**
  63145. * Creates a new matrix as the invert of a given matrix
  63146. * @param source defines the source matrix
  63147. * @returns the new matrix
  63148. */
  63149. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63150. /**
  63151. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63152. * @param angle defines the angle (in radians) to use
  63153. * @param result defines the target matrix
  63154. */
  63155. static RotationXToRef(angle: number, result: Matrix): void;
  63156. /**
  63157. * Creates a new rotation matrix for "angle" radians around the Y axis
  63158. * @param angle defines the angle (in radians) to use
  63159. * @return the new matrix
  63160. */
  63161. static RotationY(angle: number): Matrix;
  63162. /**
  63163. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63164. * @param angle defines the angle (in radians) to use
  63165. * @param result defines the target matrix
  63166. */
  63167. static RotationYToRef(angle: number, result: Matrix): void;
  63168. /**
  63169. * Creates a new rotation matrix for "angle" radians around the Z axis
  63170. * @param angle defines the angle (in radians) to use
  63171. * @return the new matrix
  63172. */
  63173. static RotationZ(angle: number): Matrix;
  63174. /**
  63175. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63176. * @param angle defines the angle (in radians) to use
  63177. * @param result defines the target matrix
  63178. */
  63179. static RotationZToRef(angle: number, result: Matrix): void;
  63180. /**
  63181. * Creates a new rotation matrix for "angle" radians around the given axis
  63182. * @param axis defines the axis to use
  63183. * @param angle defines the angle (in radians) to use
  63184. * @return the new matrix
  63185. */
  63186. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63187. /**
  63188. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63189. * @param axis defines the axis to use
  63190. * @param angle defines the angle (in radians) to use
  63191. * @param result defines the target matrix
  63192. */
  63193. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63194. /**
  63195. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63196. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63197. * @param from defines the vector to align
  63198. * @param to defines the vector to align to
  63199. * @param result defines the target matrix
  63200. */
  63201. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63202. /**
  63203. * Creates a rotation matrix
  63204. * @param yaw defines the yaw angle in radians (Y axis)
  63205. * @param pitch defines the pitch angle in radians (X axis)
  63206. * @param roll defines the roll angle in radians (X axis)
  63207. * @returns the new rotation matrix
  63208. */
  63209. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63210. /**
  63211. * Creates a rotation matrix and stores it in a given matrix
  63212. * @param yaw defines the yaw angle in radians (Y axis)
  63213. * @param pitch defines the pitch angle in radians (X axis)
  63214. * @param roll defines the roll angle in radians (X axis)
  63215. * @param result defines the target matrix
  63216. */
  63217. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63218. /**
  63219. * Creates a scaling matrix
  63220. * @param x defines the scale factor on X axis
  63221. * @param y defines the scale factor on Y axis
  63222. * @param z defines the scale factor on Z axis
  63223. * @returns the new matrix
  63224. */
  63225. static Scaling(x: number, y: number, z: number): Matrix;
  63226. /**
  63227. * Creates a scaling matrix and stores it in a given matrix
  63228. * @param x defines the scale factor on X axis
  63229. * @param y defines the scale factor on Y axis
  63230. * @param z defines the scale factor on Z axis
  63231. * @param result defines the target matrix
  63232. */
  63233. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63234. /**
  63235. * Creates a translation matrix
  63236. * @param x defines the translation on X axis
  63237. * @param y defines the translation on Y axis
  63238. * @param z defines the translationon Z axis
  63239. * @returns the new matrix
  63240. */
  63241. static Translation(x: number, y: number, z: number): Matrix;
  63242. /**
  63243. * Creates a translation matrix and stores it in a given matrix
  63244. * @param x defines the translation on X axis
  63245. * @param y defines the translation on Y axis
  63246. * @param z defines the translationon Z axis
  63247. * @param result defines the target matrix
  63248. */
  63249. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63250. /**
  63251. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63252. * @param startValue defines the start value
  63253. * @param endValue defines the end value
  63254. * @param gradient defines the gradient factor
  63255. * @returns the new matrix
  63256. */
  63257. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63258. /**
  63259. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63260. * @param startValue defines the start value
  63261. * @param endValue defines the end value
  63262. * @param gradient defines the gradient factor
  63263. * @param result defines the Matrix object where to store data
  63264. */
  63265. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63266. /**
  63267. * Builds a new matrix whose values are computed by:
  63268. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63269. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63270. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63271. * @param startValue defines the first matrix
  63272. * @param endValue defines the second matrix
  63273. * @param gradient defines the gradient between the two matrices
  63274. * @returns the new matrix
  63275. */
  63276. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63277. /**
  63278. * Update a matrix to values which are computed by:
  63279. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63280. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63281. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63282. * @param startValue defines the first matrix
  63283. * @param endValue defines the second matrix
  63284. * @param gradient defines the gradient between the two matrices
  63285. * @param result defines the target matrix
  63286. */
  63287. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63288. /**
  63289. * 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"
  63290. * This function works in left handed mode
  63291. * @param eye defines the final position of the entity
  63292. * @param target defines where the entity should look at
  63293. * @param up defines the up vector for the entity
  63294. * @returns the new matrix
  63295. */
  63296. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63297. /**
  63298. * 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".
  63299. * This function works in left handed mode
  63300. * @param eye defines the final position of the entity
  63301. * @param target defines where the entity should look at
  63302. * @param up defines the up vector for the entity
  63303. * @param result defines the target matrix
  63304. */
  63305. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63306. /**
  63307. * 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"
  63308. * This function works in right handed mode
  63309. * @param eye defines the final position of the entity
  63310. * @param target defines where the entity should look at
  63311. * @param up defines the up vector for the entity
  63312. * @returns the new matrix
  63313. */
  63314. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63315. /**
  63316. * 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".
  63317. * This function works in right handed mode
  63318. * @param eye defines the final position of the entity
  63319. * @param target defines where the entity should look at
  63320. * @param up defines the up vector for the entity
  63321. * @param result defines the target matrix
  63322. */
  63323. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63324. /**
  63325. * Create a left-handed orthographic projection matrix
  63326. * @param width defines the viewport width
  63327. * @param height defines the viewport height
  63328. * @param znear defines the near clip plane
  63329. * @param zfar defines the far clip plane
  63330. * @returns a new matrix as a left-handed orthographic projection matrix
  63331. */
  63332. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63333. /**
  63334. * Store a left-handed orthographic projection to a given matrix
  63335. * @param width defines the viewport width
  63336. * @param height defines the viewport height
  63337. * @param znear defines the near clip plane
  63338. * @param zfar defines the far clip plane
  63339. * @param result defines the target matrix
  63340. */
  63341. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63342. /**
  63343. * Create a left-handed orthographic projection matrix
  63344. * @param left defines the viewport left coordinate
  63345. * @param right defines the viewport right coordinate
  63346. * @param bottom defines the viewport bottom coordinate
  63347. * @param top defines the viewport top coordinate
  63348. * @param znear defines the near clip plane
  63349. * @param zfar defines the far clip plane
  63350. * @returns a new matrix as a left-handed orthographic projection matrix
  63351. */
  63352. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63353. /**
  63354. * Stores a left-handed orthographic projection into a given matrix
  63355. * @param left defines the viewport left coordinate
  63356. * @param right defines the viewport right coordinate
  63357. * @param bottom defines the viewport bottom coordinate
  63358. * @param top defines the viewport top coordinate
  63359. * @param znear defines the near clip plane
  63360. * @param zfar defines the far clip plane
  63361. * @param result defines the target matrix
  63362. */
  63363. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63364. /**
  63365. * Creates a right-handed orthographic projection matrix
  63366. * @param left defines the viewport left coordinate
  63367. * @param right defines the viewport right coordinate
  63368. * @param bottom defines the viewport bottom coordinate
  63369. * @param top defines the viewport top coordinate
  63370. * @param znear defines the near clip plane
  63371. * @param zfar defines the far clip plane
  63372. * @returns a new matrix as a right-handed orthographic projection matrix
  63373. */
  63374. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63375. /**
  63376. * Stores a right-handed orthographic projection into a given matrix
  63377. * @param left defines the viewport left coordinate
  63378. * @param right defines the viewport right coordinate
  63379. * @param bottom defines the viewport bottom coordinate
  63380. * @param top defines the viewport top coordinate
  63381. * @param znear defines the near clip plane
  63382. * @param zfar defines the far clip plane
  63383. * @param result defines the target matrix
  63384. */
  63385. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63386. /**
  63387. * Creates a left-handed perspective projection matrix
  63388. * @param width defines the viewport width
  63389. * @param height defines the viewport height
  63390. * @param znear defines the near clip plane
  63391. * @param zfar defines the far clip plane
  63392. * @returns a new matrix as a left-handed perspective projection matrix
  63393. */
  63394. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63395. /**
  63396. * Creates a left-handed perspective projection matrix
  63397. * @param fov defines the horizontal field of view
  63398. * @param aspect defines the aspect ratio
  63399. * @param znear defines the near clip plane
  63400. * @param zfar defines the far clip plane
  63401. * @returns a new matrix as a left-handed perspective projection matrix
  63402. */
  63403. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63404. /**
  63405. * Stores a left-handed perspective projection into a given matrix
  63406. * @param fov defines the horizontal field of view
  63407. * @param aspect defines the aspect ratio
  63408. * @param znear defines the near clip plane
  63409. * @param zfar defines the far clip plane
  63410. * @param result defines the target matrix
  63411. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63412. */
  63413. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63414. /**
  63415. * Creates a right-handed perspective projection matrix
  63416. * @param fov defines the horizontal field of view
  63417. * @param aspect defines the aspect ratio
  63418. * @param znear defines the near clip plane
  63419. * @param zfar defines the far clip plane
  63420. * @returns a new matrix as a right-handed perspective projection matrix
  63421. */
  63422. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63423. /**
  63424. * Stores a right-handed perspective projection into a given matrix
  63425. * @param fov defines the horizontal field of view
  63426. * @param aspect defines the aspect ratio
  63427. * @param znear defines the near clip plane
  63428. * @param zfar defines the far clip plane
  63429. * @param result defines the target matrix
  63430. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63431. */
  63432. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63433. /**
  63434. * Stores a perspective projection for WebVR info a given matrix
  63435. * @param fov defines the field of view
  63436. * @param znear defines the near clip plane
  63437. * @param zfar defines the far clip plane
  63438. * @param result defines the target matrix
  63439. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63440. */
  63441. static PerspectiveFovWebVRToRef(fov: {
  63442. upDegrees: number;
  63443. downDegrees: number;
  63444. leftDegrees: number;
  63445. rightDegrees: number;
  63446. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63447. /**
  63448. * Computes a complete transformation matrix
  63449. * @param viewport defines the viewport to use
  63450. * @param world defines the world matrix
  63451. * @param view defines the view matrix
  63452. * @param projection defines the projection matrix
  63453. * @param zmin defines the near clip plane
  63454. * @param zmax defines the far clip plane
  63455. * @returns the transformation matrix
  63456. */
  63457. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63458. /**
  63459. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63460. * @param matrix defines the matrix to use
  63461. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63462. */
  63463. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63464. /**
  63465. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63466. * @param matrix defines the matrix to use
  63467. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63468. */
  63469. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63470. /**
  63471. * Compute the transpose of a given matrix
  63472. * @param matrix defines the matrix to transpose
  63473. * @returns the new matrix
  63474. */
  63475. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63476. /**
  63477. * Compute the transpose of a matrix and store it in a target matrix
  63478. * @param matrix defines the matrix to transpose
  63479. * @param result defines the target matrix
  63480. */
  63481. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63482. /**
  63483. * Computes a reflection matrix from a plane
  63484. * @param plane defines the reflection plane
  63485. * @returns a new matrix
  63486. */
  63487. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63488. /**
  63489. * Computes a reflection matrix from a plane
  63490. * @param plane defines the reflection plane
  63491. * @param result defines the target matrix
  63492. */
  63493. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63494. /**
  63495. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63496. * @param xaxis defines the value of the 1st axis
  63497. * @param yaxis defines the value of the 2nd axis
  63498. * @param zaxis defines the value of the 3rd axis
  63499. * @param result defines the target matrix
  63500. */
  63501. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63502. /**
  63503. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63504. * @param quat defines the quaternion to use
  63505. * @param result defines the target matrix
  63506. */
  63507. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63508. }
  63509. /**
  63510. * Represens a plane by the equation ax + by + cz + d = 0
  63511. */
  63512. export class Plane {
  63513. /**
  63514. * Normal of the plane (a,b,c)
  63515. */
  63516. normal: Vector3;
  63517. /**
  63518. * d component of the plane
  63519. */
  63520. d: number;
  63521. /**
  63522. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63523. * @param a a component of the plane
  63524. * @param b b component of the plane
  63525. * @param c c component of the plane
  63526. * @param d d component of the plane
  63527. */
  63528. constructor(a: number, b: number, c: number, d: number);
  63529. /**
  63530. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63531. */
  63532. asArray(): number[];
  63533. /**
  63534. * @returns a new plane copied from the current Plane.
  63535. */
  63536. clone(): Plane;
  63537. /**
  63538. * @returns the string "Plane".
  63539. */
  63540. getClassName(): string;
  63541. /**
  63542. * @returns the Plane hash code.
  63543. */
  63544. getHashCode(): number;
  63545. /**
  63546. * Normalize the current Plane in place.
  63547. * @returns the updated Plane.
  63548. */
  63549. normalize(): Plane;
  63550. /**
  63551. * Applies a transformation the plane and returns the result
  63552. * @param transformation the transformation matrix to be applied to the plane
  63553. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63554. */
  63555. transform(transformation: DeepImmutable<Matrix>): Plane;
  63556. /**
  63557. * Calcualtte the dot product between the point and the plane normal
  63558. * @param point point to calculate the dot product with
  63559. * @returns the dot product (float) of the point coordinates and the plane normal.
  63560. */
  63561. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63562. /**
  63563. * Updates the current Plane from the plane defined by the three given points.
  63564. * @param point1 one of the points used to contruct the plane
  63565. * @param point2 one of the points used to contruct the plane
  63566. * @param point3 one of the points used to contruct the plane
  63567. * @returns the updated Plane.
  63568. */
  63569. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63570. /**
  63571. * Checks if the plane is facing a given direction
  63572. * @param direction the direction to check if the plane is facing
  63573. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63574. * @returns True is the vector "direction" is the same side than the plane normal.
  63575. */
  63576. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63577. /**
  63578. * Calculates the distance to a point
  63579. * @param point point to calculate distance to
  63580. * @returns the signed distance (float) from the given point to the Plane.
  63581. */
  63582. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63583. /**
  63584. * Creates a plane from an array
  63585. * @param array the array to create a plane from
  63586. * @returns a new Plane from the given array.
  63587. */
  63588. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63589. /**
  63590. * Creates a plane from three points
  63591. * @param point1 point used to create the plane
  63592. * @param point2 point used to create the plane
  63593. * @param point3 point used to create the plane
  63594. * @returns a new Plane defined by the three given points.
  63595. */
  63596. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63597. /**
  63598. * Creates a plane from an origin point and a normal
  63599. * @param origin origin of the plane to be constructed
  63600. * @param normal normal of the plane to be constructed
  63601. * @returns a new Plane the normal vector to this plane at the given origin point.
  63602. * Note : the vector "normal" is updated because normalized.
  63603. */
  63604. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63605. /**
  63606. * Calculates the distance from a plane and a point
  63607. * @param origin origin of the plane to be constructed
  63608. * @param normal normal of the plane to be constructed
  63609. * @param point point to calculate distance to
  63610. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63611. */
  63612. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63613. }
  63614. /**
  63615. * Class used to represent a viewport on screen
  63616. */
  63617. export class Viewport {
  63618. /** viewport left coordinate */
  63619. x: number;
  63620. /** viewport top coordinate */
  63621. y: number;
  63622. /**viewport width */
  63623. width: number;
  63624. /** viewport height */
  63625. height: number;
  63626. /**
  63627. * Creates a Viewport object located at (x, y) and sized (width, height)
  63628. * @param x defines viewport left coordinate
  63629. * @param y defines viewport top coordinate
  63630. * @param width defines the viewport width
  63631. * @param height defines the viewport height
  63632. */
  63633. constructor(
  63634. /** viewport left coordinate */
  63635. x: number,
  63636. /** viewport top coordinate */
  63637. y: number,
  63638. /**viewport width */
  63639. width: number,
  63640. /** viewport height */
  63641. height: number);
  63642. /**
  63643. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63644. * @param renderWidth defines the rendering width
  63645. * @param renderHeight defines the rendering height
  63646. * @returns a new Viewport
  63647. */
  63648. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63649. /**
  63650. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63651. * @param renderWidth defines the rendering width
  63652. * @param renderHeight defines the rendering height
  63653. * @param ref defines the target viewport
  63654. * @returns the current viewport
  63655. */
  63656. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63657. /**
  63658. * Returns a new Viewport copied from the current one
  63659. * @returns a new Viewport
  63660. */
  63661. clone(): Viewport;
  63662. }
  63663. /**
  63664. * Reprasents a camera frustum
  63665. */
  63666. export class Frustum {
  63667. /**
  63668. * Gets the planes representing the frustum
  63669. * @param transform matrix to be applied to the returned planes
  63670. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63671. */
  63672. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63673. /**
  63674. * Gets the near frustum plane transformed by the transform matrix
  63675. * @param transform transformation matrix to be applied to the resulting frustum plane
  63676. * @param frustumPlane the resuling frustum plane
  63677. */
  63678. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63679. /**
  63680. * Gets the far frustum plane transformed by the transform matrix
  63681. * @param transform transformation matrix to be applied to the resulting frustum plane
  63682. * @param frustumPlane the resuling frustum plane
  63683. */
  63684. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63685. /**
  63686. * Gets the left frustum plane transformed by the transform matrix
  63687. * @param transform transformation matrix to be applied to the resulting frustum plane
  63688. * @param frustumPlane the resuling frustum plane
  63689. */
  63690. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63691. /**
  63692. * Gets the right frustum plane transformed by the transform matrix
  63693. * @param transform transformation matrix to be applied to the resulting frustum plane
  63694. * @param frustumPlane the resuling frustum plane
  63695. */
  63696. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63697. /**
  63698. * Gets the top frustum plane transformed by the transform matrix
  63699. * @param transform transformation matrix to be applied to the resulting frustum plane
  63700. * @param frustumPlane the resuling frustum plane
  63701. */
  63702. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63703. /**
  63704. * Gets the bottom frustum plane transformed by the transform matrix
  63705. * @param transform transformation matrix to be applied to the resulting frustum plane
  63706. * @param frustumPlane the resuling frustum plane
  63707. */
  63708. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63709. /**
  63710. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63711. * @param transform transformation matrix to be applied to the resulting frustum planes
  63712. * @param frustumPlanes the resuling frustum planes
  63713. */
  63714. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63715. }
  63716. /** Defines supported spaces */
  63717. export enum Space {
  63718. /** Local (object) space */
  63719. LOCAL = 0,
  63720. /** World space */
  63721. WORLD = 1,
  63722. /** Bone space */
  63723. BONE = 2
  63724. }
  63725. /** Defines the 3 main axes */
  63726. export class Axis {
  63727. /** X axis */
  63728. static X: Vector3;
  63729. /** Y axis */
  63730. static Y: Vector3;
  63731. /** Z axis */
  63732. static Z: Vector3;
  63733. }
  63734. /** Class used to represent a Bezier curve */
  63735. export class BezierCurve {
  63736. /**
  63737. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63738. * @param t defines the time
  63739. * @param x1 defines the left coordinate on X axis
  63740. * @param y1 defines the left coordinate on Y axis
  63741. * @param x2 defines the right coordinate on X axis
  63742. * @param y2 defines the right coordinate on Y axis
  63743. * @returns the interpolated value
  63744. */
  63745. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63746. }
  63747. /**
  63748. * Defines potential orientation for back face culling
  63749. */
  63750. export enum Orientation {
  63751. /**
  63752. * Clockwise
  63753. */
  63754. CW = 0,
  63755. /** Counter clockwise */
  63756. CCW = 1
  63757. }
  63758. /**
  63759. * Defines angle representation
  63760. */
  63761. export class Angle {
  63762. private _radians;
  63763. /**
  63764. * Creates an Angle object of "radians" radians (float).
  63765. * @param radians the angle in radians
  63766. */
  63767. constructor(radians: number);
  63768. /**
  63769. * Get value in degrees
  63770. * @returns the Angle value in degrees (float)
  63771. */
  63772. degrees(): number;
  63773. /**
  63774. * Get value in radians
  63775. * @returns the Angle value in radians (float)
  63776. */
  63777. radians(): number;
  63778. /**
  63779. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63780. * @param a defines first vector
  63781. * @param b defines second vector
  63782. * @returns a new Angle
  63783. */
  63784. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63785. /**
  63786. * Gets a new Angle object from the given float in radians
  63787. * @param radians defines the angle value in radians
  63788. * @returns a new Angle
  63789. */
  63790. static FromRadians(radians: number): Angle;
  63791. /**
  63792. * Gets a new Angle object from the given float in degrees
  63793. * @param degrees defines the angle value in degrees
  63794. * @returns a new Angle
  63795. */
  63796. static FromDegrees(degrees: number): Angle;
  63797. }
  63798. /**
  63799. * This represents an arc in a 2d space.
  63800. */
  63801. export class Arc2 {
  63802. /** Defines the start point of the arc */
  63803. startPoint: Vector2;
  63804. /** Defines the mid point of the arc */
  63805. midPoint: Vector2;
  63806. /** Defines the end point of the arc */
  63807. endPoint: Vector2;
  63808. /**
  63809. * Defines the center point of the arc.
  63810. */
  63811. centerPoint: Vector2;
  63812. /**
  63813. * Defines the radius of the arc.
  63814. */
  63815. radius: number;
  63816. /**
  63817. * Defines the angle of the arc (from mid point to end point).
  63818. */
  63819. angle: Angle;
  63820. /**
  63821. * Defines the start angle of the arc (from start point to middle point).
  63822. */
  63823. startAngle: Angle;
  63824. /**
  63825. * Defines the orientation of the arc (clock wise/counter clock wise).
  63826. */
  63827. orientation: Orientation;
  63828. /**
  63829. * Creates an Arc object from the three given points : start, middle and end.
  63830. * @param startPoint Defines the start point of the arc
  63831. * @param midPoint Defines the midlle point of the arc
  63832. * @param endPoint Defines the end point of the arc
  63833. */
  63834. constructor(
  63835. /** Defines the start point of the arc */
  63836. startPoint: Vector2,
  63837. /** Defines the mid point of the arc */
  63838. midPoint: Vector2,
  63839. /** Defines the end point of the arc */
  63840. endPoint: Vector2);
  63841. }
  63842. /**
  63843. * Represents a 2D path made up of multiple 2D points
  63844. */
  63845. export class Path2 {
  63846. private _points;
  63847. private _length;
  63848. /**
  63849. * If the path start and end point are the same
  63850. */
  63851. closed: boolean;
  63852. /**
  63853. * Creates a Path2 object from the starting 2D coordinates x and y.
  63854. * @param x the starting points x value
  63855. * @param y the starting points y value
  63856. */
  63857. constructor(x: number, y: number);
  63858. /**
  63859. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63860. * @param x the added points x value
  63861. * @param y the added points y value
  63862. * @returns the updated Path2.
  63863. */
  63864. addLineTo(x: number, y: number): Path2;
  63865. /**
  63866. * 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.
  63867. * @param midX middle point x value
  63868. * @param midY middle point y value
  63869. * @param endX end point x value
  63870. * @param endY end point y value
  63871. * @param numberOfSegments (default: 36)
  63872. * @returns the updated Path2.
  63873. */
  63874. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63875. /**
  63876. * Closes the Path2.
  63877. * @returns the Path2.
  63878. */
  63879. close(): Path2;
  63880. /**
  63881. * Gets the sum of the distance between each sequential point in the path
  63882. * @returns the Path2 total length (float).
  63883. */
  63884. length(): number;
  63885. /**
  63886. * Gets the points which construct the path
  63887. * @returns the Path2 internal array of points.
  63888. */
  63889. getPoints(): Vector2[];
  63890. /**
  63891. * Retreives the point at the distance aways from the starting point
  63892. * @param normalizedLengthPosition the length along the path to retreive the point from
  63893. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63894. */
  63895. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63896. /**
  63897. * Creates a new path starting from an x and y position
  63898. * @param x starting x value
  63899. * @param y starting y value
  63900. * @returns a new Path2 starting at the coordinates (x, y).
  63901. */
  63902. static StartingAt(x: number, y: number): Path2;
  63903. }
  63904. /**
  63905. * Represents a 3D path made up of multiple 3D points
  63906. */
  63907. export class Path3D {
  63908. /**
  63909. * an array of Vector3, the curve axis of the Path3D
  63910. */
  63911. path: Vector3[];
  63912. private _curve;
  63913. private _distances;
  63914. private _tangents;
  63915. private _normals;
  63916. private _binormals;
  63917. private _raw;
  63918. /**
  63919. * new Path3D(path, normal, raw)
  63920. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63921. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63922. * @param path an array of Vector3, the curve axis of the Path3D
  63923. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63924. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63925. */
  63926. constructor(
  63927. /**
  63928. * an array of Vector3, the curve axis of the Path3D
  63929. */
  63930. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63931. /**
  63932. * Returns the Path3D array of successive Vector3 designing its curve.
  63933. * @returns the Path3D array of successive Vector3 designing its curve.
  63934. */
  63935. getCurve(): Vector3[];
  63936. /**
  63937. * Returns an array populated with tangent vectors on each Path3D curve point.
  63938. * @returns an array populated with tangent vectors on each Path3D curve point.
  63939. */
  63940. getTangents(): Vector3[];
  63941. /**
  63942. * Returns an array populated with normal vectors on each Path3D curve point.
  63943. * @returns an array populated with normal vectors on each Path3D curve point.
  63944. */
  63945. getNormals(): Vector3[];
  63946. /**
  63947. * Returns an array populated with binormal vectors on each Path3D curve point.
  63948. * @returns an array populated with binormal vectors on each Path3D curve point.
  63949. */
  63950. getBinormals(): Vector3[];
  63951. /**
  63952. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63953. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63954. */
  63955. getDistances(): number[];
  63956. /**
  63957. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63958. * @param path path which all values are copied into the curves points
  63959. * @param firstNormal which should be projected onto the curve
  63960. * @returns the same object updated.
  63961. */
  63962. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63963. private _compute;
  63964. private _getFirstNonNullVector;
  63965. private _getLastNonNullVector;
  63966. private _normalVector;
  63967. }
  63968. /**
  63969. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63970. * A Curve3 is designed from a series of successive Vector3.
  63971. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63972. */
  63973. export class Curve3 {
  63974. private _points;
  63975. private _length;
  63976. /**
  63977. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63978. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63979. * @param v1 (Vector3) the control point
  63980. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63981. * @param nbPoints (integer) the wanted number of points in the curve
  63982. * @returns the created Curve3
  63983. */
  63984. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63985. /**
  63986. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63987. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63988. * @param v1 (Vector3) the first control point
  63989. * @param v2 (Vector3) the second control point
  63990. * @param v3 (Vector3) the end point of the Cubic Bezier
  63991. * @param nbPoints (integer) the wanted number of points in the curve
  63992. * @returns the created Curve3
  63993. */
  63994. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63995. /**
  63996. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63997. * @param p1 (Vector3) the origin point of the Hermite Spline
  63998. * @param t1 (Vector3) the tangent vector at the origin point
  63999. * @param p2 (Vector3) the end point of the Hermite Spline
  64000. * @param t2 (Vector3) the tangent vector at the end point
  64001. * @param nbPoints (integer) the wanted number of points in the curve
  64002. * @returns the created Curve3
  64003. */
  64004. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64005. /**
  64006. * Returns a Curve3 object along a CatmullRom Spline curve :
  64007. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64008. * @param nbPoints (integer) the wanted number of points between each curve control points
  64009. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64010. * @returns the created Curve3
  64011. */
  64012. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64013. /**
  64014. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64015. * A Curve3 is designed from a series of successive Vector3.
  64016. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64017. * @param points points which make up the curve
  64018. */
  64019. constructor(points: Vector3[]);
  64020. /**
  64021. * @returns the Curve3 stored array of successive Vector3
  64022. */
  64023. getPoints(): Vector3[];
  64024. /**
  64025. * @returns the computed length (float) of the curve.
  64026. */
  64027. length(): number;
  64028. /**
  64029. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64030. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64031. * curveA and curveB keep unchanged.
  64032. * @param curve the curve to continue from this curve
  64033. * @returns the newly constructed curve
  64034. */
  64035. continue(curve: DeepImmutable<Curve3>): Curve3;
  64036. private _computeLength;
  64037. }
  64038. /**
  64039. * Contains position and normal vectors for a vertex
  64040. */
  64041. export class PositionNormalVertex {
  64042. /** the position of the vertex (defaut: 0,0,0) */
  64043. position: Vector3;
  64044. /** the normal of the vertex (defaut: 0,1,0) */
  64045. normal: Vector3;
  64046. /**
  64047. * Creates a PositionNormalVertex
  64048. * @param position the position of the vertex (defaut: 0,0,0)
  64049. * @param normal the normal of the vertex (defaut: 0,1,0)
  64050. */
  64051. constructor(
  64052. /** the position of the vertex (defaut: 0,0,0) */
  64053. position?: Vector3,
  64054. /** the normal of the vertex (defaut: 0,1,0) */
  64055. normal?: Vector3);
  64056. /**
  64057. * Clones the PositionNormalVertex
  64058. * @returns the cloned PositionNormalVertex
  64059. */
  64060. clone(): PositionNormalVertex;
  64061. }
  64062. /**
  64063. * Contains position, normal and uv vectors for a vertex
  64064. */
  64065. export class PositionNormalTextureVertex {
  64066. /** the position of the vertex (defaut: 0,0,0) */
  64067. position: Vector3;
  64068. /** the normal of the vertex (defaut: 0,1,0) */
  64069. normal: Vector3;
  64070. /** the uv of the vertex (default: 0,0) */
  64071. uv: Vector2;
  64072. /**
  64073. * Creates a PositionNormalTextureVertex
  64074. * @param position the position of the vertex (defaut: 0,0,0)
  64075. * @param normal the normal of the vertex (defaut: 0,1,0)
  64076. * @param uv the uv of the vertex (default: 0,0)
  64077. */
  64078. constructor(
  64079. /** the position of the vertex (defaut: 0,0,0) */
  64080. position?: Vector3,
  64081. /** the normal of the vertex (defaut: 0,1,0) */
  64082. normal?: Vector3,
  64083. /** the uv of the vertex (default: 0,0) */
  64084. uv?: Vector2);
  64085. /**
  64086. * Clones the PositionNormalTextureVertex
  64087. * @returns the cloned PositionNormalTextureVertex
  64088. */
  64089. clone(): PositionNormalTextureVertex;
  64090. }
  64091. /**
  64092. * @hidden
  64093. */
  64094. export class Tmp {
  64095. static Color3: Color3[];
  64096. static Color4: Color4[];
  64097. static Vector2: Vector2[];
  64098. static Vector3: Vector3[];
  64099. static Vector4: Vector4[];
  64100. static Quaternion: Quaternion[];
  64101. static Matrix: Matrix[];
  64102. }
  64103. }
  64104. declare module BABYLON {
  64105. /**
  64106. * Class used to enable access to offline support
  64107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64108. */
  64109. export interface IOfflineProvider {
  64110. /**
  64111. * Gets a boolean indicating if scene must be saved in the database
  64112. */
  64113. enableSceneOffline: boolean;
  64114. /**
  64115. * Gets a boolean indicating if textures must be saved in the database
  64116. */
  64117. enableTexturesOffline: boolean;
  64118. /**
  64119. * Open the offline support and make it available
  64120. * @param successCallback defines the callback to call on success
  64121. * @param errorCallback defines the callback to call on error
  64122. */
  64123. open(successCallback: () => void, errorCallback: () => void): void;
  64124. /**
  64125. * Loads an image from the offline support
  64126. * @param url defines the url to load from
  64127. * @param image defines the target DOM image
  64128. */
  64129. loadImage(url: string, image: HTMLImageElement): void;
  64130. /**
  64131. * Loads a file from offline support
  64132. * @param url defines the URL to load from
  64133. * @param sceneLoaded defines a callback to call on success
  64134. * @param progressCallBack defines a callback to call when progress changed
  64135. * @param errorCallback defines a callback to call on error
  64136. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64137. */
  64138. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64139. }
  64140. }
  64141. declare module BABYLON {
  64142. /**
  64143. * A class serves as a medium between the observable and its observers
  64144. */
  64145. export class EventState {
  64146. /**
  64147. * Create a new EventState
  64148. * @param mask defines the mask associated with this state
  64149. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64150. * @param target defines the original target of the state
  64151. * @param currentTarget defines the current target of the state
  64152. */
  64153. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64154. /**
  64155. * Initialize the current event state
  64156. * @param mask defines the mask associated with this state
  64157. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64158. * @param target defines the original target of the state
  64159. * @param currentTarget defines the current target of the state
  64160. * @returns the current event state
  64161. */
  64162. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64163. /**
  64164. * An Observer can set this property to true to prevent subsequent observers of being notified
  64165. */
  64166. skipNextObservers: boolean;
  64167. /**
  64168. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64169. */
  64170. mask: number;
  64171. /**
  64172. * The object that originally notified the event
  64173. */
  64174. target?: any;
  64175. /**
  64176. * The current object in the bubbling phase
  64177. */
  64178. currentTarget?: any;
  64179. /**
  64180. * This will be populated with the return value of the last function that was executed.
  64181. * If it is the first function in the callback chain it will be the event data.
  64182. */
  64183. lastReturnValue?: any;
  64184. }
  64185. /**
  64186. * Represent an Observer registered to a given Observable object.
  64187. */
  64188. export class Observer<T> {
  64189. /**
  64190. * Defines the callback to call when the observer is notified
  64191. */
  64192. callback: (eventData: T, eventState: EventState) => void;
  64193. /**
  64194. * Defines the mask of the observer (used to filter notifications)
  64195. */
  64196. mask: number;
  64197. /**
  64198. * Defines the current scope used to restore the JS context
  64199. */
  64200. scope: any;
  64201. /** @hidden */
  64202. _willBeUnregistered: boolean;
  64203. /**
  64204. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64205. */
  64206. unregisterOnNextCall: boolean;
  64207. /**
  64208. * Creates a new observer
  64209. * @param callback defines the callback to call when the observer is notified
  64210. * @param mask defines the mask of the observer (used to filter notifications)
  64211. * @param scope defines the current scope used to restore the JS context
  64212. */
  64213. constructor(
  64214. /**
  64215. * Defines the callback to call when the observer is notified
  64216. */
  64217. callback: (eventData: T, eventState: EventState) => void,
  64218. /**
  64219. * Defines the mask of the observer (used to filter notifications)
  64220. */
  64221. mask: number,
  64222. /**
  64223. * Defines the current scope used to restore the JS context
  64224. */
  64225. scope?: any);
  64226. }
  64227. /**
  64228. * Represent a list of observers registered to multiple Observables object.
  64229. */
  64230. export class MultiObserver<T> {
  64231. private _observers;
  64232. private _observables;
  64233. /**
  64234. * Release associated resources
  64235. */
  64236. dispose(): void;
  64237. /**
  64238. * Raise a callback when one of the observable will notify
  64239. * @param observables defines a list of observables to watch
  64240. * @param callback defines the callback to call on notification
  64241. * @param mask defines the mask used to filter notifications
  64242. * @param scope defines the current scope used to restore the JS context
  64243. * @returns the new MultiObserver
  64244. */
  64245. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64246. }
  64247. /**
  64248. * The Observable class is a simple implementation of the Observable pattern.
  64249. *
  64250. * 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.
  64251. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64252. * 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).
  64253. * 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.
  64254. */
  64255. export class Observable<T> {
  64256. private _observers;
  64257. private _eventState;
  64258. private _onObserverAdded;
  64259. /**
  64260. * Creates a new observable
  64261. * @param onObserverAdded defines a callback to call when a new observer is added
  64262. */
  64263. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64264. /**
  64265. * Create a new Observer with the specified callback
  64266. * @param callback the callback that will be executed for that Observer
  64267. * @param mask the mask used to filter observers
  64268. * @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.
  64269. * @param scope optional scope for the callback to be called from
  64270. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64271. * @returns the new observer created for the callback
  64272. */
  64273. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64274. /**
  64275. * Create a new Observer with the specified callback and unregisters after the next notification
  64276. * @param callback the callback that will be executed for that Observer
  64277. * @returns the new observer created for the callback
  64278. */
  64279. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64280. /**
  64281. * Remove an Observer from the Observable object
  64282. * @param observer the instance of the Observer to remove
  64283. * @returns false if it doesn't belong to this Observable
  64284. */
  64285. remove(observer: Nullable<Observer<T>>): boolean;
  64286. /**
  64287. * Remove a callback from the Observable object
  64288. * @param callback the callback to remove
  64289. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64290. * @returns false if it doesn't belong to this Observable
  64291. */
  64292. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64293. private _deferUnregister;
  64294. private _remove;
  64295. /**
  64296. * Moves the observable to the top of the observer list making it get called first when notified
  64297. * @param observer the observer to move
  64298. */
  64299. makeObserverTopPriority(observer: Observer<T>): void;
  64300. /**
  64301. * Moves the observable to the bottom of the observer list making it get called last when notified
  64302. * @param observer the observer to move
  64303. */
  64304. makeObserverBottomPriority(observer: Observer<T>): void;
  64305. /**
  64306. * Notify all Observers by calling their respective callback with the given data
  64307. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64308. * @param eventData defines the data to send to all observers
  64309. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64310. * @param target defines the original target of the state
  64311. * @param currentTarget defines the current target of the state
  64312. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64313. */
  64314. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64315. /**
  64316. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64317. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64318. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64319. * and it is crucial that all callbacks will be executed.
  64320. * The order of the callbacks is kept, callbacks are not executed parallel.
  64321. *
  64322. * @param eventData The data to be sent to each callback
  64323. * @param mask is used to filter observers defaults to -1
  64324. * @param target defines the callback target (see EventState)
  64325. * @param currentTarget defines he current object in the bubbling phase
  64326. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64327. */
  64328. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64329. /**
  64330. * Notify a specific observer
  64331. * @param observer defines the observer to notify
  64332. * @param eventData defines the data to be sent to each callback
  64333. * @param mask is used to filter observers defaults to -1
  64334. */
  64335. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64336. /**
  64337. * Gets a boolean indicating if the observable has at least one observer
  64338. * @returns true is the Observable has at least one Observer registered
  64339. */
  64340. hasObservers(): boolean;
  64341. /**
  64342. * Clear the list of observers
  64343. */
  64344. clear(): void;
  64345. /**
  64346. * Clone the current observable
  64347. * @returns a new observable
  64348. */
  64349. clone(): Observable<T>;
  64350. /**
  64351. * Does this observable handles observer registered with a given mask
  64352. * @param mask defines the mask to be tested
  64353. * @return whether or not one observer registered with the given mask is handeled
  64354. **/
  64355. hasSpecificMask(mask?: number): boolean;
  64356. }
  64357. }
  64358. declare module BABYLON {
  64359. /**
  64360. * Class used to help managing file picking and drag'n'drop
  64361. * File Storage
  64362. */
  64363. export class FilesInputStore {
  64364. /**
  64365. * List of files ready to be loaded
  64366. */
  64367. static FilesToLoad: {
  64368. [key: string]: File;
  64369. };
  64370. }
  64371. }
  64372. declare module BABYLON {
  64373. /** Defines the cross module used constants to avoid circular dependncies */
  64374. export class Constants {
  64375. /** Defines that alpha blending is disabled */
  64376. static readonly ALPHA_DISABLE: number;
  64377. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64378. static readonly ALPHA_ADD: number;
  64379. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64380. static readonly ALPHA_COMBINE: number;
  64381. /** Defines that alpha blending to DEST - SRC * DEST */
  64382. static readonly ALPHA_SUBTRACT: number;
  64383. /** Defines that alpha blending to SRC * DEST */
  64384. static readonly ALPHA_MULTIPLY: number;
  64385. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64386. static readonly ALPHA_MAXIMIZED: number;
  64387. /** Defines that alpha blending to SRC + DEST */
  64388. static readonly ALPHA_ONEONE: number;
  64389. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64390. static readonly ALPHA_PREMULTIPLIED: number;
  64391. /**
  64392. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64393. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64394. */
  64395. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64396. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64397. static readonly ALPHA_INTERPOLATE: number;
  64398. /**
  64399. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64400. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64401. */
  64402. static readonly ALPHA_SCREENMODE: number;
  64403. /** Defines that the ressource is not delayed*/
  64404. static readonly DELAYLOADSTATE_NONE: number;
  64405. /** Defines that the ressource was successfully delay loaded */
  64406. static readonly DELAYLOADSTATE_LOADED: number;
  64407. /** Defines that the ressource is currently delay loading */
  64408. static readonly DELAYLOADSTATE_LOADING: number;
  64409. /** Defines that the ressource is delayed and has not started loading */
  64410. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64411. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64412. static readonly NEVER: number;
  64413. /** 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 */
  64414. static readonly ALWAYS: number;
  64415. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64416. static readonly LESS: number;
  64417. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64418. static readonly EQUAL: number;
  64419. /** 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 */
  64420. static readonly LEQUAL: number;
  64421. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64422. static readonly GREATER: number;
  64423. /** 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 */
  64424. static readonly GEQUAL: number;
  64425. /** 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 */
  64426. static readonly NOTEQUAL: number;
  64427. /** Passed to stencilOperation to specify that stencil value must be kept */
  64428. static readonly KEEP: number;
  64429. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64430. static readonly REPLACE: number;
  64431. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64432. static readonly INCR: number;
  64433. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64434. static readonly DECR: number;
  64435. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64436. static readonly INVERT: number;
  64437. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64438. static readonly INCR_WRAP: number;
  64439. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64440. static readonly DECR_WRAP: number;
  64441. /** Texture is not repeating outside of 0..1 UVs */
  64442. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64443. /** Texture is repeating outside of 0..1 UVs */
  64444. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64445. /** Texture is repeating and mirrored */
  64446. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64447. /** ALPHA */
  64448. static readonly TEXTUREFORMAT_ALPHA: number;
  64449. /** LUMINANCE */
  64450. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64451. /** LUMINANCE_ALPHA */
  64452. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64453. /** RGB */
  64454. static readonly TEXTUREFORMAT_RGB: number;
  64455. /** RGBA */
  64456. static readonly TEXTUREFORMAT_RGBA: number;
  64457. /** RED */
  64458. static readonly TEXTUREFORMAT_RED: number;
  64459. /** RED (2nd reference) */
  64460. static readonly TEXTUREFORMAT_R: number;
  64461. /** RG */
  64462. static readonly TEXTUREFORMAT_RG: number;
  64463. /** RED_INTEGER */
  64464. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64465. /** RED_INTEGER (2nd reference) */
  64466. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64467. /** RG_INTEGER */
  64468. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64469. /** RGB_INTEGER */
  64470. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64471. /** RGBA_INTEGER */
  64472. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64473. /** UNSIGNED_BYTE */
  64474. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64475. /** UNSIGNED_BYTE (2nd reference) */
  64476. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64477. /** FLOAT */
  64478. static readonly TEXTURETYPE_FLOAT: number;
  64479. /** HALF_FLOAT */
  64480. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64481. /** BYTE */
  64482. static readonly TEXTURETYPE_BYTE: number;
  64483. /** SHORT */
  64484. static readonly TEXTURETYPE_SHORT: number;
  64485. /** UNSIGNED_SHORT */
  64486. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64487. /** INT */
  64488. static readonly TEXTURETYPE_INT: number;
  64489. /** UNSIGNED_INT */
  64490. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64491. /** UNSIGNED_SHORT_4_4_4_4 */
  64492. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64493. /** UNSIGNED_SHORT_5_5_5_1 */
  64494. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64495. /** UNSIGNED_SHORT_5_6_5 */
  64496. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64497. /** UNSIGNED_INT_2_10_10_10_REV */
  64498. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64499. /** UNSIGNED_INT_24_8 */
  64500. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64501. /** UNSIGNED_INT_10F_11F_11F_REV */
  64502. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64503. /** UNSIGNED_INT_5_9_9_9_REV */
  64504. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64505. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64506. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64507. /** nearest is mag = nearest and min = nearest and mip = linear */
  64508. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64509. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64510. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64511. /** Trilinear is mag = linear and min = linear and mip = linear */
  64512. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64513. /** nearest is mag = nearest and min = nearest and mip = linear */
  64514. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64515. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64516. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64517. /** Trilinear is mag = linear and min = linear and mip = linear */
  64518. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64519. /** mag = nearest and min = nearest and mip = nearest */
  64520. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64521. /** mag = nearest and min = linear and mip = nearest */
  64522. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64523. /** mag = nearest and min = linear and mip = linear */
  64524. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64525. /** mag = nearest and min = linear and mip = none */
  64526. static readonly TEXTURE_NEAREST_LINEAR: number;
  64527. /** mag = nearest and min = nearest and mip = none */
  64528. static readonly TEXTURE_NEAREST_NEAREST: number;
  64529. /** mag = linear and min = nearest and mip = nearest */
  64530. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64531. /** mag = linear and min = nearest and mip = linear */
  64532. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64533. /** mag = linear and min = linear and mip = none */
  64534. static readonly TEXTURE_LINEAR_LINEAR: number;
  64535. /** mag = linear and min = nearest and mip = none */
  64536. static readonly TEXTURE_LINEAR_NEAREST: number;
  64537. /** Explicit coordinates mode */
  64538. static readonly TEXTURE_EXPLICIT_MODE: number;
  64539. /** Spherical coordinates mode */
  64540. static readonly TEXTURE_SPHERICAL_MODE: number;
  64541. /** Planar coordinates mode */
  64542. static readonly TEXTURE_PLANAR_MODE: number;
  64543. /** Cubic coordinates mode */
  64544. static readonly TEXTURE_CUBIC_MODE: number;
  64545. /** Projection coordinates mode */
  64546. static readonly TEXTURE_PROJECTION_MODE: number;
  64547. /** Skybox coordinates mode */
  64548. static readonly TEXTURE_SKYBOX_MODE: number;
  64549. /** Inverse Cubic coordinates mode */
  64550. static readonly TEXTURE_INVCUBIC_MODE: number;
  64551. /** Equirectangular coordinates mode */
  64552. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64553. /** Equirectangular Fixed coordinates mode */
  64554. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64555. /** Equirectangular Fixed Mirrored coordinates mode */
  64556. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64557. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64558. static readonly SCALEMODE_FLOOR: number;
  64559. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64560. static readonly SCALEMODE_NEAREST: number;
  64561. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64562. static readonly SCALEMODE_CEILING: number;
  64563. /**
  64564. * The dirty texture flag value
  64565. */
  64566. static readonly MATERIAL_TextureDirtyFlag: number;
  64567. /**
  64568. * The dirty light flag value
  64569. */
  64570. static readonly MATERIAL_LightDirtyFlag: number;
  64571. /**
  64572. * The dirty fresnel flag value
  64573. */
  64574. static readonly MATERIAL_FresnelDirtyFlag: number;
  64575. /**
  64576. * The dirty attribute flag value
  64577. */
  64578. static readonly MATERIAL_AttributesDirtyFlag: number;
  64579. /**
  64580. * The dirty misc flag value
  64581. */
  64582. static readonly MATERIAL_MiscDirtyFlag: number;
  64583. /**
  64584. * The all dirty flag value
  64585. */
  64586. static readonly MATERIAL_AllDirtyFlag: number;
  64587. /**
  64588. * Returns the triangle fill mode
  64589. */
  64590. static readonly MATERIAL_TriangleFillMode: number;
  64591. /**
  64592. * Returns the wireframe mode
  64593. */
  64594. static readonly MATERIAL_WireFrameFillMode: number;
  64595. /**
  64596. * Returns the point fill mode
  64597. */
  64598. static readonly MATERIAL_PointFillMode: number;
  64599. /**
  64600. * Returns the point list draw mode
  64601. */
  64602. static readonly MATERIAL_PointListDrawMode: number;
  64603. /**
  64604. * Returns the line list draw mode
  64605. */
  64606. static readonly MATERIAL_LineListDrawMode: number;
  64607. /**
  64608. * Returns the line loop draw mode
  64609. */
  64610. static readonly MATERIAL_LineLoopDrawMode: number;
  64611. /**
  64612. * Returns the line strip draw mode
  64613. */
  64614. static readonly MATERIAL_LineStripDrawMode: number;
  64615. /**
  64616. * Returns the triangle strip draw mode
  64617. */
  64618. static readonly MATERIAL_TriangleStripDrawMode: number;
  64619. /**
  64620. * Returns the triangle fan draw mode
  64621. */
  64622. static readonly MATERIAL_TriangleFanDrawMode: number;
  64623. /**
  64624. * Stores the clock-wise side orientation
  64625. */
  64626. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64627. /**
  64628. * Stores the counter clock-wise side orientation
  64629. */
  64630. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64631. /**
  64632. * Nothing
  64633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64634. */
  64635. static readonly ACTION_NothingTrigger: number;
  64636. /**
  64637. * On pick
  64638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64639. */
  64640. static readonly ACTION_OnPickTrigger: number;
  64641. /**
  64642. * On left pick
  64643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64644. */
  64645. static readonly ACTION_OnLeftPickTrigger: number;
  64646. /**
  64647. * On right pick
  64648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64649. */
  64650. static readonly ACTION_OnRightPickTrigger: number;
  64651. /**
  64652. * On center pick
  64653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64654. */
  64655. static readonly ACTION_OnCenterPickTrigger: number;
  64656. /**
  64657. * On pick down
  64658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64659. */
  64660. static readonly ACTION_OnPickDownTrigger: number;
  64661. /**
  64662. * On double pick
  64663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64664. */
  64665. static readonly ACTION_OnDoublePickTrigger: number;
  64666. /**
  64667. * On pick up
  64668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64669. */
  64670. static readonly ACTION_OnPickUpTrigger: number;
  64671. /**
  64672. * On pick out.
  64673. * This trigger will only be raised if you also declared a OnPickDown
  64674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64675. */
  64676. static readonly ACTION_OnPickOutTrigger: number;
  64677. /**
  64678. * On long press
  64679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64680. */
  64681. static readonly ACTION_OnLongPressTrigger: number;
  64682. /**
  64683. * On pointer over
  64684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64685. */
  64686. static readonly ACTION_OnPointerOverTrigger: number;
  64687. /**
  64688. * On pointer out
  64689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64690. */
  64691. static readonly ACTION_OnPointerOutTrigger: number;
  64692. /**
  64693. * On every frame
  64694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64695. */
  64696. static readonly ACTION_OnEveryFrameTrigger: number;
  64697. /**
  64698. * On intersection enter
  64699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64700. */
  64701. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64702. /**
  64703. * On intersection exit
  64704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64705. */
  64706. static readonly ACTION_OnIntersectionExitTrigger: number;
  64707. /**
  64708. * On key down
  64709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64710. */
  64711. static readonly ACTION_OnKeyDownTrigger: number;
  64712. /**
  64713. * On key up
  64714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64715. */
  64716. static readonly ACTION_OnKeyUpTrigger: number;
  64717. /**
  64718. * Billboard mode will only apply to Y axis
  64719. */
  64720. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64721. /**
  64722. * Billboard mode will apply to all axes
  64723. */
  64724. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64725. /**
  64726. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64727. */
  64728. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64729. /**
  64730. * Gets or sets base Assets URL
  64731. */
  64732. static readonly PARTICLES_BaseAssetsUrl: string;
  64733. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64734. * Test order :
  64735. * Is the bounding sphere outside the frustum ?
  64736. * If not, are the bounding box vertices outside the frustum ?
  64737. * It not, then the cullable object is in the frustum.
  64738. */
  64739. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64740. /** Culling strategy : Bounding Sphere Only.
  64741. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64742. * It's also less accurate than the standard because some not visible objects can still be selected.
  64743. * Test : is the bounding sphere outside the frustum ?
  64744. * If not, then the cullable object is in the frustum.
  64745. */
  64746. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64747. /** Culling strategy : Optimistic Inclusion.
  64748. * This in an inclusion test first, then the standard exclusion test.
  64749. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64750. * 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.
  64751. * Anyway, it's as accurate as the standard strategy.
  64752. * Test :
  64753. * Is the cullable object bounding sphere center in the frustum ?
  64754. * If not, apply the default culling strategy.
  64755. */
  64756. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64757. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64758. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64759. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64760. * 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.
  64761. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64762. * Test :
  64763. * Is the cullable object bounding sphere center in the frustum ?
  64764. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64765. */
  64766. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64767. /**
  64768. * No logging while loading
  64769. */
  64770. static readonly SCENELOADER_NO_LOGGING: number;
  64771. /**
  64772. * Minimal logging while loading
  64773. */
  64774. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64775. /**
  64776. * Summary logging while loading
  64777. */
  64778. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64779. /**
  64780. * Detailled logging while loading
  64781. */
  64782. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64783. }
  64784. }
  64785. declare module BABYLON {
  64786. /**
  64787. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64788. * Babylon.js
  64789. */
  64790. export class DomManagement {
  64791. /**
  64792. * Checks if the window object exists
  64793. * @returns true if the window object exists
  64794. */
  64795. static IsWindowObjectExist(): boolean;
  64796. /**
  64797. * Extracts text content from a DOM element hierarchy
  64798. * @param element defines the root element
  64799. * @returns a string
  64800. */
  64801. static GetDOMTextContent(element: HTMLElement): string;
  64802. }
  64803. }
  64804. declare module BABYLON {
  64805. /**
  64806. * Logger used througouht the application to allow configuration of
  64807. * the log level required for the messages.
  64808. */
  64809. export class Logger {
  64810. /**
  64811. * No log
  64812. */
  64813. static readonly NoneLogLevel: number;
  64814. /**
  64815. * Only message logs
  64816. */
  64817. static readonly MessageLogLevel: number;
  64818. /**
  64819. * Only warning logs
  64820. */
  64821. static readonly WarningLogLevel: number;
  64822. /**
  64823. * Only error logs
  64824. */
  64825. static readonly ErrorLogLevel: number;
  64826. /**
  64827. * All logs
  64828. */
  64829. static readonly AllLogLevel: number;
  64830. private static _LogCache;
  64831. /**
  64832. * Gets a value indicating the number of loading errors
  64833. * @ignorenaming
  64834. */
  64835. static errorsCount: number;
  64836. /**
  64837. * Callback called when a new log is added
  64838. */
  64839. static OnNewCacheEntry: (entry: string) => void;
  64840. private static _AddLogEntry;
  64841. private static _FormatMessage;
  64842. private static _LogDisabled;
  64843. private static _LogEnabled;
  64844. private static _WarnDisabled;
  64845. private static _WarnEnabled;
  64846. private static _ErrorDisabled;
  64847. private static _ErrorEnabled;
  64848. /**
  64849. * Log a message to the console
  64850. */
  64851. static Log: (message: string) => void;
  64852. /**
  64853. * Write a warning message to the console
  64854. */
  64855. static Warn: (message: string) => void;
  64856. /**
  64857. * Write an error message to the console
  64858. */
  64859. static Error: (message: string) => void;
  64860. /**
  64861. * Gets current log cache (list of logs)
  64862. */
  64863. static readonly LogCache: string;
  64864. /**
  64865. * Clears the log cache
  64866. */
  64867. static ClearLogCache(): void;
  64868. /**
  64869. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64870. */
  64871. static LogLevels: number;
  64872. }
  64873. }
  64874. declare module BABYLON {
  64875. /** @hidden */
  64876. export class _TypeStore {
  64877. /** @hidden */
  64878. static RegisteredTypes: {
  64879. [key: string]: Object;
  64880. };
  64881. /** @hidden */
  64882. static GetClass(fqdn: string): any;
  64883. }
  64884. }
  64885. declare module BABYLON {
  64886. /**
  64887. * Class containing a set of static utilities functions for deep copy.
  64888. */
  64889. export class DeepCopier {
  64890. /**
  64891. * Tries to copy an object by duplicating every property
  64892. * @param source defines the source object
  64893. * @param destination defines the target object
  64894. * @param doNotCopyList defines a list of properties to avoid
  64895. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64896. */
  64897. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * Class containing a set of static utilities functions for precision date
  64903. */
  64904. export class PrecisionDate {
  64905. /**
  64906. * Gets either window.performance.now() if supported or Date.now() else
  64907. */
  64908. static readonly Now: number;
  64909. }
  64910. }
  64911. declare module BABYLON {
  64912. /** @hidden */
  64913. export class _DevTools {
  64914. static WarnImport(name: string): string;
  64915. }
  64916. }
  64917. declare module BABYLON {
  64918. /**
  64919. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64920. */
  64921. export class WebRequest {
  64922. private _xhr;
  64923. /**
  64924. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64925. * i.e. when loading files, where the server/service expects an Authorization header
  64926. */
  64927. static CustomRequestHeaders: {
  64928. [key: string]: string;
  64929. };
  64930. /**
  64931. * Add callback functions in this array to update all the requests before they get sent to the network
  64932. */
  64933. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64934. private _injectCustomRequestHeaders;
  64935. /**
  64936. * Gets or sets a function to be called when loading progress changes
  64937. */
  64938. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64939. /**
  64940. * Returns client's state
  64941. */
  64942. readonly readyState: number;
  64943. /**
  64944. * Returns client's status
  64945. */
  64946. readonly status: number;
  64947. /**
  64948. * Returns client's status as a text
  64949. */
  64950. readonly statusText: string;
  64951. /**
  64952. * Returns client's response
  64953. */
  64954. readonly response: any;
  64955. /**
  64956. * Returns client's response url
  64957. */
  64958. readonly responseURL: string;
  64959. /**
  64960. * Returns client's response as text
  64961. */
  64962. readonly responseText: string;
  64963. /**
  64964. * Gets or sets the expected response type
  64965. */
  64966. responseType: XMLHttpRequestResponseType;
  64967. /** @hidden */
  64968. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64969. /** @hidden */
  64970. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64971. /**
  64972. * Cancels any network activity
  64973. */
  64974. abort(): void;
  64975. /**
  64976. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64977. * @param body defines an optional request body
  64978. */
  64979. send(body?: Document | BodyInit | null): void;
  64980. /**
  64981. * Sets the request method, request URL
  64982. * @param method defines the method to use (GET, POST, etc..)
  64983. * @param url defines the url to connect with
  64984. */
  64985. open(method: string, url: string): void;
  64986. }
  64987. }
  64988. declare module BABYLON {
  64989. /**
  64990. * Class used to evalaute queries containing `and` and `or` operators
  64991. */
  64992. export class AndOrNotEvaluator {
  64993. /**
  64994. * Evaluate a query
  64995. * @param query defines the query to evaluate
  64996. * @param evaluateCallback defines the callback used to filter result
  64997. * @returns true if the query matches
  64998. */
  64999. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65000. private static _HandleParenthesisContent;
  65001. private static _SimplifyNegation;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * Class used to store custom tags
  65007. */
  65008. export class Tags {
  65009. /**
  65010. * Adds support for tags on the given object
  65011. * @param obj defines the object to use
  65012. */
  65013. static EnableFor(obj: any): void;
  65014. /**
  65015. * Removes tags support
  65016. * @param obj defines the object to use
  65017. */
  65018. static DisableFor(obj: any): void;
  65019. /**
  65020. * Gets a boolean indicating if the given object has tags
  65021. * @param obj defines the object to use
  65022. * @returns a boolean
  65023. */
  65024. static HasTags(obj: any): boolean;
  65025. /**
  65026. * Gets the tags available on a given object
  65027. * @param obj defines the object to use
  65028. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65029. * @returns the tags
  65030. */
  65031. static GetTags(obj: any, asString?: boolean): any;
  65032. /**
  65033. * Adds tags to an object
  65034. * @param obj defines the object to use
  65035. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65036. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65037. */
  65038. static AddTagsTo(obj: any, tagsString: string): void;
  65039. /**
  65040. * @hidden
  65041. */
  65042. static _AddTagTo(obj: any, tag: string): void;
  65043. /**
  65044. * Removes specific tags from a specific object
  65045. * @param obj defines the object to use
  65046. * @param tagsString defines the tags to remove
  65047. */
  65048. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65049. /**
  65050. * @hidden
  65051. */
  65052. static _RemoveTagFrom(obj: any, tag: string): void;
  65053. /**
  65054. * Defines if tags hosted on an object match a given query
  65055. * @param obj defines the object to use
  65056. * @param tagsQuery defines the tag query
  65057. * @returns a boolean
  65058. */
  65059. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65060. }
  65061. }
  65062. declare module BABYLON {
  65063. /**
  65064. * Manages the defines for the Material
  65065. */
  65066. export class MaterialDefines {
  65067. private _keys;
  65068. private _isDirty;
  65069. /** @hidden */
  65070. _renderId: number;
  65071. /** @hidden */
  65072. _areLightsDirty: boolean;
  65073. /** @hidden */
  65074. _areAttributesDirty: boolean;
  65075. /** @hidden */
  65076. _areTexturesDirty: boolean;
  65077. /** @hidden */
  65078. _areFresnelDirty: boolean;
  65079. /** @hidden */
  65080. _areMiscDirty: boolean;
  65081. /** @hidden */
  65082. _areImageProcessingDirty: boolean;
  65083. /** @hidden */
  65084. _normals: boolean;
  65085. /** @hidden */
  65086. _uvs: boolean;
  65087. /** @hidden */
  65088. _needNormals: boolean;
  65089. /** @hidden */
  65090. _needUVs: boolean;
  65091. /**
  65092. * Specifies if the material needs to be re-calculated
  65093. */
  65094. readonly isDirty: boolean;
  65095. /**
  65096. * Marks the material to indicate that it has been re-calculated
  65097. */
  65098. markAsProcessed(): void;
  65099. /**
  65100. * Marks the material to indicate that it needs to be re-calculated
  65101. */
  65102. markAsUnprocessed(): void;
  65103. /**
  65104. * Marks the material to indicate all of its defines need to be re-calculated
  65105. */
  65106. markAllAsDirty(): void;
  65107. /**
  65108. * Marks the material to indicate that image processing needs to be re-calculated
  65109. */
  65110. markAsImageProcessingDirty(): void;
  65111. /**
  65112. * Marks the material to indicate the lights need to be re-calculated
  65113. */
  65114. markAsLightDirty(): void;
  65115. /**
  65116. * Marks the attribute state as changed
  65117. */
  65118. markAsAttributesDirty(): void;
  65119. /**
  65120. * Marks the texture state as changed
  65121. */
  65122. markAsTexturesDirty(): void;
  65123. /**
  65124. * Marks the fresnel state as changed
  65125. */
  65126. markAsFresnelDirty(): void;
  65127. /**
  65128. * Marks the misc state as changed
  65129. */
  65130. markAsMiscDirty(): void;
  65131. /**
  65132. * Rebuilds the material defines
  65133. */
  65134. rebuild(): void;
  65135. /**
  65136. * Specifies if two material defines are equal
  65137. * @param other - A material define instance to compare to
  65138. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65139. */
  65140. isEqual(other: MaterialDefines): boolean;
  65141. /**
  65142. * Clones this instance's defines to another instance
  65143. * @param other - material defines to clone values to
  65144. */
  65145. cloneTo(other: MaterialDefines): void;
  65146. /**
  65147. * Resets the material define values
  65148. */
  65149. reset(): void;
  65150. /**
  65151. * Converts the material define values to a string
  65152. * @returns - String of material define information
  65153. */
  65154. toString(): string;
  65155. }
  65156. }
  65157. declare module BABYLON {
  65158. /**
  65159. * Class used to store and describe the pipeline context associated with an effect
  65160. */
  65161. export interface IPipelineContext {
  65162. /**
  65163. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65164. */
  65165. isAsync: boolean;
  65166. /**
  65167. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65168. */
  65169. isReady: boolean;
  65170. /** @hidden */
  65171. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65172. }
  65173. }
  65174. declare module BABYLON {
  65175. /**
  65176. * Class used to store gfx data (like WebGLBuffer)
  65177. */
  65178. export class DataBuffer {
  65179. /**
  65180. * Gets or sets the number of objects referencing this buffer
  65181. */
  65182. references: number;
  65183. /** Gets or sets the size of the underlying buffer */
  65184. capacity: number;
  65185. /**
  65186. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65187. */
  65188. is32Bits: boolean;
  65189. /**
  65190. * Gets the underlying buffer
  65191. */
  65192. readonly underlyingResource: any;
  65193. }
  65194. }
  65195. declare module BABYLON {
  65196. /**
  65197. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65198. */
  65199. export class PerformanceMonitor {
  65200. private _enabled;
  65201. private _rollingFrameTime;
  65202. private _lastFrameTimeMs;
  65203. /**
  65204. * constructor
  65205. * @param frameSampleSize The number of samples required to saturate the sliding window
  65206. */
  65207. constructor(frameSampleSize?: number);
  65208. /**
  65209. * Samples current frame
  65210. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65211. */
  65212. sampleFrame(timeMs?: number): void;
  65213. /**
  65214. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65215. */
  65216. readonly averageFrameTime: number;
  65217. /**
  65218. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65219. */
  65220. readonly averageFrameTimeVariance: number;
  65221. /**
  65222. * Returns the frame time of the most recent frame
  65223. */
  65224. readonly instantaneousFrameTime: number;
  65225. /**
  65226. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65227. */
  65228. readonly averageFPS: number;
  65229. /**
  65230. * Returns the average framerate in frames per second using the most recent frame time
  65231. */
  65232. readonly instantaneousFPS: number;
  65233. /**
  65234. * Returns true if enough samples have been taken to completely fill the sliding window
  65235. */
  65236. readonly isSaturated: boolean;
  65237. /**
  65238. * Enables contributions to the sliding window sample set
  65239. */
  65240. enable(): void;
  65241. /**
  65242. * Disables contributions to the sliding window sample set
  65243. * Samples will not be interpolated over the disabled period
  65244. */
  65245. disable(): void;
  65246. /**
  65247. * Returns true if sampling is enabled
  65248. */
  65249. readonly isEnabled: boolean;
  65250. /**
  65251. * Resets performance monitor
  65252. */
  65253. reset(): void;
  65254. }
  65255. /**
  65256. * RollingAverage
  65257. *
  65258. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65259. */
  65260. export class RollingAverage {
  65261. /**
  65262. * Current average
  65263. */
  65264. average: number;
  65265. /**
  65266. * Current variance
  65267. */
  65268. variance: number;
  65269. protected _samples: Array<number>;
  65270. protected _sampleCount: number;
  65271. protected _pos: number;
  65272. protected _m2: number;
  65273. /**
  65274. * constructor
  65275. * @param length The number of samples required to saturate the sliding window
  65276. */
  65277. constructor(length: number);
  65278. /**
  65279. * Adds a sample to the sample set
  65280. * @param v The sample value
  65281. */
  65282. add(v: number): void;
  65283. /**
  65284. * Returns previously added values or null if outside of history or outside the sliding window domain
  65285. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65286. * @return Value previously recorded with add() or null if outside of range
  65287. */
  65288. history(i: number): number;
  65289. /**
  65290. * Returns true if enough samples have been taken to completely fill the sliding window
  65291. * @return true if sample-set saturated
  65292. */
  65293. isSaturated(): boolean;
  65294. /**
  65295. * Resets the rolling average (equivalent to 0 samples taken so far)
  65296. */
  65297. reset(): void;
  65298. /**
  65299. * Wraps a value around the sample range boundaries
  65300. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65301. * @return Wrapped position in sample range
  65302. */
  65303. protected _wrapPosition(i: number): number;
  65304. }
  65305. }
  65306. declare module BABYLON {
  65307. /**
  65308. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65309. * The underlying implementation relies on an associative array to ensure the best performances.
  65310. * The value can be anything including 'null' but except 'undefined'
  65311. */
  65312. export class StringDictionary<T> {
  65313. /**
  65314. * This will clear this dictionary and copy the content from the 'source' one.
  65315. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65316. * @param source the dictionary to take the content from and copy to this dictionary
  65317. */
  65318. copyFrom(source: StringDictionary<T>): void;
  65319. /**
  65320. * Get a value based from its key
  65321. * @param key the given key to get the matching value from
  65322. * @return the value if found, otherwise undefined is returned
  65323. */
  65324. get(key: string): T | undefined;
  65325. /**
  65326. * Get a value from its key or add it if it doesn't exist.
  65327. * This method will ensure you that a given key/data will be present in the dictionary.
  65328. * @param key the given key to get the matching value from
  65329. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65330. * The factory will only be invoked if there's no data for the given key.
  65331. * @return the value corresponding to the key.
  65332. */
  65333. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65334. /**
  65335. * Get a value from its key if present in the dictionary otherwise add it
  65336. * @param key the key to get the value from
  65337. * @param val if there's no such key/value pair in the dictionary add it with this value
  65338. * @return the value corresponding to the key
  65339. */
  65340. getOrAdd(key: string, val: T): T;
  65341. /**
  65342. * Check if there's a given key in the dictionary
  65343. * @param key the key to check for
  65344. * @return true if the key is present, false otherwise
  65345. */
  65346. contains(key: string): boolean;
  65347. /**
  65348. * Add a new key and its corresponding value
  65349. * @param key the key to add
  65350. * @param value the value corresponding to the key
  65351. * @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
  65352. */
  65353. add(key: string, value: T): boolean;
  65354. /**
  65355. * Update a specific value associated to a key
  65356. * @param key defines the key to use
  65357. * @param value defines the value to store
  65358. * @returns true if the value was updated (or false if the key was not found)
  65359. */
  65360. set(key: string, value: T): boolean;
  65361. /**
  65362. * Get the element of the given key and remove it from the dictionary
  65363. * @param key defines the key to search
  65364. * @returns the value associated with the key or null if not found
  65365. */
  65366. getAndRemove(key: string): Nullable<T>;
  65367. /**
  65368. * Remove a key/value from the dictionary.
  65369. * @param key the key to remove
  65370. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65371. */
  65372. remove(key: string): boolean;
  65373. /**
  65374. * Clear the whole content of the dictionary
  65375. */
  65376. clear(): void;
  65377. /**
  65378. * Gets the current count
  65379. */
  65380. readonly count: number;
  65381. /**
  65382. * Execute a callback on each key/val of the dictionary.
  65383. * Note that you can remove any element in this dictionary in the callback implementation
  65384. * @param callback the callback to execute on a given key/value pair
  65385. */
  65386. forEach(callback: (key: string, val: T) => void): void;
  65387. /**
  65388. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65389. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65390. * Note that you can remove any element in this dictionary in the callback implementation
  65391. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65392. * @returns the first item
  65393. */
  65394. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65395. private _count;
  65396. private _data;
  65397. }
  65398. }
  65399. declare module BABYLON {
  65400. /**
  65401. * Helper class that provides a small promise polyfill
  65402. */
  65403. export class PromisePolyfill {
  65404. /**
  65405. * Static function used to check if the polyfill is required
  65406. * If this is the case then the function will inject the polyfill to window.Promise
  65407. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65408. */
  65409. static Apply(force?: boolean): void;
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /**
  65414. * Class used to store data that will be store in GPU memory
  65415. */
  65416. export class Buffer {
  65417. private _engine;
  65418. private _buffer;
  65419. /** @hidden */
  65420. _data: Nullable<DataArray>;
  65421. private _updatable;
  65422. private _instanced;
  65423. /**
  65424. * Gets the byte stride.
  65425. */
  65426. readonly byteStride: number;
  65427. /**
  65428. * Constructor
  65429. * @param engine the engine
  65430. * @param data the data to use for this buffer
  65431. * @param updatable whether the data is updatable
  65432. * @param stride the stride (optional)
  65433. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65434. * @param instanced whether the buffer is instanced (optional)
  65435. * @param useBytes set to true if the stride in in bytes (optional)
  65436. */
  65437. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65438. /**
  65439. * Create a new VertexBuffer based on the current buffer
  65440. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65441. * @param offset defines offset in the buffer (0 by default)
  65442. * @param size defines the size in floats of attributes (position is 3 for instance)
  65443. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65444. * @param instanced defines if the vertex buffer contains indexed data
  65445. * @param useBytes defines if the offset and stride are in bytes
  65446. * @returns the new vertex buffer
  65447. */
  65448. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65449. /**
  65450. * Gets a boolean indicating if the Buffer is updatable?
  65451. * @returns true if the buffer is updatable
  65452. */
  65453. isUpdatable(): boolean;
  65454. /**
  65455. * Gets current buffer's data
  65456. * @returns a DataArray or null
  65457. */
  65458. getData(): Nullable<DataArray>;
  65459. /**
  65460. * Gets underlying native buffer
  65461. * @returns underlying native buffer
  65462. */
  65463. getBuffer(): Nullable<DataBuffer>;
  65464. /**
  65465. * Gets the stride in float32 units (i.e. byte stride / 4).
  65466. * May not be an integer if the byte stride is not divisible by 4.
  65467. * DEPRECATED. Use byteStride instead.
  65468. * @returns the stride in float32 units
  65469. */
  65470. getStrideSize(): number;
  65471. /**
  65472. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65473. * @param data defines the data to store
  65474. */
  65475. create(data?: Nullable<DataArray>): void;
  65476. /** @hidden */
  65477. _rebuild(): void;
  65478. /**
  65479. * Update current buffer data
  65480. * @param data defines the data to store
  65481. */
  65482. update(data: DataArray): void;
  65483. /**
  65484. * Updates the data directly.
  65485. * @param data the new data
  65486. * @param offset the new offset
  65487. * @param vertexCount the vertex count (optional)
  65488. * @param useBytes set to true if the offset is in bytes
  65489. */
  65490. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65491. /**
  65492. * Release all resources
  65493. */
  65494. dispose(): void;
  65495. }
  65496. /**
  65497. * Specialized buffer used to store vertex data
  65498. */
  65499. export class VertexBuffer {
  65500. /** @hidden */
  65501. _buffer: Buffer;
  65502. private _kind;
  65503. private _size;
  65504. private _ownsBuffer;
  65505. private _instanced;
  65506. private _instanceDivisor;
  65507. /**
  65508. * The byte type.
  65509. */
  65510. static readonly BYTE: number;
  65511. /**
  65512. * The unsigned byte type.
  65513. */
  65514. static readonly UNSIGNED_BYTE: number;
  65515. /**
  65516. * The short type.
  65517. */
  65518. static readonly SHORT: number;
  65519. /**
  65520. * The unsigned short type.
  65521. */
  65522. static readonly UNSIGNED_SHORT: number;
  65523. /**
  65524. * The integer type.
  65525. */
  65526. static readonly INT: number;
  65527. /**
  65528. * The unsigned integer type.
  65529. */
  65530. static readonly UNSIGNED_INT: number;
  65531. /**
  65532. * The float type.
  65533. */
  65534. static readonly FLOAT: number;
  65535. /**
  65536. * Gets or sets the instance divisor when in instanced mode
  65537. */
  65538. instanceDivisor: number;
  65539. /**
  65540. * Gets the byte stride.
  65541. */
  65542. readonly byteStride: number;
  65543. /**
  65544. * Gets the byte offset.
  65545. */
  65546. readonly byteOffset: number;
  65547. /**
  65548. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65549. */
  65550. readonly normalized: boolean;
  65551. /**
  65552. * Gets the data type of each component in the array.
  65553. */
  65554. readonly type: number;
  65555. /**
  65556. * Constructor
  65557. * @param engine the engine
  65558. * @param data the data to use for this vertex buffer
  65559. * @param kind the vertex buffer kind
  65560. * @param updatable whether the data is updatable
  65561. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65562. * @param stride the stride (optional)
  65563. * @param instanced whether the buffer is instanced (optional)
  65564. * @param offset the offset of the data (optional)
  65565. * @param size the number of components (optional)
  65566. * @param type the type of the component (optional)
  65567. * @param normalized whether the data contains normalized data (optional)
  65568. * @param useBytes set to true if stride and offset are in bytes (optional)
  65569. */
  65570. 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);
  65571. /** @hidden */
  65572. _rebuild(): void;
  65573. /**
  65574. * Returns the kind of the VertexBuffer (string)
  65575. * @returns a string
  65576. */
  65577. getKind(): string;
  65578. /**
  65579. * Gets a boolean indicating if the VertexBuffer is updatable?
  65580. * @returns true if the buffer is updatable
  65581. */
  65582. isUpdatable(): boolean;
  65583. /**
  65584. * Gets current buffer's data
  65585. * @returns a DataArray or null
  65586. */
  65587. getData(): Nullable<DataArray>;
  65588. /**
  65589. * Gets underlying native buffer
  65590. * @returns underlying native buffer
  65591. */
  65592. getBuffer(): Nullable<DataBuffer>;
  65593. /**
  65594. * Gets the stride in float32 units (i.e. byte stride / 4).
  65595. * May not be an integer if the byte stride is not divisible by 4.
  65596. * DEPRECATED. Use byteStride instead.
  65597. * @returns the stride in float32 units
  65598. */
  65599. getStrideSize(): number;
  65600. /**
  65601. * Returns the offset as a multiple of the type byte length.
  65602. * DEPRECATED. Use byteOffset instead.
  65603. * @returns the offset in bytes
  65604. */
  65605. getOffset(): number;
  65606. /**
  65607. * Returns the number of components per vertex attribute (integer)
  65608. * @returns the size in float
  65609. */
  65610. getSize(): number;
  65611. /**
  65612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65613. * @returns true if this buffer is instanced
  65614. */
  65615. getIsInstanced(): boolean;
  65616. /**
  65617. * Returns the instancing divisor, zero for non-instanced (integer).
  65618. * @returns a number
  65619. */
  65620. getInstanceDivisor(): number;
  65621. /**
  65622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65623. * @param data defines the data to store
  65624. */
  65625. create(data?: DataArray): void;
  65626. /**
  65627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65628. * This function will create a new buffer if the current one is not updatable
  65629. * @param data defines the data to store
  65630. */
  65631. update(data: DataArray): void;
  65632. /**
  65633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65634. * Returns the directly updated WebGLBuffer.
  65635. * @param data the new data
  65636. * @param offset the new offset
  65637. * @param useBytes set to true if the offset is in bytes
  65638. */
  65639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65640. /**
  65641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65642. */
  65643. dispose(): void;
  65644. /**
  65645. * Enumerates each value of this vertex buffer as numbers.
  65646. * @param count the number of values to enumerate
  65647. * @param callback the callback function called for each value
  65648. */
  65649. forEach(count: number, callback: (value: number, index: number) => void): void;
  65650. /**
  65651. * Positions
  65652. */
  65653. static readonly PositionKind: string;
  65654. /**
  65655. * Normals
  65656. */
  65657. static readonly NormalKind: string;
  65658. /**
  65659. * Tangents
  65660. */
  65661. static readonly TangentKind: string;
  65662. /**
  65663. * Texture coordinates
  65664. */
  65665. static readonly UVKind: string;
  65666. /**
  65667. * Texture coordinates 2
  65668. */
  65669. static readonly UV2Kind: string;
  65670. /**
  65671. * Texture coordinates 3
  65672. */
  65673. static readonly UV3Kind: string;
  65674. /**
  65675. * Texture coordinates 4
  65676. */
  65677. static readonly UV4Kind: string;
  65678. /**
  65679. * Texture coordinates 5
  65680. */
  65681. static readonly UV5Kind: string;
  65682. /**
  65683. * Texture coordinates 6
  65684. */
  65685. static readonly UV6Kind: string;
  65686. /**
  65687. * Colors
  65688. */
  65689. static readonly ColorKind: string;
  65690. /**
  65691. * Matrix indices (for bones)
  65692. */
  65693. static readonly MatricesIndicesKind: string;
  65694. /**
  65695. * Matrix weights (for bones)
  65696. */
  65697. static readonly MatricesWeightsKind: string;
  65698. /**
  65699. * Additional matrix indices (for bones)
  65700. */
  65701. static readonly MatricesIndicesExtraKind: string;
  65702. /**
  65703. * Additional matrix weights (for bones)
  65704. */
  65705. static readonly MatricesWeightsExtraKind: string;
  65706. /**
  65707. * Deduces the stride given a kind.
  65708. * @param kind The kind string to deduce
  65709. * @returns The deduced stride
  65710. */
  65711. static DeduceStride(kind: string): number;
  65712. /**
  65713. * Gets the byte length of the given type.
  65714. * @param type the type
  65715. * @returns the number of bytes
  65716. */
  65717. static GetTypeByteLength(type: number): number;
  65718. /**
  65719. * Enumerates each value of the given parameters as numbers.
  65720. * @param data the data to enumerate
  65721. * @param byteOffset the byte offset of the data
  65722. * @param byteStride the byte stride of the data
  65723. * @param componentCount the number of components per element
  65724. * @param componentType the type of the component
  65725. * @param count the total number of components
  65726. * @param normalized whether the data is normalized
  65727. * @param callback the callback function called for each value
  65728. */
  65729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65730. private static _GetFloatValue;
  65731. }
  65732. }
  65733. declare module BABYLON {
  65734. /**
  65735. * Class representing spherical harmonics coefficients to the 3rd degree
  65736. */
  65737. export class SphericalHarmonics {
  65738. /**
  65739. * Defines whether or not the harmonics have been prescaled for rendering.
  65740. */
  65741. preScaled: boolean;
  65742. /**
  65743. * The l0,0 coefficients of the spherical harmonics
  65744. */
  65745. l00: Vector3;
  65746. /**
  65747. * The l1,-1 coefficients of the spherical harmonics
  65748. */
  65749. l1_1: Vector3;
  65750. /**
  65751. * The l1,0 coefficients of the spherical harmonics
  65752. */
  65753. l10: Vector3;
  65754. /**
  65755. * The l1,1 coefficients of the spherical harmonics
  65756. */
  65757. l11: Vector3;
  65758. /**
  65759. * The l2,-2 coefficients of the spherical harmonics
  65760. */
  65761. l2_2: Vector3;
  65762. /**
  65763. * The l2,-1 coefficients of the spherical harmonics
  65764. */
  65765. l2_1: Vector3;
  65766. /**
  65767. * The l2,0 coefficients of the spherical harmonics
  65768. */
  65769. l20: Vector3;
  65770. /**
  65771. * The l2,1 coefficients of the spherical harmonics
  65772. */
  65773. l21: Vector3;
  65774. /**
  65775. * The l2,2 coefficients of the spherical harmonics
  65776. */
  65777. l22: Vector3;
  65778. /**
  65779. * Adds a light to the spherical harmonics
  65780. * @param direction the direction of the light
  65781. * @param color the color of the light
  65782. * @param deltaSolidAngle the delta solid angle of the light
  65783. */
  65784. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65785. /**
  65786. * Scales the spherical harmonics by the given amount
  65787. * @param scale the amount to scale
  65788. */
  65789. scaleInPlace(scale: number): void;
  65790. /**
  65791. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65792. *
  65793. * ```
  65794. * E_lm = A_l * L_lm
  65795. * ```
  65796. *
  65797. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65798. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65799. * the scaling factors are given in equation 9.
  65800. */
  65801. convertIncidentRadianceToIrradiance(): void;
  65802. /**
  65803. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65804. *
  65805. * ```
  65806. * L = (1/pi) * E * rho
  65807. * ```
  65808. *
  65809. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65810. */
  65811. convertIrradianceToLambertianRadiance(): void;
  65812. /**
  65813. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65814. * required operations at run time.
  65815. *
  65816. * This is simply done by scaling back the SH with Ylm constants parameter.
  65817. * The trigonometric part being applied by the shader at run time.
  65818. */
  65819. preScaleForRendering(): void;
  65820. /**
  65821. * Constructs a spherical harmonics from an array.
  65822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65823. * @returns the spherical harmonics
  65824. */
  65825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65826. /**
  65827. * Gets the spherical harmonics from polynomial
  65828. * @param polynomial the spherical polynomial
  65829. * @returns the spherical harmonics
  65830. */
  65831. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65832. }
  65833. /**
  65834. * Class representing spherical polynomial coefficients to the 3rd degree
  65835. */
  65836. export class SphericalPolynomial {
  65837. private _harmonics;
  65838. /**
  65839. * The spherical harmonics used to create the polynomials.
  65840. */
  65841. readonly preScaledHarmonics: SphericalHarmonics;
  65842. /**
  65843. * The x coefficients of the spherical polynomial
  65844. */
  65845. x: Vector3;
  65846. /**
  65847. * The y coefficients of the spherical polynomial
  65848. */
  65849. y: Vector3;
  65850. /**
  65851. * The z coefficients of the spherical polynomial
  65852. */
  65853. z: Vector3;
  65854. /**
  65855. * The xx coefficients of the spherical polynomial
  65856. */
  65857. xx: Vector3;
  65858. /**
  65859. * The yy coefficients of the spherical polynomial
  65860. */
  65861. yy: Vector3;
  65862. /**
  65863. * The zz coefficients of the spherical polynomial
  65864. */
  65865. zz: Vector3;
  65866. /**
  65867. * The xy coefficients of the spherical polynomial
  65868. */
  65869. xy: Vector3;
  65870. /**
  65871. * The yz coefficients of the spherical polynomial
  65872. */
  65873. yz: Vector3;
  65874. /**
  65875. * The zx coefficients of the spherical polynomial
  65876. */
  65877. zx: Vector3;
  65878. /**
  65879. * Adds an ambient color to the spherical polynomial
  65880. * @param color the color to add
  65881. */
  65882. addAmbient(color: Color3): void;
  65883. /**
  65884. * Scales the spherical polynomial by the given amount
  65885. * @param scale the amount to scale
  65886. */
  65887. scaleInPlace(scale: number): void;
  65888. /**
  65889. * Gets the spherical polynomial from harmonics
  65890. * @param harmonics the spherical harmonics
  65891. * @returns the spherical polynomial
  65892. */
  65893. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65894. /**
  65895. * Constructs a spherical polynomial from an array.
  65896. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65897. * @returns the spherical polynomial
  65898. */
  65899. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65900. }
  65901. }
  65902. declare module BABYLON {
  65903. /**
  65904. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65905. */
  65906. export interface CubeMapInfo {
  65907. /**
  65908. * The pixel array for the front face.
  65909. * This is stored in format, left to right, up to down format.
  65910. */
  65911. front: Nullable<ArrayBufferView>;
  65912. /**
  65913. * The pixel array for the back face.
  65914. * This is stored in format, left to right, up to down format.
  65915. */
  65916. back: Nullable<ArrayBufferView>;
  65917. /**
  65918. * The pixel array for the left face.
  65919. * This is stored in format, left to right, up to down format.
  65920. */
  65921. left: Nullable<ArrayBufferView>;
  65922. /**
  65923. * The pixel array for the right face.
  65924. * This is stored in format, left to right, up to down format.
  65925. */
  65926. right: Nullable<ArrayBufferView>;
  65927. /**
  65928. * The pixel array for the up face.
  65929. * This is stored in format, left to right, up to down format.
  65930. */
  65931. up: Nullable<ArrayBufferView>;
  65932. /**
  65933. * The pixel array for the down face.
  65934. * This is stored in format, left to right, up to down format.
  65935. */
  65936. down: Nullable<ArrayBufferView>;
  65937. /**
  65938. * The size of the cubemap stored.
  65939. *
  65940. * Each faces will be size * size pixels.
  65941. */
  65942. size: number;
  65943. /**
  65944. * The format of the texture.
  65945. *
  65946. * RGBA, RGB.
  65947. */
  65948. format: number;
  65949. /**
  65950. * The type of the texture data.
  65951. *
  65952. * UNSIGNED_INT, FLOAT.
  65953. */
  65954. type: number;
  65955. /**
  65956. * Specifies whether the texture is in gamma space.
  65957. */
  65958. gammaSpace: boolean;
  65959. }
  65960. /**
  65961. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65962. */
  65963. export class PanoramaToCubeMapTools {
  65964. private static FACE_FRONT;
  65965. private static FACE_BACK;
  65966. private static FACE_RIGHT;
  65967. private static FACE_LEFT;
  65968. private static FACE_DOWN;
  65969. private static FACE_UP;
  65970. /**
  65971. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65972. *
  65973. * @param float32Array The source data.
  65974. * @param inputWidth The width of the input panorama.
  65975. * @param inputHeight The height of the input panorama.
  65976. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65977. * @return The cubemap data
  65978. */
  65979. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65980. private static CreateCubemapTexture;
  65981. private static CalcProjectionSpherical;
  65982. }
  65983. }
  65984. declare module BABYLON {
  65985. /**
  65986. * Helper class dealing with the extraction of spherical polynomial dataArray
  65987. * from a cube map.
  65988. */
  65989. export class CubeMapToSphericalPolynomialTools {
  65990. private static FileFaces;
  65991. /**
  65992. * Converts a texture to the according Spherical Polynomial data.
  65993. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65994. *
  65995. * @param texture The texture to extract the information from.
  65996. * @return The Spherical Polynomial data.
  65997. */
  65998. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65999. /**
  66000. * Converts a cubemap to the according Spherical Polynomial data.
  66001. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66002. *
  66003. * @param cubeInfo The Cube map to extract the information from.
  66004. * @return The Spherical Polynomial data.
  66005. */
  66006. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66007. }
  66008. }
  66009. declare module BABYLON {
  66010. /**
  66011. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66012. * during the life time of the application.
  66013. */
  66014. export class EngineStore {
  66015. /** Gets the list of created engines */
  66016. static Instances: Engine[];
  66017. /**
  66018. * Gets the latest created engine
  66019. */
  66020. static readonly LastCreatedEngine: Nullable<Engine>;
  66021. /**
  66022. * Gets the latest created scene
  66023. */
  66024. static readonly LastCreatedScene: Nullable<Scene>;
  66025. }
  66026. }
  66027. declare module BABYLON {
  66028. /**
  66029. * Define options used to create a render target texture
  66030. */
  66031. export class RenderTargetCreationOptions {
  66032. /**
  66033. * Specifies is mipmaps must be generated
  66034. */
  66035. generateMipMaps?: boolean;
  66036. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66037. generateDepthBuffer?: boolean;
  66038. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66039. generateStencilBuffer?: boolean;
  66040. /** Defines texture type (int by default) */
  66041. type?: number;
  66042. /** Defines sampling mode (trilinear by default) */
  66043. samplingMode?: number;
  66044. /** Defines format (RGBA by default) */
  66045. format?: number;
  66046. }
  66047. }
  66048. declare module BABYLON {
  66049. /**
  66050. * @hidden
  66051. **/
  66052. export class _AlphaState {
  66053. private _isAlphaBlendDirty;
  66054. private _isBlendFunctionParametersDirty;
  66055. private _isBlendEquationParametersDirty;
  66056. private _isBlendConstantsDirty;
  66057. private _alphaBlend;
  66058. private _blendFunctionParameters;
  66059. private _blendEquationParameters;
  66060. private _blendConstants;
  66061. /**
  66062. * Initializes the state.
  66063. */
  66064. constructor();
  66065. readonly isDirty: boolean;
  66066. alphaBlend: boolean;
  66067. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66068. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66069. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66070. reset(): void;
  66071. apply(gl: WebGLRenderingContext): void;
  66072. }
  66073. }
  66074. declare module BABYLON {
  66075. /**
  66076. * @hidden
  66077. **/
  66078. export class _DepthCullingState {
  66079. private _isDepthTestDirty;
  66080. private _isDepthMaskDirty;
  66081. private _isDepthFuncDirty;
  66082. private _isCullFaceDirty;
  66083. private _isCullDirty;
  66084. private _isZOffsetDirty;
  66085. private _isFrontFaceDirty;
  66086. private _depthTest;
  66087. private _depthMask;
  66088. private _depthFunc;
  66089. private _cull;
  66090. private _cullFace;
  66091. private _zOffset;
  66092. private _frontFace;
  66093. /**
  66094. * Initializes the state.
  66095. */
  66096. constructor();
  66097. readonly isDirty: boolean;
  66098. zOffset: number;
  66099. cullFace: Nullable<number>;
  66100. cull: Nullable<boolean>;
  66101. depthFunc: Nullable<number>;
  66102. depthMask: boolean;
  66103. depthTest: boolean;
  66104. frontFace: Nullable<number>;
  66105. reset(): void;
  66106. apply(gl: WebGLRenderingContext): void;
  66107. }
  66108. }
  66109. declare module BABYLON {
  66110. /**
  66111. * @hidden
  66112. **/
  66113. export class _StencilState {
  66114. /** 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 */
  66115. static readonly ALWAYS: number;
  66116. /** Passed to stencilOperation to specify that stencil value must be kept */
  66117. static readonly KEEP: number;
  66118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66119. static readonly REPLACE: number;
  66120. private _isStencilTestDirty;
  66121. private _isStencilMaskDirty;
  66122. private _isStencilFuncDirty;
  66123. private _isStencilOpDirty;
  66124. private _stencilTest;
  66125. private _stencilMask;
  66126. private _stencilFunc;
  66127. private _stencilFuncRef;
  66128. private _stencilFuncMask;
  66129. private _stencilOpStencilFail;
  66130. private _stencilOpDepthFail;
  66131. private _stencilOpStencilDepthPass;
  66132. readonly isDirty: boolean;
  66133. stencilFunc: number;
  66134. stencilFuncRef: number;
  66135. stencilFuncMask: number;
  66136. stencilOpStencilFail: number;
  66137. stencilOpDepthFail: number;
  66138. stencilOpStencilDepthPass: number;
  66139. stencilMask: number;
  66140. stencilTest: boolean;
  66141. constructor();
  66142. reset(): void;
  66143. apply(gl: WebGLRenderingContext): void;
  66144. }
  66145. }
  66146. declare module BABYLON {
  66147. /**
  66148. * @hidden
  66149. **/
  66150. export class _TimeToken {
  66151. _startTimeQuery: Nullable<WebGLQuery>;
  66152. _endTimeQuery: Nullable<WebGLQuery>;
  66153. _timeElapsedQuery: Nullable<WebGLQuery>;
  66154. _timeElapsedQueryEnded: boolean;
  66155. }
  66156. }
  66157. declare module BABYLON {
  66158. /**
  66159. * Class used to store data associated with WebGL texture data for the engine
  66160. * This class should not be used directly
  66161. */
  66162. export class InternalTexture {
  66163. /** hidden */
  66164. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66165. /**
  66166. * The source of the texture data is unknown
  66167. */
  66168. static DATASOURCE_UNKNOWN: number;
  66169. /**
  66170. * Texture data comes from an URL
  66171. */
  66172. static DATASOURCE_URL: number;
  66173. /**
  66174. * Texture data is only used for temporary storage
  66175. */
  66176. static DATASOURCE_TEMP: number;
  66177. /**
  66178. * Texture data comes from raw data (ArrayBuffer)
  66179. */
  66180. static DATASOURCE_RAW: number;
  66181. /**
  66182. * Texture content is dynamic (video or dynamic texture)
  66183. */
  66184. static DATASOURCE_DYNAMIC: number;
  66185. /**
  66186. * Texture content is generated by rendering to it
  66187. */
  66188. static DATASOURCE_RENDERTARGET: number;
  66189. /**
  66190. * Texture content is part of a multi render target process
  66191. */
  66192. static DATASOURCE_MULTIRENDERTARGET: number;
  66193. /**
  66194. * Texture data comes from a cube data file
  66195. */
  66196. static DATASOURCE_CUBE: number;
  66197. /**
  66198. * Texture data comes from a raw cube data
  66199. */
  66200. static DATASOURCE_CUBERAW: number;
  66201. /**
  66202. * Texture data come from a prefiltered cube data file
  66203. */
  66204. static DATASOURCE_CUBEPREFILTERED: number;
  66205. /**
  66206. * Texture content is raw 3D data
  66207. */
  66208. static DATASOURCE_RAW3D: number;
  66209. /**
  66210. * Texture content is a depth texture
  66211. */
  66212. static DATASOURCE_DEPTHTEXTURE: number;
  66213. /**
  66214. * Texture data comes from a raw cube data encoded with RGBD
  66215. */
  66216. static DATASOURCE_CUBERAW_RGBD: number;
  66217. /**
  66218. * Defines if the texture is ready
  66219. */
  66220. isReady: boolean;
  66221. /**
  66222. * Defines if the texture is a cube texture
  66223. */
  66224. isCube: boolean;
  66225. /**
  66226. * Defines if the texture contains 3D data
  66227. */
  66228. is3D: boolean;
  66229. /**
  66230. * Defines if the texture contains multiview data
  66231. */
  66232. isMultiview: boolean;
  66233. /**
  66234. * Gets the URL used to load this texture
  66235. */
  66236. url: string;
  66237. /**
  66238. * Gets the sampling mode of the texture
  66239. */
  66240. samplingMode: number;
  66241. /**
  66242. * Gets a boolean indicating if the texture needs mipmaps generation
  66243. */
  66244. generateMipMaps: boolean;
  66245. /**
  66246. * Gets the number of samples used by the texture (WebGL2+ only)
  66247. */
  66248. samples: number;
  66249. /**
  66250. * Gets the type of the texture (int, float...)
  66251. */
  66252. type: number;
  66253. /**
  66254. * Gets the format of the texture (RGB, RGBA...)
  66255. */
  66256. format: number;
  66257. /**
  66258. * Observable called when the texture is loaded
  66259. */
  66260. onLoadedObservable: Observable<InternalTexture>;
  66261. /**
  66262. * Gets the width of the texture
  66263. */
  66264. width: number;
  66265. /**
  66266. * Gets the height of the texture
  66267. */
  66268. height: number;
  66269. /**
  66270. * Gets the depth of the texture
  66271. */
  66272. depth: number;
  66273. /**
  66274. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66275. */
  66276. baseWidth: number;
  66277. /**
  66278. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66279. */
  66280. baseHeight: number;
  66281. /**
  66282. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66283. */
  66284. baseDepth: number;
  66285. /**
  66286. * Gets a boolean indicating if the texture is inverted on Y axis
  66287. */
  66288. invertY: boolean;
  66289. /** @hidden */
  66290. _invertVScale: boolean;
  66291. /** @hidden */
  66292. _associatedChannel: number;
  66293. /** @hidden */
  66294. _dataSource: number;
  66295. /** @hidden */
  66296. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66297. /** @hidden */
  66298. _bufferView: Nullable<ArrayBufferView>;
  66299. /** @hidden */
  66300. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66301. /** @hidden */
  66302. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66303. /** @hidden */
  66304. _size: number;
  66305. /** @hidden */
  66306. _extension: string;
  66307. /** @hidden */
  66308. _files: Nullable<string[]>;
  66309. /** @hidden */
  66310. _workingCanvas: Nullable<HTMLCanvasElement>;
  66311. /** @hidden */
  66312. _workingContext: Nullable<CanvasRenderingContext2D>;
  66313. /** @hidden */
  66314. _framebuffer: Nullable<WebGLFramebuffer>;
  66315. /** @hidden */
  66316. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66317. /** @hidden */
  66318. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66319. /** @hidden */
  66320. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66321. /** @hidden */
  66322. _attachments: Nullable<number[]>;
  66323. /** @hidden */
  66324. _cachedCoordinatesMode: Nullable<number>;
  66325. /** @hidden */
  66326. _cachedWrapU: Nullable<number>;
  66327. /** @hidden */
  66328. _cachedWrapV: Nullable<number>;
  66329. /** @hidden */
  66330. _cachedWrapR: Nullable<number>;
  66331. /** @hidden */
  66332. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66333. /** @hidden */
  66334. _isDisabled: boolean;
  66335. /** @hidden */
  66336. _compression: Nullable<string>;
  66337. /** @hidden */
  66338. _generateStencilBuffer: boolean;
  66339. /** @hidden */
  66340. _generateDepthBuffer: boolean;
  66341. /** @hidden */
  66342. _comparisonFunction: number;
  66343. /** @hidden */
  66344. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66345. /** @hidden */
  66346. _lodGenerationScale: number;
  66347. /** @hidden */
  66348. _lodGenerationOffset: number;
  66349. /** @hidden */
  66350. _colorTextureArray: Nullable<WebGLTexture>;
  66351. /** @hidden */
  66352. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66353. /** @hidden */
  66354. _lodTextureHigh: Nullable<BaseTexture>;
  66355. /** @hidden */
  66356. _lodTextureMid: Nullable<BaseTexture>;
  66357. /** @hidden */
  66358. _lodTextureLow: Nullable<BaseTexture>;
  66359. /** @hidden */
  66360. _isRGBD: boolean;
  66361. /** @hidden */
  66362. _webGLTexture: Nullable<WebGLTexture>;
  66363. /** @hidden */
  66364. _references: number;
  66365. private _engine;
  66366. /**
  66367. * Gets the Engine the texture belongs to.
  66368. * @returns The babylon engine
  66369. */
  66370. getEngine(): Engine;
  66371. /**
  66372. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66373. */
  66374. readonly dataSource: number;
  66375. /**
  66376. * Creates a new InternalTexture
  66377. * @param engine defines the engine to use
  66378. * @param dataSource defines the type of data that will be used
  66379. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66380. */
  66381. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66382. /**
  66383. * Increments the number of references (ie. the number of Texture that point to it)
  66384. */
  66385. incrementReferences(): void;
  66386. /**
  66387. * Change the size of the texture (not the size of the content)
  66388. * @param width defines the new width
  66389. * @param height defines the new height
  66390. * @param depth defines the new depth (1 by default)
  66391. */
  66392. updateSize(width: int, height: int, depth?: int): void;
  66393. /** @hidden */
  66394. _rebuild(): void;
  66395. /** @hidden */
  66396. _swapAndDie(target: InternalTexture): void;
  66397. /**
  66398. * Dispose the current allocated resources
  66399. */
  66400. dispose(): void;
  66401. }
  66402. }
  66403. declare module BABYLON {
  66404. /**
  66405. * This represents the main contract an easing function should follow.
  66406. * Easing functions are used throughout the animation system.
  66407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66408. */
  66409. export interface IEasingFunction {
  66410. /**
  66411. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66412. * of the easing function.
  66413. * The link below provides some of the most common examples of easing functions.
  66414. * @see https://easings.net/
  66415. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66416. * @returns the corresponding value on the curve defined by the easing function
  66417. */
  66418. ease(gradient: number): number;
  66419. }
  66420. /**
  66421. * Base class used for every default easing function.
  66422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66423. */
  66424. export class EasingFunction implements IEasingFunction {
  66425. /**
  66426. * Interpolation follows the mathematical formula associated with the easing function.
  66427. */
  66428. static readonly EASINGMODE_EASEIN: number;
  66429. /**
  66430. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66431. */
  66432. static readonly EASINGMODE_EASEOUT: number;
  66433. /**
  66434. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66435. */
  66436. static readonly EASINGMODE_EASEINOUT: number;
  66437. private _easingMode;
  66438. /**
  66439. * Sets the easing mode of the current function.
  66440. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66441. */
  66442. setEasingMode(easingMode: number): void;
  66443. /**
  66444. * Gets the current easing mode.
  66445. * @returns the easing mode
  66446. */
  66447. getEasingMode(): number;
  66448. /**
  66449. * @hidden
  66450. */
  66451. easeInCore(gradient: number): number;
  66452. /**
  66453. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66454. * of the easing function.
  66455. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66456. * @returns the corresponding value on the curve defined by the easing function
  66457. */
  66458. ease(gradient: number): number;
  66459. }
  66460. /**
  66461. * Easing function with a circle shape (see link below).
  66462. * @see https://easings.net/#easeInCirc
  66463. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66464. */
  66465. export class CircleEase extends EasingFunction implements IEasingFunction {
  66466. /** @hidden */
  66467. easeInCore(gradient: number): number;
  66468. }
  66469. /**
  66470. * Easing function with a ease back shape (see link below).
  66471. * @see https://easings.net/#easeInBack
  66472. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66473. */
  66474. export class BackEase extends EasingFunction implements IEasingFunction {
  66475. /** Defines the amplitude of the function */
  66476. amplitude: number;
  66477. /**
  66478. * Instantiates a back ease easing
  66479. * @see https://easings.net/#easeInBack
  66480. * @param amplitude Defines the amplitude of the function
  66481. */
  66482. constructor(
  66483. /** Defines the amplitude of the function */
  66484. amplitude?: number);
  66485. /** @hidden */
  66486. easeInCore(gradient: number): number;
  66487. }
  66488. /**
  66489. * Easing function with a bouncing shape (see link below).
  66490. * @see https://easings.net/#easeInBounce
  66491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66492. */
  66493. export class BounceEase extends EasingFunction implements IEasingFunction {
  66494. /** Defines the number of bounces */
  66495. bounces: number;
  66496. /** Defines the amplitude of the bounce */
  66497. bounciness: number;
  66498. /**
  66499. * Instantiates a bounce easing
  66500. * @see https://easings.net/#easeInBounce
  66501. * @param bounces Defines the number of bounces
  66502. * @param bounciness Defines the amplitude of the bounce
  66503. */
  66504. constructor(
  66505. /** Defines the number of bounces */
  66506. bounces?: number,
  66507. /** Defines the amplitude of the bounce */
  66508. bounciness?: number);
  66509. /** @hidden */
  66510. easeInCore(gradient: number): number;
  66511. }
  66512. /**
  66513. * Easing function with a power of 3 shape (see link below).
  66514. * @see https://easings.net/#easeInCubic
  66515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66516. */
  66517. export class CubicEase extends EasingFunction implements IEasingFunction {
  66518. /** @hidden */
  66519. easeInCore(gradient: number): number;
  66520. }
  66521. /**
  66522. * Easing function with an elastic shape (see link below).
  66523. * @see https://easings.net/#easeInElastic
  66524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66525. */
  66526. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66527. /** Defines the number of oscillations*/
  66528. oscillations: number;
  66529. /** Defines the amplitude of the oscillations*/
  66530. springiness: number;
  66531. /**
  66532. * Instantiates an elastic easing function
  66533. * @see https://easings.net/#easeInElastic
  66534. * @param oscillations Defines the number of oscillations
  66535. * @param springiness Defines the amplitude of the oscillations
  66536. */
  66537. constructor(
  66538. /** Defines the number of oscillations*/
  66539. oscillations?: number,
  66540. /** Defines the amplitude of the oscillations*/
  66541. springiness?: number);
  66542. /** @hidden */
  66543. easeInCore(gradient: number): number;
  66544. }
  66545. /**
  66546. * Easing function with an exponential shape (see link below).
  66547. * @see https://easings.net/#easeInExpo
  66548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66549. */
  66550. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66551. /** Defines the exponent of the function */
  66552. exponent: number;
  66553. /**
  66554. * Instantiates an exponential easing function
  66555. * @see https://easings.net/#easeInExpo
  66556. * @param exponent Defines the exponent of the function
  66557. */
  66558. constructor(
  66559. /** Defines the exponent of the function */
  66560. exponent?: number);
  66561. /** @hidden */
  66562. easeInCore(gradient: number): number;
  66563. }
  66564. /**
  66565. * Easing function with a power shape (see link below).
  66566. * @see https://easings.net/#easeInQuad
  66567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66568. */
  66569. export class PowerEase extends EasingFunction implements IEasingFunction {
  66570. /** Defines the power of the function */
  66571. power: number;
  66572. /**
  66573. * Instantiates an power base easing function
  66574. * @see https://easings.net/#easeInQuad
  66575. * @param power Defines the power of the function
  66576. */
  66577. constructor(
  66578. /** Defines the power of the function */
  66579. power?: number);
  66580. /** @hidden */
  66581. easeInCore(gradient: number): number;
  66582. }
  66583. /**
  66584. * Easing function with a power of 2 shape (see link below).
  66585. * @see https://easings.net/#easeInQuad
  66586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66587. */
  66588. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66589. /** @hidden */
  66590. easeInCore(gradient: number): number;
  66591. }
  66592. /**
  66593. * Easing function with a power of 4 shape (see link below).
  66594. * @see https://easings.net/#easeInQuart
  66595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66596. */
  66597. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66598. /** @hidden */
  66599. easeInCore(gradient: number): number;
  66600. }
  66601. /**
  66602. * Easing function with a power of 5 shape (see link below).
  66603. * @see https://easings.net/#easeInQuint
  66604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66605. */
  66606. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66607. /** @hidden */
  66608. easeInCore(gradient: number): number;
  66609. }
  66610. /**
  66611. * Easing function with a sin shape (see link below).
  66612. * @see https://easings.net/#easeInSine
  66613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66614. */
  66615. export class SineEase extends EasingFunction implements IEasingFunction {
  66616. /** @hidden */
  66617. easeInCore(gradient: number): number;
  66618. }
  66619. /**
  66620. * Easing function with a bezier shape (see link below).
  66621. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66623. */
  66624. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66625. /** Defines the x component of the start tangent in the bezier curve */
  66626. x1: number;
  66627. /** Defines the y component of the start tangent in the bezier curve */
  66628. y1: number;
  66629. /** Defines the x component of the end tangent in the bezier curve */
  66630. x2: number;
  66631. /** Defines the y component of the end tangent in the bezier curve */
  66632. y2: number;
  66633. /**
  66634. * Instantiates a bezier function
  66635. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66636. * @param x1 Defines the x component of the start tangent in the bezier curve
  66637. * @param y1 Defines the y component of the start tangent in the bezier curve
  66638. * @param x2 Defines the x component of the end tangent in the bezier curve
  66639. * @param y2 Defines the y component of the end tangent in the bezier curve
  66640. */
  66641. constructor(
  66642. /** Defines the x component of the start tangent in the bezier curve */
  66643. x1?: number,
  66644. /** Defines the y component of the start tangent in the bezier curve */
  66645. y1?: number,
  66646. /** Defines the x component of the end tangent in the bezier curve */
  66647. x2?: number,
  66648. /** Defines the y component of the end tangent in the bezier curve */
  66649. y2?: number);
  66650. /** @hidden */
  66651. easeInCore(gradient: number): number;
  66652. }
  66653. }
  66654. declare module BABYLON {
  66655. /**
  66656. * Defines an interface which represents an animation key frame
  66657. */
  66658. export interface IAnimationKey {
  66659. /**
  66660. * Frame of the key frame
  66661. */
  66662. frame: number;
  66663. /**
  66664. * Value at the specifies key frame
  66665. */
  66666. value: any;
  66667. /**
  66668. * The input tangent for the cubic hermite spline
  66669. */
  66670. inTangent?: any;
  66671. /**
  66672. * The output tangent for the cubic hermite spline
  66673. */
  66674. outTangent?: any;
  66675. /**
  66676. * The animation interpolation type
  66677. */
  66678. interpolation?: AnimationKeyInterpolation;
  66679. }
  66680. /**
  66681. * Enum for the animation key frame interpolation type
  66682. */
  66683. export enum AnimationKeyInterpolation {
  66684. /**
  66685. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66686. */
  66687. STEP = 1
  66688. }
  66689. }
  66690. declare module BABYLON {
  66691. /**
  66692. * Represents the range of an animation
  66693. */
  66694. export class AnimationRange {
  66695. /**The name of the animation range**/
  66696. name: string;
  66697. /**The starting frame of the animation */
  66698. from: number;
  66699. /**The ending frame of the animation*/
  66700. to: number;
  66701. /**
  66702. * Initializes the range of an animation
  66703. * @param name The name of the animation range
  66704. * @param from The starting frame of the animation
  66705. * @param to The ending frame of the animation
  66706. */
  66707. constructor(
  66708. /**The name of the animation range**/
  66709. name: string,
  66710. /**The starting frame of the animation */
  66711. from: number,
  66712. /**The ending frame of the animation*/
  66713. to: number);
  66714. /**
  66715. * Makes a copy of the animation range
  66716. * @returns A copy of the animation range
  66717. */
  66718. clone(): AnimationRange;
  66719. }
  66720. }
  66721. declare module BABYLON {
  66722. /**
  66723. * Composed of a frame, and an action function
  66724. */
  66725. export class AnimationEvent {
  66726. /** The frame for which the event is triggered **/
  66727. frame: number;
  66728. /** The event to perform when triggered **/
  66729. action: (currentFrame: number) => void;
  66730. /** Specifies if the event should be triggered only once**/
  66731. onlyOnce?: boolean | undefined;
  66732. /**
  66733. * Specifies if the animation event is done
  66734. */
  66735. isDone: boolean;
  66736. /**
  66737. * Initializes the animation event
  66738. * @param frame The frame for which the event is triggered
  66739. * @param action The event to perform when triggered
  66740. * @param onlyOnce Specifies if the event should be triggered only once
  66741. */
  66742. constructor(
  66743. /** The frame for which the event is triggered **/
  66744. frame: number,
  66745. /** The event to perform when triggered **/
  66746. action: (currentFrame: number) => void,
  66747. /** Specifies if the event should be triggered only once**/
  66748. onlyOnce?: boolean | undefined);
  66749. /** @hidden */
  66750. _clone(): AnimationEvent;
  66751. }
  66752. }
  66753. declare module BABYLON {
  66754. /**
  66755. * Interface used to define a behavior
  66756. */
  66757. export interface Behavior<T> {
  66758. /** gets or sets behavior's name */
  66759. name: string;
  66760. /**
  66761. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66762. */
  66763. init(): void;
  66764. /**
  66765. * Called when the behavior is attached to a target
  66766. * @param target defines the target where the behavior is attached to
  66767. */
  66768. attach(target: T): void;
  66769. /**
  66770. * Called when the behavior is detached from its target
  66771. */
  66772. detach(): void;
  66773. }
  66774. /**
  66775. * Interface implemented by classes supporting behaviors
  66776. */
  66777. export interface IBehaviorAware<T> {
  66778. /**
  66779. * Attach a behavior
  66780. * @param behavior defines the behavior to attach
  66781. * @returns the current host
  66782. */
  66783. addBehavior(behavior: Behavior<T>): T;
  66784. /**
  66785. * Remove a behavior from the current object
  66786. * @param behavior defines the behavior to detach
  66787. * @returns the current host
  66788. */
  66789. removeBehavior(behavior: Behavior<T>): T;
  66790. /**
  66791. * Gets a behavior using its name to search
  66792. * @param name defines the name to search
  66793. * @returns the behavior or null if not found
  66794. */
  66795. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66796. }
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * @hidden
  66801. */
  66802. export class IntersectionInfo {
  66803. bu: Nullable<number>;
  66804. bv: Nullable<number>;
  66805. distance: number;
  66806. faceId: number;
  66807. subMeshId: number;
  66808. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66809. }
  66810. }
  66811. declare module BABYLON {
  66812. /**
  66813. * Class used to store bounding sphere information
  66814. */
  66815. export class BoundingSphere {
  66816. /**
  66817. * Gets the center of the bounding sphere in local space
  66818. */
  66819. readonly center: Vector3;
  66820. /**
  66821. * Radius of the bounding sphere in local space
  66822. */
  66823. radius: number;
  66824. /**
  66825. * Gets the center of the bounding sphere in world space
  66826. */
  66827. readonly centerWorld: Vector3;
  66828. /**
  66829. * Radius of the bounding sphere in world space
  66830. */
  66831. radiusWorld: number;
  66832. /**
  66833. * Gets the minimum vector in local space
  66834. */
  66835. readonly minimum: Vector3;
  66836. /**
  66837. * Gets the maximum vector in local space
  66838. */
  66839. readonly maximum: Vector3;
  66840. private _worldMatrix;
  66841. private static readonly TmpVector3;
  66842. /**
  66843. * Creates a new bounding sphere
  66844. * @param min defines the minimum vector (in local space)
  66845. * @param max defines the maximum vector (in local space)
  66846. * @param worldMatrix defines the new world matrix
  66847. */
  66848. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66849. /**
  66850. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66851. * @param min defines the new minimum vector (in local space)
  66852. * @param max defines the new maximum vector (in local space)
  66853. * @param worldMatrix defines the new world matrix
  66854. */
  66855. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66856. /**
  66857. * Scale the current bounding sphere by applying a scale factor
  66858. * @param factor defines the scale factor to apply
  66859. * @returns the current bounding box
  66860. */
  66861. scale(factor: number): BoundingSphere;
  66862. /**
  66863. * Gets the world matrix of the bounding box
  66864. * @returns a matrix
  66865. */
  66866. getWorldMatrix(): DeepImmutable<Matrix>;
  66867. /** @hidden */
  66868. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66869. /**
  66870. * Tests if the bounding sphere is intersecting the frustum planes
  66871. * @param frustumPlanes defines the frustum planes to test
  66872. * @returns true if there is an intersection
  66873. */
  66874. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66875. /**
  66876. * Tests if the bounding sphere center is in between the frustum planes.
  66877. * Used for optimistic fast inclusion.
  66878. * @param frustumPlanes defines the frustum planes to test
  66879. * @returns true if the sphere center is in between the frustum planes
  66880. */
  66881. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66882. /**
  66883. * Tests if a point is inside the bounding sphere
  66884. * @param point defines the point to test
  66885. * @returns true if the point is inside the bounding sphere
  66886. */
  66887. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66888. /**
  66889. * Checks if two sphere intersct
  66890. * @param sphere0 sphere 0
  66891. * @param sphere1 sphere 1
  66892. * @returns true if the speres intersect
  66893. */
  66894. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66895. }
  66896. }
  66897. declare module BABYLON {
  66898. /**
  66899. * Class used to store bounding box information
  66900. */
  66901. export class BoundingBox implements ICullable {
  66902. /**
  66903. * Gets the 8 vectors representing the bounding box in local space
  66904. */
  66905. readonly vectors: Vector3[];
  66906. /**
  66907. * Gets the center of the bounding box in local space
  66908. */
  66909. readonly center: Vector3;
  66910. /**
  66911. * Gets the center of the bounding box in world space
  66912. */
  66913. readonly centerWorld: Vector3;
  66914. /**
  66915. * Gets the extend size in local space
  66916. */
  66917. readonly extendSize: Vector3;
  66918. /**
  66919. * Gets the extend size in world space
  66920. */
  66921. readonly extendSizeWorld: Vector3;
  66922. /**
  66923. * Gets the OBB (object bounding box) directions
  66924. */
  66925. readonly directions: Vector3[];
  66926. /**
  66927. * Gets the 8 vectors representing the bounding box in world space
  66928. */
  66929. readonly vectorsWorld: Vector3[];
  66930. /**
  66931. * Gets the minimum vector in world space
  66932. */
  66933. readonly minimumWorld: Vector3;
  66934. /**
  66935. * Gets the maximum vector in world space
  66936. */
  66937. readonly maximumWorld: Vector3;
  66938. /**
  66939. * Gets the minimum vector in local space
  66940. */
  66941. readonly minimum: Vector3;
  66942. /**
  66943. * Gets the maximum vector in local space
  66944. */
  66945. readonly maximum: Vector3;
  66946. private _worldMatrix;
  66947. private static readonly TmpVector3;
  66948. /**
  66949. * @hidden
  66950. */
  66951. _tag: number;
  66952. /**
  66953. * Creates a new bounding box
  66954. * @param min defines the minimum vector (in local space)
  66955. * @param max defines the maximum vector (in local space)
  66956. * @param worldMatrix defines the new world matrix
  66957. */
  66958. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66959. /**
  66960. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66961. * @param min defines the new minimum vector (in local space)
  66962. * @param max defines the new maximum vector (in local space)
  66963. * @param worldMatrix defines the new world matrix
  66964. */
  66965. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66966. /**
  66967. * Scale the current bounding box by applying a scale factor
  66968. * @param factor defines the scale factor to apply
  66969. * @returns the current bounding box
  66970. */
  66971. scale(factor: number): BoundingBox;
  66972. /**
  66973. * Gets the world matrix of the bounding box
  66974. * @returns a matrix
  66975. */
  66976. getWorldMatrix(): DeepImmutable<Matrix>;
  66977. /** @hidden */
  66978. _update(world: DeepImmutable<Matrix>): void;
  66979. /**
  66980. * Tests if the bounding box is intersecting the frustum planes
  66981. * @param frustumPlanes defines the frustum planes to test
  66982. * @returns true if there is an intersection
  66983. */
  66984. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66985. /**
  66986. * Tests if the bounding box is entirely inside the frustum planes
  66987. * @param frustumPlanes defines the frustum planes to test
  66988. * @returns true if there is an inclusion
  66989. */
  66990. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66991. /**
  66992. * Tests if a point is inside the bounding box
  66993. * @param point defines the point to test
  66994. * @returns true if the point is inside the bounding box
  66995. */
  66996. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66997. /**
  66998. * Tests if the bounding box intersects with a bounding sphere
  66999. * @param sphere defines the sphere to test
  67000. * @returns true if there is an intersection
  67001. */
  67002. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67003. /**
  67004. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67005. * @param min defines the min vector to use
  67006. * @param max defines the max vector to use
  67007. * @returns true if there is an intersection
  67008. */
  67009. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67010. /**
  67011. * Tests if two bounding boxes are intersections
  67012. * @param box0 defines the first box to test
  67013. * @param box1 defines the second box to test
  67014. * @returns true if there is an intersection
  67015. */
  67016. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67017. /**
  67018. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67019. * @param minPoint defines the minimum vector of the bounding box
  67020. * @param maxPoint defines the maximum vector of the bounding box
  67021. * @param sphereCenter defines the sphere center
  67022. * @param sphereRadius defines the sphere radius
  67023. * @returns true if there is an intersection
  67024. */
  67025. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67026. /**
  67027. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67028. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67029. * @param frustumPlanes defines the frustum planes to test
  67030. * @return true if there is an inclusion
  67031. */
  67032. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67033. /**
  67034. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67035. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67036. * @param frustumPlanes defines the frustum planes to test
  67037. * @return true if there is an intersection
  67038. */
  67039. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67040. }
  67041. }
  67042. declare module BABYLON {
  67043. /** @hidden */
  67044. export class Collider {
  67045. /** Define if a collision was found */
  67046. collisionFound: boolean;
  67047. /**
  67048. * Define last intersection point in local space
  67049. */
  67050. intersectionPoint: Vector3;
  67051. /**
  67052. * Define last collided mesh
  67053. */
  67054. collidedMesh: Nullable<AbstractMesh>;
  67055. private _collisionPoint;
  67056. private _planeIntersectionPoint;
  67057. private _tempVector;
  67058. private _tempVector2;
  67059. private _tempVector3;
  67060. private _tempVector4;
  67061. private _edge;
  67062. private _baseToVertex;
  67063. private _destinationPoint;
  67064. private _slidePlaneNormal;
  67065. private _displacementVector;
  67066. /** @hidden */
  67067. _radius: Vector3;
  67068. /** @hidden */
  67069. _retry: number;
  67070. private _velocity;
  67071. private _basePoint;
  67072. private _epsilon;
  67073. /** @hidden */
  67074. _velocityWorldLength: number;
  67075. /** @hidden */
  67076. _basePointWorld: Vector3;
  67077. private _velocityWorld;
  67078. private _normalizedVelocity;
  67079. /** @hidden */
  67080. _initialVelocity: Vector3;
  67081. /** @hidden */
  67082. _initialPosition: Vector3;
  67083. private _nearestDistance;
  67084. private _collisionMask;
  67085. collisionMask: number;
  67086. /**
  67087. * Gets the plane normal used to compute the sliding response (in local space)
  67088. */
  67089. readonly slidePlaneNormal: Vector3;
  67090. /** @hidden */
  67091. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67092. /** @hidden */
  67093. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67094. /** @hidden */
  67095. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67096. /** @hidden */
  67097. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67098. /** @hidden */
  67099. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67100. /** @hidden */
  67101. _getResponse(pos: Vector3, vel: Vector3): void;
  67102. }
  67103. }
  67104. declare module BABYLON {
  67105. /**
  67106. * Interface for cullable objects
  67107. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67108. */
  67109. export interface ICullable {
  67110. /**
  67111. * Checks if the object or part of the object is in the frustum
  67112. * @param frustumPlanes Camera near/planes
  67113. * @returns true if the object is in frustum otherwise false
  67114. */
  67115. isInFrustum(frustumPlanes: Plane[]): boolean;
  67116. /**
  67117. * Checks if a cullable object (mesh...) is in the camera frustum
  67118. * Unlike isInFrustum this cheks the full bounding box
  67119. * @param frustumPlanes Camera near/planes
  67120. * @returns true if the object is in frustum otherwise false
  67121. */
  67122. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67123. }
  67124. /**
  67125. * Info for a bounding data of a mesh
  67126. */
  67127. export class BoundingInfo implements ICullable {
  67128. /**
  67129. * Bounding box for the mesh
  67130. */
  67131. readonly boundingBox: BoundingBox;
  67132. /**
  67133. * Bounding sphere for the mesh
  67134. */
  67135. readonly boundingSphere: BoundingSphere;
  67136. private _isLocked;
  67137. private static readonly TmpVector3;
  67138. /**
  67139. * Constructs bounding info
  67140. * @param minimum min vector of the bounding box/sphere
  67141. * @param maximum max vector of the bounding box/sphere
  67142. * @param worldMatrix defines the new world matrix
  67143. */
  67144. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67145. /**
  67146. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67147. * @param min defines the new minimum vector (in local space)
  67148. * @param max defines the new maximum vector (in local space)
  67149. * @param worldMatrix defines the new world matrix
  67150. */
  67151. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67152. /**
  67153. * min vector of the bounding box/sphere
  67154. */
  67155. readonly minimum: Vector3;
  67156. /**
  67157. * max vector of the bounding box/sphere
  67158. */
  67159. readonly maximum: Vector3;
  67160. /**
  67161. * If the info is locked and won't be updated to avoid perf overhead
  67162. */
  67163. isLocked: boolean;
  67164. /**
  67165. * Updates the bounding sphere and box
  67166. * @param world world matrix to be used to update
  67167. */
  67168. update(world: DeepImmutable<Matrix>): void;
  67169. /**
  67170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67171. * @param center New center of the bounding info
  67172. * @param extend New extend of the bounding info
  67173. * @returns the current bounding info
  67174. */
  67175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67176. /**
  67177. * Scale the current bounding info by applying a scale factor
  67178. * @param factor defines the scale factor to apply
  67179. * @returns the current bounding info
  67180. */
  67181. scale(factor: number): BoundingInfo;
  67182. /**
  67183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67184. * @param frustumPlanes defines the frustum to test
  67185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67186. * @returns true if the bounding info is in the frustum planes
  67187. */
  67188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67189. /**
  67190. * Gets the world distance between the min and max points of the bounding box
  67191. */
  67192. readonly diagonalLength: number;
  67193. /**
  67194. * Checks if a cullable object (mesh...) is in the camera frustum
  67195. * Unlike isInFrustum this cheks the full bounding box
  67196. * @param frustumPlanes Camera near/planes
  67197. * @returns true if the object is in frustum otherwise false
  67198. */
  67199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67200. /** @hidden */
  67201. _checkCollision(collider: Collider): boolean;
  67202. /**
  67203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67205. * @param point the point to check intersection with
  67206. * @returns if the point intersects
  67207. */
  67208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67209. /**
  67210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67212. * @param boundingInfo the bounding info to check intersection with
  67213. * @param precise if the intersection should be done using OBB
  67214. * @returns if the bounding info intersects
  67215. */
  67216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. /**
  67221. * Defines an array and its length.
  67222. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67223. */
  67224. export interface ISmartArrayLike<T> {
  67225. /**
  67226. * The data of the array.
  67227. */
  67228. data: Array<T>;
  67229. /**
  67230. * The active length of the array.
  67231. */
  67232. length: number;
  67233. }
  67234. /**
  67235. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67236. */
  67237. export class SmartArray<T> implements ISmartArrayLike<T> {
  67238. /**
  67239. * The full set of data from the array.
  67240. */
  67241. data: Array<T>;
  67242. /**
  67243. * The active length of the array.
  67244. */
  67245. length: number;
  67246. protected _id: number;
  67247. /**
  67248. * Instantiates a Smart Array.
  67249. * @param capacity defines the default capacity of the array.
  67250. */
  67251. constructor(capacity: number);
  67252. /**
  67253. * Pushes a value at the end of the active data.
  67254. * @param value defines the object to push in the array.
  67255. */
  67256. push(value: T): void;
  67257. /**
  67258. * Iterates over the active data and apply the lambda to them.
  67259. * @param func defines the action to apply on each value.
  67260. */
  67261. forEach(func: (content: T) => void): void;
  67262. /**
  67263. * Sorts the full sets of data.
  67264. * @param compareFn defines the comparison function to apply.
  67265. */
  67266. sort(compareFn: (a: T, b: T) => number): void;
  67267. /**
  67268. * Resets the active data to an empty array.
  67269. */
  67270. reset(): void;
  67271. /**
  67272. * Releases all the data from the array as well as the array.
  67273. */
  67274. dispose(): void;
  67275. /**
  67276. * Concats the active data with a given array.
  67277. * @param array defines the data to concatenate with.
  67278. */
  67279. concat(array: any): void;
  67280. /**
  67281. * Returns the position of a value in the active data.
  67282. * @param value defines the value to find the index for
  67283. * @returns the index if found in the active data otherwise -1
  67284. */
  67285. indexOf(value: T): number;
  67286. /**
  67287. * Returns whether an element is part of the active data.
  67288. * @param value defines the value to look for
  67289. * @returns true if found in the active data otherwise false
  67290. */
  67291. contains(value: T): boolean;
  67292. private static _GlobalId;
  67293. }
  67294. /**
  67295. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67296. * The data in this array can only be present once
  67297. */
  67298. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67299. private _duplicateId;
  67300. /**
  67301. * Pushes a value at the end of the active data.
  67302. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67303. * @param value defines the object to push in the array.
  67304. */
  67305. push(value: T): void;
  67306. /**
  67307. * Pushes a value at the end of the active data.
  67308. * If the data is already present, it won t be added again
  67309. * @param value defines the object to push in the array.
  67310. * @returns true if added false if it was already present
  67311. */
  67312. pushNoDuplicate(value: T): boolean;
  67313. /**
  67314. * Resets the active data to an empty array.
  67315. */
  67316. reset(): void;
  67317. /**
  67318. * Concats the active data with a given array.
  67319. * This ensures no dupplicate will be present in the result.
  67320. * @param array defines the data to concatenate with.
  67321. */
  67322. concatWithNoDuplicate(array: any): void;
  67323. }
  67324. }
  67325. declare module BABYLON {
  67326. /**
  67327. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67328. * separate meshes. This can be use to improve performances.
  67329. * @see http://doc.babylonjs.com/how_to/multi_materials
  67330. */
  67331. export class MultiMaterial extends Material {
  67332. private _subMaterials;
  67333. /**
  67334. * Gets or Sets the list of Materials used within the multi material.
  67335. * They need to be ordered according to the submeshes order in the associated mesh
  67336. */
  67337. subMaterials: Nullable<Material>[];
  67338. /**
  67339. * Function used to align with Node.getChildren()
  67340. * @returns the list of Materials used within the multi material
  67341. */
  67342. getChildren(): Nullable<Material>[];
  67343. /**
  67344. * Instantiates a new Multi Material
  67345. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67346. * separate meshes. This can be use to improve performances.
  67347. * @see http://doc.babylonjs.com/how_to/multi_materials
  67348. * @param name Define the name in the scene
  67349. * @param scene Define the scene the material belongs to
  67350. */
  67351. constructor(name: string, scene: Scene);
  67352. private _hookArray;
  67353. /**
  67354. * Get one of the submaterial by its index in the submaterials array
  67355. * @param index The index to look the sub material at
  67356. * @returns The Material if the index has been defined
  67357. */
  67358. getSubMaterial(index: number): Nullable<Material>;
  67359. /**
  67360. * Get the list of active textures for the whole sub materials list.
  67361. * @returns All the textures that will be used during the rendering
  67362. */
  67363. getActiveTextures(): BaseTexture[];
  67364. /**
  67365. * Gets the current class name of the material e.g. "MultiMaterial"
  67366. * Mainly use in serialization.
  67367. * @returns the class name
  67368. */
  67369. getClassName(): string;
  67370. /**
  67371. * Checks if the material is ready to render the requested sub mesh
  67372. * @param mesh Define the mesh the submesh belongs to
  67373. * @param subMesh Define the sub mesh to look readyness for
  67374. * @param useInstances Define whether or not the material is used with instances
  67375. * @returns true if ready, otherwise false
  67376. */
  67377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67378. /**
  67379. * Clones the current material and its related sub materials
  67380. * @param name Define the name of the newly cloned material
  67381. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67382. * @returns the cloned material
  67383. */
  67384. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67385. /**
  67386. * Serializes the materials into a JSON representation.
  67387. * @returns the JSON representation
  67388. */
  67389. serialize(): any;
  67390. /**
  67391. * Dispose the material and release its associated resources
  67392. * @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)
  67393. * @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)
  67394. * @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)
  67395. */
  67396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67397. /**
  67398. * Creates a MultiMaterial from parsed MultiMaterial data.
  67399. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67400. * @param scene defines the hosting scene
  67401. * @returns a new MultiMaterial
  67402. */
  67403. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67404. }
  67405. }
  67406. declare module BABYLON {
  67407. /**
  67408. * Class used to represent data loading progression
  67409. */
  67410. export class SceneLoaderFlags {
  67411. private static _ForceFullSceneLoadingForIncremental;
  67412. private static _ShowLoadingScreen;
  67413. private static _CleanBoneMatrixWeights;
  67414. private static _loggingLevel;
  67415. /**
  67416. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67417. */
  67418. static ForceFullSceneLoadingForIncremental: boolean;
  67419. /**
  67420. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67421. */
  67422. static ShowLoadingScreen: boolean;
  67423. /**
  67424. * Defines the current logging level (while loading the scene)
  67425. * @ignorenaming
  67426. */
  67427. static loggingLevel: number;
  67428. /**
  67429. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67430. */
  67431. static CleanBoneMatrixWeights: boolean;
  67432. }
  67433. }
  67434. declare module BABYLON {
  67435. /**
  67436. * 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.
  67437. * @see https://doc.babylonjs.com/how_to/transformnode
  67438. */
  67439. export class TransformNode extends Node {
  67440. /**
  67441. * Object will not rotate to face the camera
  67442. */
  67443. static BILLBOARDMODE_NONE: number;
  67444. /**
  67445. * Object will rotate to face the camera but only on the x axis
  67446. */
  67447. static BILLBOARDMODE_X: number;
  67448. /**
  67449. * Object will rotate to face the camera but only on the y axis
  67450. */
  67451. static BILLBOARDMODE_Y: number;
  67452. /**
  67453. * Object will rotate to face the camera but only on the z axis
  67454. */
  67455. static BILLBOARDMODE_Z: number;
  67456. /**
  67457. * Object will rotate to face the camera
  67458. */
  67459. static BILLBOARDMODE_ALL: number;
  67460. private _forward;
  67461. private _forwardInverted;
  67462. private _up;
  67463. private _right;
  67464. private _rightInverted;
  67465. private _position;
  67466. private _rotation;
  67467. private _rotationQuaternion;
  67468. protected _scaling: Vector3;
  67469. protected _isDirty: boolean;
  67470. private _transformToBoneReferal;
  67471. private _billboardMode;
  67472. /**
  67473. * Gets or sets the billboard mode. Default is 0.
  67474. *
  67475. * | Value | Type | Description |
  67476. * | --- | --- | --- |
  67477. * | 0 | BILLBOARDMODE_NONE | |
  67478. * | 1 | BILLBOARDMODE_X | |
  67479. * | 2 | BILLBOARDMODE_Y | |
  67480. * | 4 | BILLBOARDMODE_Z | |
  67481. * | 7 | BILLBOARDMODE_ALL | |
  67482. *
  67483. */
  67484. billboardMode: number;
  67485. private _preserveParentRotationForBillboard;
  67486. /**
  67487. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67488. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67489. */
  67490. preserveParentRotationForBillboard: boolean;
  67491. /**
  67492. * 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
  67493. */
  67494. scalingDeterminant: number;
  67495. private _infiniteDistance;
  67496. /**
  67497. * Gets or sets the distance of the object to max, often used by skybox
  67498. */
  67499. infiniteDistance: boolean;
  67500. /**
  67501. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67502. * By default the system will update normals to compensate
  67503. */
  67504. ignoreNonUniformScaling: boolean;
  67505. /**
  67506. * 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
  67507. */
  67508. reIntegrateRotationIntoRotationQuaternion: boolean;
  67509. /** @hidden */
  67510. _poseMatrix: Nullable<Matrix>;
  67511. /** @hidden */
  67512. _localMatrix: Matrix;
  67513. private _usePivotMatrix;
  67514. private _absolutePosition;
  67515. private _pivotMatrix;
  67516. private _pivotMatrixInverse;
  67517. protected _postMultiplyPivotMatrix: boolean;
  67518. protected _isWorldMatrixFrozen: boolean;
  67519. /** @hidden */
  67520. _indexInSceneTransformNodesArray: number;
  67521. /**
  67522. * An event triggered after the world matrix is updated
  67523. */
  67524. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67525. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67526. /**
  67527. * Gets a string identifying the name of the class
  67528. * @returns "TransformNode" string
  67529. */
  67530. getClassName(): string;
  67531. /**
  67532. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67533. */
  67534. position: Vector3;
  67535. /**
  67536. * 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)).
  67537. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67538. */
  67539. rotation: Vector3;
  67540. /**
  67541. * 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)).
  67542. */
  67543. scaling: Vector3;
  67544. /**
  67545. * 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).
  67546. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67547. */
  67548. rotationQuaternion: Nullable<Quaternion>;
  67549. /**
  67550. * The forward direction of that transform in world space.
  67551. */
  67552. readonly forward: Vector3;
  67553. /**
  67554. * The up direction of that transform in world space.
  67555. */
  67556. readonly up: Vector3;
  67557. /**
  67558. * The right direction of that transform in world space.
  67559. */
  67560. readonly right: Vector3;
  67561. /**
  67562. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67563. * @param matrix the matrix to copy the pose from
  67564. * @returns this TransformNode.
  67565. */
  67566. updatePoseMatrix(matrix: Matrix): TransformNode;
  67567. /**
  67568. * Returns the mesh Pose matrix.
  67569. * @returns the pose matrix
  67570. */
  67571. getPoseMatrix(): Matrix;
  67572. /** @hidden */
  67573. _isSynchronized(): boolean;
  67574. /** @hidden */
  67575. _initCache(): void;
  67576. /**
  67577. * Flag the transform node as dirty (Forcing it to update everything)
  67578. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67579. * @returns this transform node
  67580. */
  67581. markAsDirty(property: string): TransformNode;
  67582. /**
  67583. * Returns the current mesh absolute position.
  67584. * Returns a Vector3.
  67585. */
  67586. readonly absolutePosition: Vector3;
  67587. /**
  67588. * Sets a new matrix to apply before all other transformation
  67589. * @param matrix defines the transform matrix
  67590. * @returns the current TransformNode
  67591. */
  67592. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67593. /**
  67594. * Sets a new pivot matrix to the current node
  67595. * @param matrix defines the new pivot matrix to use
  67596. * @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
  67597. * @returns the current TransformNode
  67598. */
  67599. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67600. /**
  67601. * Returns the mesh pivot matrix.
  67602. * Default : Identity.
  67603. * @returns the matrix
  67604. */
  67605. getPivotMatrix(): Matrix;
  67606. /**
  67607. * Prevents the World matrix to be computed any longer.
  67608. * @returns the TransformNode.
  67609. */
  67610. freezeWorldMatrix(): TransformNode;
  67611. /**
  67612. * Allows back the World matrix computation.
  67613. * @returns the TransformNode.
  67614. */
  67615. unfreezeWorldMatrix(): this;
  67616. /**
  67617. * True if the World matrix has been frozen.
  67618. */
  67619. readonly isWorldMatrixFrozen: boolean;
  67620. /**
  67621. * Retuns the mesh absolute position in the World.
  67622. * @returns a Vector3.
  67623. */
  67624. getAbsolutePosition(): Vector3;
  67625. /**
  67626. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67627. * @param absolutePosition the absolute position to set
  67628. * @returns the TransformNode.
  67629. */
  67630. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67631. /**
  67632. * Sets the mesh position in its local space.
  67633. * @param vector3 the position to set in localspace
  67634. * @returns the TransformNode.
  67635. */
  67636. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67637. /**
  67638. * Returns the mesh position in the local space from the current World matrix values.
  67639. * @returns a new Vector3.
  67640. */
  67641. getPositionExpressedInLocalSpace(): Vector3;
  67642. /**
  67643. * Translates the mesh along the passed Vector3 in its local space.
  67644. * @param vector3 the distance to translate in localspace
  67645. * @returns the TransformNode.
  67646. */
  67647. locallyTranslate(vector3: Vector3): TransformNode;
  67648. private static _lookAtVectorCache;
  67649. /**
  67650. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67651. * @param targetPoint the position (must be in same space as current mesh) to look at
  67652. * @param yawCor optional yaw (y-axis) correction in radians
  67653. * @param pitchCor optional pitch (x-axis) correction in radians
  67654. * @param rollCor optional roll (z-axis) correction in radians
  67655. * @param space the choosen space of the target
  67656. * @returns the TransformNode.
  67657. */
  67658. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67659. /**
  67660. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67661. * This Vector3 is expressed in the World space.
  67662. * @param localAxis axis to rotate
  67663. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67664. */
  67665. getDirection(localAxis: Vector3): Vector3;
  67666. /**
  67667. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67668. * localAxis is expressed in the mesh local space.
  67669. * result is computed in the Wordl space from the mesh World matrix.
  67670. * @param localAxis axis to rotate
  67671. * @param result the resulting transformnode
  67672. * @returns this TransformNode.
  67673. */
  67674. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67675. /**
  67676. * Sets this transform node rotation to the given local axis.
  67677. * @param localAxis the axis in local space
  67678. * @param yawCor optional yaw (y-axis) correction in radians
  67679. * @param pitchCor optional pitch (x-axis) correction in radians
  67680. * @param rollCor optional roll (z-axis) correction in radians
  67681. * @returns this TransformNode
  67682. */
  67683. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67684. /**
  67685. * Sets a new pivot point to the current node
  67686. * @param point defines the new pivot point to use
  67687. * @param space defines if the point is in world or local space (local by default)
  67688. * @returns the current TransformNode
  67689. */
  67690. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67691. /**
  67692. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67693. * @returns the pivot point
  67694. */
  67695. getPivotPoint(): Vector3;
  67696. /**
  67697. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67698. * @param result the vector3 to store the result
  67699. * @returns this TransformNode.
  67700. */
  67701. getPivotPointToRef(result: Vector3): TransformNode;
  67702. /**
  67703. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67704. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67705. */
  67706. getAbsolutePivotPoint(): Vector3;
  67707. /**
  67708. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67709. * @param result vector3 to store the result
  67710. * @returns this TransformNode.
  67711. */
  67712. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67713. /**
  67714. * Defines the passed node as the parent of the current node.
  67715. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67716. * @see https://doc.babylonjs.com/how_to/parenting
  67717. * @param node the node ot set as the parent
  67718. * @returns this TransformNode.
  67719. */
  67720. setParent(node: Nullable<Node>): TransformNode;
  67721. private _nonUniformScaling;
  67722. /**
  67723. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67724. */
  67725. readonly nonUniformScaling: boolean;
  67726. /** @hidden */
  67727. _updateNonUniformScalingState(value: boolean): boolean;
  67728. /**
  67729. * Attach the current TransformNode to another TransformNode associated with a bone
  67730. * @param bone Bone affecting the TransformNode
  67731. * @param affectedTransformNode TransformNode associated with the bone
  67732. * @returns this object
  67733. */
  67734. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67735. /**
  67736. * Detach the transform node if its associated with a bone
  67737. * @returns this object
  67738. */
  67739. detachFromBone(): TransformNode;
  67740. private static _rotationAxisCache;
  67741. /**
  67742. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67743. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67744. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67745. * The passed axis is also normalized.
  67746. * @param axis the axis to rotate around
  67747. * @param amount the amount to rotate in radians
  67748. * @param space Space to rotate in (Default: local)
  67749. * @returns the TransformNode.
  67750. */
  67751. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67752. /**
  67753. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67754. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67755. * The passed axis is also normalized. .
  67756. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67757. * @param point the point to rotate around
  67758. * @param axis the axis to rotate around
  67759. * @param amount the amount to rotate in radians
  67760. * @returns the TransformNode
  67761. */
  67762. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67763. /**
  67764. * Translates the mesh along the axis vector for the passed distance in the given space.
  67765. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67766. * @param axis the axis to translate in
  67767. * @param distance the distance to translate
  67768. * @param space Space to rotate in (Default: local)
  67769. * @returns the TransformNode.
  67770. */
  67771. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67772. /**
  67773. * Adds a rotation step to the mesh current rotation.
  67774. * x, y, z are Euler angles expressed in radians.
  67775. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67776. * This means this rotation is made in the mesh local space only.
  67777. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67778. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67779. * ```javascript
  67780. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67781. * ```
  67782. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67783. * 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.
  67784. * @param x Rotation to add
  67785. * @param y Rotation to add
  67786. * @param z Rotation to add
  67787. * @returns the TransformNode.
  67788. */
  67789. addRotation(x: number, y: number, z: number): TransformNode;
  67790. /**
  67791. * @hidden
  67792. */
  67793. protected _getEffectiveParent(): Nullable<Node>;
  67794. /**
  67795. * Computes the world matrix of the node
  67796. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67797. * @returns the world matrix
  67798. */
  67799. computeWorldMatrix(force?: boolean): Matrix;
  67800. protected _afterComputeWorldMatrix(): void;
  67801. /**
  67802. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67803. * @param func callback function to add
  67804. *
  67805. * @returns the TransformNode.
  67806. */
  67807. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67808. /**
  67809. * Removes a registered callback function.
  67810. * @param func callback function to remove
  67811. * @returns the TransformNode.
  67812. */
  67813. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67814. /**
  67815. * Gets the position of the current mesh in camera space
  67816. * @param camera defines the camera to use
  67817. * @returns a position
  67818. */
  67819. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67820. /**
  67821. * Returns the distance from the mesh to the active camera
  67822. * @param camera defines the camera to use
  67823. * @returns the distance
  67824. */
  67825. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67826. /**
  67827. * Clone the current transform node
  67828. * @param name Name of the new clone
  67829. * @param newParent New parent for the clone
  67830. * @param doNotCloneChildren Do not clone children hierarchy
  67831. * @returns the new transform node
  67832. */
  67833. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67834. /**
  67835. * Serializes the objects information.
  67836. * @param currentSerializationObject defines the object to serialize in
  67837. * @returns the serialized object
  67838. */
  67839. serialize(currentSerializationObject?: any): any;
  67840. /**
  67841. * Returns a new TransformNode object parsed from the source provided.
  67842. * @param parsedTransformNode is the source.
  67843. * @param scene the scne the object belongs to
  67844. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67845. * @returns a new TransformNode object parsed from the source provided.
  67846. */
  67847. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67848. /**
  67849. * Get all child-transformNodes of this node
  67850. * @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
  67851. * @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
  67852. * @returns an array of TransformNode
  67853. */
  67854. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67855. /**
  67856. * Releases resources associated with this transform node.
  67857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67859. */
  67860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67861. }
  67862. }
  67863. declare module BABYLON {
  67864. /**
  67865. * Class used to override all child animations of a given target
  67866. */
  67867. export class AnimationPropertiesOverride {
  67868. /**
  67869. * Gets or sets a value indicating if animation blending must be used
  67870. */
  67871. enableBlending: boolean;
  67872. /**
  67873. * Gets or sets the blending speed to use when enableBlending is true
  67874. */
  67875. blendingSpeed: number;
  67876. /**
  67877. * Gets or sets the default loop mode to use
  67878. */
  67879. loopMode: number;
  67880. }
  67881. }
  67882. declare module BABYLON {
  67883. /**
  67884. * Class used to store bone information
  67885. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67886. */
  67887. export class Bone extends Node {
  67888. /**
  67889. * defines the bone name
  67890. */
  67891. name: string;
  67892. private static _tmpVecs;
  67893. private static _tmpQuat;
  67894. private static _tmpMats;
  67895. /**
  67896. * Gets the list of child bones
  67897. */
  67898. children: Bone[];
  67899. /** Gets the animations associated with this bone */
  67900. animations: Animation[];
  67901. /**
  67902. * Gets or sets bone length
  67903. */
  67904. length: number;
  67905. /**
  67906. * @hidden Internal only
  67907. * Set this value to map this bone to a different index in the transform matrices
  67908. * Set this value to -1 to exclude the bone from the transform matrices
  67909. */
  67910. _index: Nullable<number>;
  67911. private _skeleton;
  67912. private _localMatrix;
  67913. private _restPose;
  67914. private _baseMatrix;
  67915. private _absoluteTransform;
  67916. private _invertedAbsoluteTransform;
  67917. private _parent;
  67918. private _scalingDeterminant;
  67919. private _worldTransform;
  67920. private _localScaling;
  67921. private _localRotation;
  67922. private _localPosition;
  67923. private _needToDecompose;
  67924. private _needToCompose;
  67925. /** @hidden */
  67926. _linkedTransformNode: Nullable<TransformNode>;
  67927. /** @hidden */
  67928. _waitingTransformNodeId: Nullable<string>;
  67929. /** @hidden */
  67930. /** @hidden */
  67931. _matrix: Matrix;
  67932. /**
  67933. * Create a new bone
  67934. * @param name defines the bone name
  67935. * @param skeleton defines the parent skeleton
  67936. * @param parentBone defines the parent (can be null if the bone is the root)
  67937. * @param localMatrix defines the local matrix
  67938. * @param restPose defines the rest pose matrix
  67939. * @param baseMatrix defines the base matrix
  67940. * @param index defines index of the bone in the hiearchy
  67941. */
  67942. constructor(
  67943. /**
  67944. * defines the bone name
  67945. */
  67946. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67947. /**
  67948. * Gets the current object class name.
  67949. * @return the class name
  67950. */
  67951. getClassName(): string;
  67952. /**
  67953. * Gets the parent skeleton
  67954. * @returns a skeleton
  67955. */
  67956. getSkeleton(): Skeleton;
  67957. /**
  67958. * Gets parent bone
  67959. * @returns a bone or null if the bone is the root of the bone hierarchy
  67960. */
  67961. getParent(): Nullable<Bone>;
  67962. /**
  67963. * Returns an array containing the root bones
  67964. * @returns an array containing the root bones
  67965. */
  67966. getChildren(): Array<Bone>;
  67967. /**
  67968. * Sets the parent bone
  67969. * @param parent defines the parent (can be null if the bone is the root)
  67970. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67971. */
  67972. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67973. /**
  67974. * Gets the local matrix
  67975. * @returns a matrix
  67976. */
  67977. getLocalMatrix(): Matrix;
  67978. /**
  67979. * Gets the base matrix (initial matrix which remains unchanged)
  67980. * @returns a matrix
  67981. */
  67982. getBaseMatrix(): Matrix;
  67983. /**
  67984. * Gets the rest pose matrix
  67985. * @returns a matrix
  67986. */
  67987. getRestPose(): Matrix;
  67988. /**
  67989. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67990. */
  67991. getWorldMatrix(): Matrix;
  67992. /**
  67993. * Sets the local matrix to rest pose matrix
  67994. */
  67995. returnToRest(): void;
  67996. /**
  67997. * Gets the inverse of the absolute transform matrix.
  67998. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67999. * @returns a matrix
  68000. */
  68001. getInvertedAbsoluteTransform(): Matrix;
  68002. /**
  68003. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68004. * @returns a matrix
  68005. */
  68006. getAbsoluteTransform(): Matrix;
  68007. /**
  68008. * Links with the given transform node.
  68009. * The local matrix of this bone is copied from the transform node every frame.
  68010. * @param transformNode defines the transform node to link to
  68011. */
  68012. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68013. /** Gets or sets current position (in local space) */
  68014. position: Vector3;
  68015. /** Gets or sets current rotation (in local space) */
  68016. rotation: Vector3;
  68017. /** Gets or sets current rotation quaternion (in local space) */
  68018. rotationQuaternion: Quaternion;
  68019. /** Gets or sets current scaling (in local space) */
  68020. scaling: Vector3;
  68021. /**
  68022. * Gets the animation properties override
  68023. */
  68024. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68025. private _decompose;
  68026. private _compose;
  68027. /**
  68028. * Update the base and local matrices
  68029. * @param matrix defines the new base or local matrix
  68030. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68031. * @param updateLocalMatrix defines if the local matrix should be updated
  68032. */
  68033. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68034. /** @hidden */
  68035. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68036. /**
  68037. * Flag the bone as dirty (Forcing it to update everything)
  68038. */
  68039. markAsDirty(): void;
  68040. private _markAsDirtyAndCompose;
  68041. private _markAsDirtyAndDecompose;
  68042. /**
  68043. * Translate the bone in local or world space
  68044. * @param vec The amount to translate the bone
  68045. * @param space The space that the translation is in
  68046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68047. */
  68048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68049. /**
  68050. * Set the postion of the bone in local or world space
  68051. * @param position The position to set the bone
  68052. * @param space The space that the position is in
  68053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68054. */
  68055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68056. /**
  68057. * Set the absolute position of the bone (world space)
  68058. * @param position The position to set the bone
  68059. * @param mesh The mesh that this bone is attached to
  68060. */
  68061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68062. /**
  68063. * Scale the bone on the x, y and z axes (in local space)
  68064. * @param x The amount to scale the bone on the x axis
  68065. * @param y The amount to scale the bone on the y axis
  68066. * @param z The amount to scale the bone on the z axis
  68067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68068. */
  68069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68070. /**
  68071. * Set the bone scaling in local space
  68072. * @param scale defines the scaling vector
  68073. */
  68074. setScale(scale: Vector3): void;
  68075. /**
  68076. * Gets the current scaling in local space
  68077. * @returns the current scaling vector
  68078. */
  68079. getScale(): Vector3;
  68080. /**
  68081. * Gets the current scaling in local space and stores it in a target vector
  68082. * @param result defines the target vector
  68083. */
  68084. getScaleToRef(result: Vector3): void;
  68085. /**
  68086. * Set the yaw, pitch, and roll of the bone in local or world space
  68087. * @param yaw The rotation of the bone on the y axis
  68088. * @param pitch The rotation of the bone on the x axis
  68089. * @param roll The rotation of the bone on the z axis
  68090. * @param space The space that the axes of rotation are in
  68091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68092. */
  68093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68094. /**
  68095. * Add a rotation to the bone on an axis in local or world space
  68096. * @param axis The axis to rotate the bone on
  68097. * @param amount The amount to rotate the bone
  68098. * @param space The space that the axis is in
  68099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68100. */
  68101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68102. /**
  68103. * Set the rotation of the bone to a particular axis angle in local or world space
  68104. * @param axis The axis to rotate the bone on
  68105. * @param angle The angle that the bone should be rotated to
  68106. * @param space The space that the axis is in
  68107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68108. */
  68109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68110. /**
  68111. * Set the euler rotation of the bone in local of world space
  68112. * @param rotation The euler rotation that the bone should be set to
  68113. * @param space The space that the rotation is in
  68114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68115. */
  68116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68117. /**
  68118. * Set the quaternion rotation of the bone in local of world space
  68119. * @param quat The quaternion rotation that the bone should be set to
  68120. * @param space The space that the rotation is in
  68121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68122. */
  68123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68124. /**
  68125. * Set the rotation matrix of the bone in local of world space
  68126. * @param rotMat The rotation matrix that the bone should be set to
  68127. * @param space The space that the rotation is in
  68128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68129. */
  68130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68131. private _rotateWithMatrix;
  68132. private _getNegativeRotationToRef;
  68133. /**
  68134. * Get the position of the bone in local or world space
  68135. * @param space The space that the returned position is in
  68136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68137. * @returns The position of the bone
  68138. */
  68139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68140. /**
  68141. * Copy the position of the bone to a vector3 in local or world space
  68142. * @param space The space that the returned position is in
  68143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68144. * @param result The vector3 to copy the position to
  68145. */
  68146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68147. /**
  68148. * Get the absolute position of the bone (world space)
  68149. * @param mesh The mesh that this bone is attached to
  68150. * @returns The absolute position of the bone
  68151. */
  68152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68153. /**
  68154. * Copy the absolute position of the bone (world space) to the result param
  68155. * @param mesh The mesh that this bone is attached to
  68156. * @param result The vector3 to copy the absolute position to
  68157. */
  68158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68159. /**
  68160. * Compute the absolute transforms of this bone and its children
  68161. */
  68162. computeAbsoluteTransforms(): void;
  68163. /**
  68164. * Get the world direction from an axis that is in the local space of the bone
  68165. * @param localAxis The local direction that is used to compute the world direction
  68166. * @param mesh The mesh that this bone is attached to
  68167. * @returns The world direction
  68168. */
  68169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68170. /**
  68171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68172. * @param localAxis The local direction that is used to compute the world direction
  68173. * @param mesh The mesh that this bone is attached to
  68174. * @param result The vector3 that the world direction will be copied to
  68175. */
  68176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68177. /**
  68178. * Get the euler rotation of the bone in local or world space
  68179. * @param space The space that the rotation should be in
  68180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68181. * @returns The euler rotation
  68182. */
  68183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68184. /**
  68185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68186. * @param space The space that the rotation should be in
  68187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68188. * @param result The vector3 that the rotation should be copied to
  68189. */
  68190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68191. /**
  68192. * Get the quaternion rotation of the bone in either local or world space
  68193. * @param space The space that the rotation should be in
  68194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68195. * @returns The quaternion rotation
  68196. */
  68197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68198. /**
  68199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68200. * @param space The space that the rotation should be in
  68201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68202. * @param result The quaternion that the rotation should be copied to
  68203. */
  68204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68205. /**
  68206. * Get the rotation matrix of the bone in local or world space
  68207. * @param space The space that the rotation should be in
  68208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68209. * @returns The rotation matrix
  68210. */
  68211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68212. /**
  68213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68214. * @param space The space that the rotation should be in
  68215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68216. * @param result The quaternion that the rotation should be copied to
  68217. */
  68218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68219. /**
  68220. * Get the world position of a point that is in the local space of the bone
  68221. * @param position The local position
  68222. * @param mesh The mesh that this bone is attached to
  68223. * @returns The world position
  68224. */
  68225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68226. /**
  68227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68228. * @param position The local position
  68229. * @param mesh The mesh that this bone is attached to
  68230. * @param result The vector3 that the world position should be copied to
  68231. */
  68232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68233. /**
  68234. * Get the local position of a point that is in world space
  68235. * @param position The world position
  68236. * @param mesh The mesh that this bone is attached to
  68237. * @returns The local position
  68238. */
  68239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68240. /**
  68241. * Get the local position of a point that is in world space and copy it to the result param
  68242. * @param position The world position
  68243. * @param mesh The mesh that this bone is attached to
  68244. * @param result The vector3 that the local position should be copied to
  68245. */
  68246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68247. }
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. * Enum that determines the text-wrapping mode to use.
  68252. */
  68253. export enum InspectableType {
  68254. /**
  68255. * Checkbox for booleans
  68256. */
  68257. Checkbox = 0,
  68258. /**
  68259. * Sliders for numbers
  68260. */
  68261. Slider = 1,
  68262. /**
  68263. * Vector3
  68264. */
  68265. Vector3 = 2,
  68266. /**
  68267. * Quaternions
  68268. */
  68269. Quaternion = 3,
  68270. /**
  68271. * Color3
  68272. */
  68273. Color3 = 4
  68274. }
  68275. /**
  68276. * Interface used to define custom inspectable properties.
  68277. * This interface is used by the inspector to display custom property grids
  68278. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68279. */
  68280. export interface IInspectable {
  68281. /**
  68282. * Gets the label to display
  68283. */
  68284. label: string;
  68285. /**
  68286. * Gets the name of the property to edit
  68287. */
  68288. propertyName: string;
  68289. /**
  68290. * Gets the type of the editor to use
  68291. */
  68292. type: InspectableType;
  68293. /**
  68294. * Gets the minimum value of the property when using in "slider" mode
  68295. */
  68296. min?: number;
  68297. /**
  68298. * Gets the maximum value of the property when using in "slider" mode
  68299. */
  68300. max?: number;
  68301. /**
  68302. * Gets the setp to use when using in "slider" mode
  68303. */
  68304. step?: number;
  68305. }
  68306. }
  68307. declare module BABYLON {
  68308. /**
  68309. * This represents the required contract to create a new type of texture loader.
  68310. */
  68311. export interface IInternalTextureLoader {
  68312. /**
  68313. * Defines wether the loader supports cascade loading the different faces.
  68314. */
  68315. supportCascades: boolean;
  68316. /**
  68317. * This returns if the loader support the current file information.
  68318. * @param extension defines the file extension of the file being loaded
  68319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68320. * @param fallback defines the fallback internal texture if any
  68321. * @param isBase64 defines whether the texture is encoded as a base64
  68322. * @param isBuffer defines whether the texture data are stored as a buffer
  68323. * @returns true if the loader can load the specified file
  68324. */
  68325. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68326. /**
  68327. * Transform the url before loading if required.
  68328. * @param rootUrl the url of the texture
  68329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68330. * @returns the transformed texture
  68331. */
  68332. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68333. /**
  68334. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68335. * @param rootUrl the url of the texture
  68336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68337. * @returns the fallback texture
  68338. */
  68339. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68340. /**
  68341. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68342. * @param data contains the texture data
  68343. * @param texture defines the BabylonJS internal texture
  68344. * @param createPolynomials will be true if polynomials have been requested
  68345. * @param onLoad defines the callback to trigger once the texture is ready
  68346. * @param onError defines the callback to trigger in case of error
  68347. */
  68348. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68349. /**
  68350. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68351. * @param data contains the texture data
  68352. * @param texture defines the BabylonJS internal texture
  68353. * @param callback defines the method to call once ready to upload
  68354. */
  68355. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68356. }
  68357. }
  68358. declare module BABYLON {
  68359. interface Engine {
  68360. /**
  68361. * Creates a depth stencil cube texture.
  68362. * This is only available in WebGL 2.
  68363. * @param size The size of face edge in the cube texture.
  68364. * @param options The options defining the cube texture.
  68365. * @returns The cube texture
  68366. */
  68367. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68368. /**
  68369. * Creates a cube texture
  68370. * @param rootUrl defines the url where the files to load is located
  68371. * @param scene defines the current scene
  68372. * @param files defines the list of files to load (1 per face)
  68373. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68374. * @param onLoad defines an optional callback raised when the texture is loaded
  68375. * @param onError defines an optional callback raised if there is an issue to load the texture
  68376. * @param format defines the format of the data
  68377. * @param forcedExtension defines the extension to use to pick the right loader
  68378. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68379. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68380. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68381. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68382. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68383. * @returns the cube texture as an InternalTexture
  68384. */
  68385. 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;
  68386. /**
  68387. * Creates a cube texture
  68388. * @param rootUrl defines the url where the files to load is located
  68389. * @param scene defines the current scene
  68390. * @param files defines the list of files to load (1 per face)
  68391. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68392. * @param onLoad defines an optional callback raised when the texture is loaded
  68393. * @param onError defines an optional callback raised if there is an issue to load the texture
  68394. * @param format defines the format of the data
  68395. * @param forcedExtension defines the extension to use to pick the right loader
  68396. * @returns the cube texture as an InternalTexture
  68397. */
  68398. 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;
  68399. /**
  68400. * Creates a cube texture
  68401. * @param rootUrl defines the url where the files to load is located
  68402. * @param scene defines the current scene
  68403. * @param files defines the list of files to load (1 per face)
  68404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68405. * @param onLoad defines an optional callback raised when the texture is loaded
  68406. * @param onError defines an optional callback raised if there is an issue to load the texture
  68407. * @param format defines the format of the data
  68408. * @param forcedExtension defines the extension to use to pick the right loader
  68409. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68410. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68411. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68412. * @returns the cube texture as an InternalTexture
  68413. */
  68414. 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;
  68415. /** @hidden */
  68416. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68417. /** @hidden */
  68418. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68419. /** @hidden */
  68420. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68421. /** @hidden */
  68422. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * Class for creating a cube texture
  68428. */
  68429. export class CubeTexture extends BaseTexture {
  68430. private _delayedOnLoad;
  68431. /**
  68432. * The url of the texture
  68433. */
  68434. url: string;
  68435. /**
  68436. * Gets or sets the center of the bounding box associated with the cube texture.
  68437. * It must define where the camera used to render the texture was set
  68438. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68439. */
  68440. boundingBoxPosition: Vector3;
  68441. private _boundingBoxSize;
  68442. /**
  68443. * Gets or sets the size of the bounding box associated with the cube texture
  68444. * When defined, the cubemap will switch to local mode
  68445. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68446. * @example https://www.babylonjs-playground.com/#RNASML
  68447. */
  68448. /**
  68449. * Returns the bounding box size
  68450. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68451. */
  68452. boundingBoxSize: Vector3;
  68453. protected _rotationY: number;
  68454. /**
  68455. * Sets texture matrix rotation angle around Y axis in radians.
  68456. */
  68457. /**
  68458. * Gets texture matrix rotation angle around Y axis radians.
  68459. */
  68460. rotationY: number;
  68461. /**
  68462. * Are mip maps generated for this texture or not.
  68463. */
  68464. readonly noMipmap: boolean;
  68465. private _noMipmap;
  68466. private _files;
  68467. private _extensions;
  68468. private _textureMatrix;
  68469. private _format;
  68470. private _createPolynomials;
  68471. /** @hidden */
  68472. _prefiltered: boolean;
  68473. /**
  68474. * Creates a cube texture from an array of image urls
  68475. * @param files defines an array of image urls
  68476. * @param scene defines the hosting scene
  68477. * @param noMipmap specifies if mip maps are not used
  68478. * @returns a cube texture
  68479. */
  68480. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68481. /**
  68482. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68483. * @param url defines the url of the prefiltered texture
  68484. * @param scene defines the scene the texture is attached to
  68485. * @param forcedExtension defines the extension of the file if different from the url
  68486. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68487. * @return the prefiltered texture
  68488. */
  68489. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68490. /**
  68491. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68492. * as prefiltered data.
  68493. * @param rootUrl defines the url of the texture or the root name of the six images
  68494. * @param scene defines the scene the texture is attached to
  68495. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68496. * @param noMipmap defines if mipmaps should be created or not
  68497. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68498. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68499. * @param onError defines a callback triggered in case of error during load
  68500. * @param format defines the internal format to use for the texture once loaded
  68501. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68502. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68503. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68504. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68505. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68506. * @return the cube texture
  68507. */
  68508. 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);
  68509. /**
  68510. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68511. */
  68512. readonly isPrefiltered: boolean;
  68513. /**
  68514. * Get the current class name of the texture useful for serialization or dynamic coding.
  68515. * @returns "CubeTexture"
  68516. */
  68517. getClassName(): string;
  68518. /**
  68519. * Update the url (and optional buffer) of this texture if url was null during construction.
  68520. * @param url the url of the texture
  68521. * @param forcedExtension defines the extension to use
  68522. * @param onLoad callback called when the texture is loaded (defaults to null)
  68523. */
  68524. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68525. /**
  68526. * Delays loading of the cube texture
  68527. * @param forcedExtension defines the extension to use
  68528. */
  68529. delayLoad(forcedExtension?: string): void;
  68530. /**
  68531. * Returns the reflection texture matrix
  68532. * @returns the reflection texture matrix
  68533. */
  68534. getReflectionTextureMatrix(): Matrix;
  68535. /**
  68536. * Sets the reflection texture matrix
  68537. * @param value Reflection texture matrix
  68538. */
  68539. setReflectionTextureMatrix(value: Matrix): void;
  68540. /**
  68541. * Parses text to create a cube texture
  68542. * @param parsedTexture define the serialized text to read from
  68543. * @param scene defines the hosting scene
  68544. * @param rootUrl defines the root url of the cube texture
  68545. * @returns a cube texture
  68546. */
  68547. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68548. /**
  68549. * Makes a clone, or deep copy, of the cube texture
  68550. * @returns a new cube texture
  68551. */
  68552. clone(): CubeTexture;
  68553. }
  68554. }
  68555. declare module BABYLON {
  68556. /** @hidden */
  68557. export var postprocessVertexShader: {
  68558. name: string;
  68559. shader: string;
  68560. };
  68561. }
  68562. declare module BABYLON {
  68563. /**
  68564. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68565. * This is the base of the follow, arc rotate cameras and Free camera
  68566. * @see http://doc.babylonjs.com/features/cameras
  68567. */
  68568. export class TargetCamera extends Camera {
  68569. private static _RigCamTransformMatrix;
  68570. private static _TargetTransformMatrix;
  68571. private static _TargetFocalPoint;
  68572. /**
  68573. * Define the current direction the camera is moving to
  68574. */
  68575. cameraDirection: Vector3;
  68576. /**
  68577. * Define the current rotation the camera is rotating to
  68578. */
  68579. cameraRotation: Vector2;
  68580. /**
  68581. * When set, the up vector of the camera will be updated by the rotation of the camera
  68582. */
  68583. updateUpVectorFromRotation: boolean;
  68584. private _tmpQuaternion;
  68585. /**
  68586. * Define the current rotation of the camera
  68587. */
  68588. rotation: Vector3;
  68589. /**
  68590. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68591. */
  68592. rotationQuaternion: Quaternion;
  68593. /**
  68594. * Define the current speed of the camera
  68595. */
  68596. speed: number;
  68597. /**
  68598. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68599. * around all axis.
  68600. */
  68601. noRotationConstraint: boolean;
  68602. /**
  68603. * Define the current target of the camera as an object or a position.
  68604. */
  68605. lockedTarget: any;
  68606. /** @hidden */
  68607. _currentTarget: Vector3;
  68608. /** @hidden */
  68609. _initialFocalDistance: number;
  68610. /** @hidden */
  68611. _viewMatrix: Matrix;
  68612. /** @hidden */
  68613. _camMatrix: Matrix;
  68614. /** @hidden */
  68615. _cameraTransformMatrix: Matrix;
  68616. /** @hidden */
  68617. _cameraRotationMatrix: Matrix;
  68618. /** @hidden */
  68619. _referencePoint: Vector3;
  68620. /** @hidden */
  68621. _transformedReferencePoint: Vector3;
  68622. protected _globalCurrentTarget: Vector3;
  68623. protected _globalCurrentUpVector: Vector3;
  68624. /** @hidden */
  68625. _reset: () => void;
  68626. private _defaultUp;
  68627. /**
  68628. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68629. * This is the base of the follow, arc rotate cameras and Free camera
  68630. * @see http://doc.babylonjs.com/features/cameras
  68631. * @param name Defines the name of the camera in the scene
  68632. * @param position Defines the start position of the camera in the scene
  68633. * @param scene Defines the scene the camera belongs to
  68634. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68635. */
  68636. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68637. /**
  68638. * Gets the position in front of the camera at a given distance.
  68639. * @param distance The distance from the camera we want the position to be
  68640. * @returns the position
  68641. */
  68642. getFrontPosition(distance: number): Vector3;
  68643. /** @hidden */
  68644. _getLockedTargetPosition(): Nullable<Vector3>;
  68645. private _storedPosition;
  68646. private _storedRotation;
  68647. private _storedRotationQuaternion;
  68648. /**
  68649. * Store current camera state of the camera (fov, position, rotation, etc..)
  68650. * @returns the camera
  68651. */
  68652. storeState(): Camera;
  68653. /**
  68654. * Restored camera state. You must call storeState() first
  68655. * @returns whether it was successful or not
  68656. * @hidden
  68657. */
  68658. _restoreStateValues(): boolean;
  68659. /** @hidden */
  68660. _initCache(): void;
  68661. /** @hidden */
  68662. _updateCache(ignoreParentClass?: boolean): void;
  68663. /** @hidden */
  68664. _isSynchronizedViewMatrix(): boolean;
  68665. /** @hidden */
  68666. _computeLocalCameraSpeed(): number;
  68667. /**
  68668. * Defines the target the camera should look at.
  68669. * This will automatically adapt alpha beta and radius to fit within the new target.
  68670. * @param target Defines the new target as a Vector or a mesh
  68671. */
  68672. setTarget(target: Vector3): void;
  68673. /**
  68674. * Return the current target position of the camera. This value is expressed in local space.
  68675. * @returns the target position
  68676. */
  68677. getTarget(): Vector3;
  68678. /** @hidden */
  68679. _decideIfNeedsToMove(): boolean;
  68680. /** @hidden */
  68681. _updatePosition(): void;
  68682. /** @hidden */
  68683. _checkInputs(): void;
  68684. protected _updateCameraRotationMatrix(): void;
  68685. /**
  68686. * 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)
  68687. * @returns the current camera
  68688. */
  68689. private _rotateUpVectorWithCameraRotationMatrix;
  68690. private _cachedRotationZ;
  68691. private _cachedQuaternionRotationZ;
  68692. /** @hidden */
  68693. _getViewMatrix(): Matrix;
  68694. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68695. /**
  68696. * @hidden
  68697. */
  68698. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68699. /**
  68700. * @hidden
  68701. */
  68702. _updateRigCameras(): void;
  68703. private _getRigCamPositionAndTarget;
  68704. /**
  68705. * Gets the current object class name.
  68706. * @return the class name
  68707. */
  68708. getClassName(): string;
  68709. }
  68710. }
  68711. declare module BABYLON {
  68712. /**
  68713. * @ignore
  68714. * This is a list of all the different input types that are available in the application.
  68715. * Fo instance: ArcRotateCameraGamepadInput...
  68716. */
  68717. export var CameraInputTypes: {};
  68718. /**
  68719. * This is the contract to implement in order to create a new input class.
  68720. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68721. */
  68722. export interface ICameraInput<TCamera extends Camera> {
  68723. /**
  68724. * Defines the camera the input is attached to.
  68725. */
  68726. camera: Nullable<TCamera>;
  68727. /**
  68728. * Gets the class name of the current intput.
  68729. * @returns the class name
  68730. */
  68731. getClassName(): string;
  68732. /**
  68733. * Get the friendly name associated with the input class.
  68734. * @returns the input friendly name
  68735. */
  68736. getSimpleName(): string;
  68737. /**
  68738. * Attach the input controls to a specific dom element to get the input from.
  68739. * @param element Defines the element the controls should be listened from
  68740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68741. */
  68742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68743. /**
  68744. * Detach the current controls from the specified dom element.
  68745. * @param element Defines the element to stop listening the inputs from
  68746. */
  68747. detachControl(element: Nullable<HTMLElement>): void;
  68748. /**
  68749. * Update the current camera state depending on the inputs that have been used this frame.
  68750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68751. */
  68752. checkInputs?: () => void;
  68753. }
  68754. /**
  68755. * Represents a map of input types to input instance or input index to input instance.
  68756. */
  68757. export interface CameraInputsMap<TCamera extends Camera> {
  68758. /**
  68759. * Accessor to the input by input type.
  68760. */
  68761. [name: string]: ICameraInput<TCamera>;
  68762. /**
  68763. * Accessor to the input by input index.
  68764. */
  68765. [idx: number]: ICameraInput<TCamera>;
  68766. }
  68767. /**
  68768. * This represents the input manager used within a camera.
  68769. * It helps dealing with all the different kind of input attached to a camera.
  68770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68771. */
  68772. export class CameraInputsManager<TCamera extends Camera> {
  68773. /**
  68774. * Defines the list of inputs attahed to the camera.
  68775. */
  68776. attached: CameraInputsMap<TCamera>;
  68777. /**
  68778. * Defines the dom element the camera is collecting inputs from.
  68779. * This is null if the controls have not been attached.
  68780. */
  68781. attachedElement: Nullable<HTMLElement>;
  68782. /**
  68783. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68784. */
  68785. noPreventDefault: boolean;
  68786. /**
  68787. * Defined the camera the input manager belongs to.
  68788. */
  68789. camera: TCamera;
  68790. /**
  68791. * Update the current camera state depending on the inputs that have been used this frame.
  68792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68793. */
  68794. checkInputs: () => void;
  68795. /**
  68796. * Instantiate a new Camera Input Manager.
  68797. * @param camera Defines the camera the input manager blongs to
  68798. */
  68799. constructor(camera: TCamera);
  68800. /**
  68801. * Add an input method to a camera
  68802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68803. * @param input camera input method
  68804. */
  68805. add(input: ICameraInput<TCamera>): void;
  68806. /**
  68807. * Remove a specific input method from a camera
  68808. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68809. * @param inputToRemove camera input method
  68810. */
  68811. remove(inputToRemove: ICameraInput<TCamera>): void;
  68812. /**
  68813. * Remove a specific input type from a camera
  68814. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68815. * @param inputType the type of the input to remove
  68816. */
  68817. removeByType(inputType: string): void;
  68818. private _addCheckInputs;
  68819. /**
  68820. * Attach the input controls to the currently attached dom element to listen the events from.
  68821. * @param input Defines the input to attach
  68822. */
  68823. attachInput(input: ICameraInput<TCamera>): void;
  68824. /**
  68825. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68826. * @param element Defines the dom element to collect the events from
  68827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68828. */
  68829. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68830. /**
  68831. * Detach the current manager inputs controls from a specific dom element.
  68832. * @param element Defines the dom element to collect the events from
  68833. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68834. */
  68835. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68836. /**
  68837. * Rebuild the dynamic inputCheck function from the current list of
  68838. * defined inputs in the manager.
  68839. */
  68840. rebuildInputCheck(): void;
  68841. /**
  68842. * Remove all attached input methods from a camera
  68843. */
  68844. clear(): void;
  68845. /**
  68846. * Serialize the current input manager attached to a camera.
  68847. * This ensures than once parsed,
  68848. * the input associated to the camera will be identical to the current ones
  68849. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68850. */
  68851. serialize(serializedCamera: any): void;
  68852. /**
  68853. * Parses an input manager serialized JSON to restore the previous list of inputs
  68854. * and states associated to a camera.
  68855. * @param parsedCamera Defines the JSON to parse
  68856. */
  68857. parse(parsedCamera: any): void;
  68858. }
  68859. }
  68860. declare module BABYLON {
  68861. /**
  68862. * Gather the list of keyboard event types as constants.
  68863. */
  68864. export class KeyboardEventTypes {
  68865. /**
  68866. * The keydown event is fired when a key becomes active (pressed).
  68867. */
  68868. static readonly KEYDOWN: number;
  68869. /**
  68870. * The keyup event is fired when a key has been released.
  68871. */
  68872. static readonly KEYUP: number;
  68873. }
  68874. /**
  68875. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68876. */
  68877. export class KeyboardInfo {
  68878. /**
  68879. * Defines the type of event (KeyboardEventTypes)
  68880. */
  68881. type: number;
  68882. /**
  68883. * Defines the related dom event
  68884. */
  68885. event: KeyboardEvent;
  68886. /**
  68887. * Instantiates a new keyboard info.
  68888. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68889. * @param type Defines the type of event (KeyboardEventTypes)
  68890. * @param event Defines the related dom event
  68891. */
  68892. constructor(
  68893. /**
  68894. * Defines the type of event (KeyboardEventTypes)
  68895. */
  68896. type: number,
  68897. /**
  68898. * Defines the related dom event
  68899. */
  68900. event: KeyboardEvent);
  68901. }
  68902. /**
  68903. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68904. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68905. */
  68906. export class KeyboardInfoPre extends KeyboardInfo {
  68907. /**
  68908. * Defines the type of event (KeyboardEventTypes)
  68909. */
  68910. type: number;
  68911. /**
  68912. * Defines the related dom event
  68913. */
  68914. event: KeyboardEvent;
  68915. /**
  68916. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68917. */
  68918. skipOnPointerObservable: boolean;
  68919. /**
  68920. * Instantiates a new keyboard pre info.
  68921. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68922. * @param type Defines the type of event (KeyboardEventTypes)
  68923. * @param event Defines the related dom event
  68924. */
  68925. constructor(
  68926. /**
  68927. * Defines the type of event (KeyboardEventTypes)
  68928. */
  68929. type: number,
  68930. /**
  68931. * Defines the related dom event
  68932. */
  68933. event: KeyboardEvent);
  68934. }
  68935. }
  68936. declare module BABYLON {
  68937. /**
  68938. * Manage the keyboard inputs to control the movement of a free camera.
  68939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68940. */
  68941. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68942. /**
  68943. * Defines the camera the input is attached to.
  68944. */
  68945. camera: FreeCamera;
  68946. /**
  68947. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68948. */
  68949. keysUp: number[];
  68950. /**
  68951. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68952. */
  68953. keysDown: number[];
  68954. /**
  68955. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68956. */
  68957. keysLeft: number[];
  68958. /**
  68959. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68960. */
  68961. keysRight: number[];
  68962. private _keys;
  68963. private _onCanvasBlurObserver;
  68964. private _onKeyboardObserver;
  68965. private _engine;
  68966. private _scene;
  68967. /**
  68968. * Attach the input controls to a specific dom element to get the input from.
  68969. * @param element Defines the element the controls should be listened from
  68970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68971. */
  68972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68973. /**
  68974. * Detach the current controls from the specified dom element.
  68975. * @param element Defines the element to stop listening the inputs from
  68976. */
  68977. detachControl(element: Nullable<HTMLElement>): void;
  68978. /**
  68979. * Update the current camera state depending on the inputs that have been used this frame.
  68980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68981. */
  68982. checkInputs(): void;
  68983. /**
  68984. * Gets the class name of the current intput.
  68985. * @returns the class name
  68986. */
  68987. getClassName(): string;
  68988. /** @hidden */
  68989. _onLostFocus(): void;
  68990. /**
  68991. * Get the friendly name associated with the input class.
  68992. * @returns the input friendly name
  68993. */
  68994. getSimpleName(): string;
  68995. }
  68996. }
  68997. declare module BABYLON {
  68998. /**
  68999. * Interface describing all the common properties and methods a shadow light needs to implement.
  69000. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69001. * as well as binding the different shadow properties to the effects.
  69002. */
  69003. export interface IShadowLight extends Light {
  69004. /**
  69005. * The light id in the scene (used in scene.findLighById for instance)
  69006. */
  69007. id: string;
  69008. /**
  69009. * The position the shdow will be casted from.
  69010. */
  69011. position: Vector3;
  69012. /**
  69013. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69014. */
  69015. direction: Vector3;
  69016. /**
  69017. * The transformed position. Position of the light in world space taking parenting in account.
  69018. */
  69019. transformedPosition: Vector3;
  69020. /**
  69021. * The transformed direction. Direction of the light in world space taking parenting in account.
  69022. */
  69023. transformedDirection: Vector3;
  69024. /**
  69025. * The friendly name of the light in the scene.
  69026. */
  69027. name: string;
  69028. /**
  69029. * Defines the shadow projection clipping minimum z value.
  69030. */
  69031. shadowMinZ: number;
  69032. /**
  69033. * Defines the shadow projection clipping maximum z value.
  69034. */
  69035. shadowMaxZ: number;
  69036. /**
  69037. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69038. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69039. */
  69040. computeTransformedInformation(): boolean;
  69041. /**
  69042. * Gets the scene the light belongs to.
  69043. * @returns The scene
  69044. */
  69045. getScene(): Scene;
  69046. /**
  69047. * Callback defining a custom Projection Matrix Builder.
  69048. * This can be used to override the default projection matrix computation.
  69049. */
  69050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69051. /**
  69052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69053. * @param matrix The materix to updated with the projection information
  69054. * @param viewMatrix The transform matrix of the light
  69055. * @param renderList The list of mesh to render in the map
  69056. * @returns The current light
  69057. */
  69058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69059. /**
  69060. * Gets the current depth scale used in ESM.
  69061. * @returns The scale
  69062. */
  69063. getDepthScale(): number;
  69064. /**
  69065. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69066. * @returns true if a cube texture needs to be use
  69067. */
  69068. needCube(): boolean;
  69069. /**
  69070. * Detects if the projection matrix requires to be recomputed this frame.
  69071. * @returns true if it requires to be recomputed otherwise, false.
  69072. */
  69073. needProjectionMatrixCompute(): boolean;
  69074. /**
  69075. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69076. */
  69077. forceProjectionMatrixCompute(): void;
  69078. /**
  69079. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69080. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69081. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69082. */
  69083. getShadowDirection(faceIndex?: number): Vector3;
  69084. /**
  69085. * Gets the minZ used for shadow according to both the scene and the light.
  69086. * @param activeCamera The camera we are returning the min for
  69087. * @returns the depth min z
  69088. */
  69089. getDepthMinZ(activeCamera: Camera): number;
  69090. /**
  69091. * Gets the maxZ used for shadow according to both the scene and the light.
  69092. * @param activeCamera The camera we are returning the max for
  69093. * @returns the depth max z
  69094. */
  69095. getDepthMaxZ(activeCamera: Camera): number;
  69096. }
  69097. /**
  69098. * Base implementation IShadowLight
  69099. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69100. */
  69101. export abstract class ShadowLight extends Light implements IShadowLight {
  69102. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69103. protected _position: Vector3;
  69104. protected _setPosition(value: Vector3): void;
  69105. /**
  69106. * Sets the position the shadow will be casted from. Also use as the light position for both
  69107. * point and spot lights.
  69108. */
  69109. /**
  69110. * Sets the position the shadow will be casted from. Also use as the light position for both
  69111. * point and spot lights.
  69112. */
  69113. position: Vector3;
  69114. protected _direction: Vector3;
  69115. protected _setDirection(value: Vector3): void;
  69116. /**
  69117. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69118. * Also use as the light direction on spot and directional lights.
  69119. */
  69120. /**
  69121. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69122. * Also use as the light direction on spot and directional lights.
  69123. */
  69124. direction: Vector3;
  69125. private _shadowMinZ;
  69126. /**
  69127. * Gets the shadow projection clipping minimum z value.
  69128. */
  69129. /**
  69130. * Sets the shadow projection clipping minimum z value.
  69131. */
  69132. shadowMinZ: number;
  69133. private _shadowMaxZ;
  69134. /**
  69135. * Sets the shadow projection clipping maximum z value.
  69136. */
  69137. /**
  69138. * Gets the shadow projection clipping maximum z value.
  69139. */
  69140. shadowMaxZ: number;
  69141. /**
  69142. * Callback defining a custom Projection Matrix Builder.
  69143. * This can be used to override the default projection matrix computation.
  69144. */
  69145. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69146. /**
  69147. * The transformed position. Position of the light in world space taking parenting in account.
  69148. */
  69149. transformedPosition: Vector3;
  69150. /**
  69151. * The transformed direction. Direction of the light in world space taking parenting in account.
  69152. */
  69153. transformedDirection: Vector3;
  69154. private _needProjectionMatrixCompute;
  69155. /**
  69156. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69157. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69158. */
  69159. computeTransformedInformation(): boolean;
  69160. /**
  69161. * Return the depth scale used for the shadow map.
  69162. * @returns the depth scale.
  69163. */
  69164. getDepthScale(): number;
  69165. /**
  69166. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69167. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69168. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69169. */
  69170. getShadowDirection(faceIndex?: number): Vector3;
  69171. /**
  69172. * Returns the ShadowLight absolute position in the World.
  69173. * @returns the position vector in world space
  69174. */
  69175. getAbsolutePosition(): Vector3;
  69176. /**
  69177. * Sets the ShadowLight direction toward the passed target.
  69178. * @param target The point to target in local space
  69179. * @returns the updated ShadowLight direction
  69180. */
  69181. setDirectionToTarget(target: Vector3): Vector3;
  69182. /**
  69183. * Returns the light rotation in euler definition.
  69184. * @returns the x y z rotation in local space.
  69185. */
  69186. getRotation(): Vector3;
  69187. /**
  69188. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69189. * @returns true if a cube texture needs to be use
  69190. */
  69191. needCube(): boolean;
  69192. /**
  69193. * Detects if the projection matrix requires to be recomputed this frame.
  69194. * @returns true if it requires to be recomputed otherwise, false.
  69195. */
  69196. needProjectionMatrixCompute(): boolean;
  69197. /**
  69198. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69199. */
  69200. forceProjectionMatrixCompute(): void;
  69201. /** @hidden */
  69202. _initCache(): void;
  69203. /** @hidden */
  69204. _isSynchronized(): boolean;
  69205. /**
  69206. * Computes the world matrix of the node
  69207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69208. * @returns the world matrix
  69209. */
  69210. computeWorldMatrix(force?: boolean): Matrix;
  69211. /**
  69212. * Gets the minZ used for shadow according to both the scene and the light.
  69213. * @param activeCamera The camera we are returning the min for
  69214. * @returns the depth min z
  69215. */
  69216. getDepthMinZ(activeCamera: Camera): number;
  69217. /**
  69218. * Gets the maxZ used for shadow according to both the scene and the light.
  69219. * @param activeCamera The camera we are returning the max for
  69220. * @returns the depth max z
  69221. */
  69222. getDepthMaxZ(activeCamera: Camera): number;
  69223. /**
  69224. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69225. * @param matrix The materix to updated with the projection information
  69226. * @param viewMatrix The transform matrix of the light
  69227. * @param renderList The list of mesh to render in the map
  69228. * @returns The current light
  69229. */
  69230. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /**
  69235. * "Static Class" containing the most commonly used helper while dealing with material for
  69236. * rendering purpose.
  69237. *
  69238. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69239. *
  69240. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69241. */
  69242. export class MaterialHelper {
  69243. /**
  69244. * Bind the current view position to an effect.
  69245. * @param effect The effect to be bound
  69246. * @param scene The scene the eyes position is used from
  69247. */
  69248. static BindEyePosition(effect: Effect, scene: Scene): void;
  69249. /**
  69250. * Helps preparing the defines values about the UVs in used in the effect.
  69251. * UVs are shared as much as we can accross channels in the shaders.
  69252. * @param texture The texture we are preparing the UVs for
  69253. * @param defines The defines to update
  69254. * @param key The channel key "diffuse", "specular"... used in the shader
  69255. */
  69256. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69257. /**
  69258. * Binds a texture matrix value to its corrsponding uniform
  69259. * @param texture The texture to bind the matrix for
  69260. * @param uniformBuffer The uniform buffer receivin the data
  69261. * @param key The channel key "diffuse", "specular"... used in the shader
  69262. */
  69263. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69264. /**
  69265. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69266. * @param mesh defines the current mesh
  69267. * @param scene defines the current scene
  69268. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69269. * @param pointsCloud defines if point cloud rendering has to be turned on
  69270. * @param fogEnabled defines if fog has to be turned on
  69271. * @param alphaTest defines if alpha testing has to be turned on
  69272. * @param defines defines the current list of defines
  69273. */
  69274. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69275. /**
  69276. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69277. * @param scene defines the current scene
  69278. * @param engine defines the current engine
  69279. * @param defines specifies the list of active defines
  69280. * @param useInstances defines if instances have to be turned on
  69281. * @param useClipPlane defines if clip plane have to be turned on
  69282. */
  69283. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69284. /**
  69285. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69286. * @param mesh The mesh containing the geometry data we will draw
  69287. * @param defines The defines to update
  69288. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69289. * @param useBones Precise whether bones should be used or not (override mesh info)
  69290. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69291. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69292. * @returns false if defines are considered not dirty and have not been checked
  69293. */
  69294. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69295. /**
  69296. * Prepares the defines related to multiview
  69297. * @param scene The scene we are intending to draw
  69298. * @param defines The defines to update
  69299. */
  69300. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69301. /**
  69302. * Prepares the defines related to the light information passed in parameter
  69303. * @param scene The scene we are intending to draw
  69304. * @param mesh The mesh the effect is compiling for
  69305. * @param defines The defines to update
  69306. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69307. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69308. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69309. * @returns true if normals will be required for the rest of the effect
  69310. */
  69311. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69312. /**
  69313. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69314. * that won t be acctive due to defines being turned off.
  69315. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69316. * @param samplersList The samplers list
  69317. * @param defines The defines helping in the list generation
  69318. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69319. */
  69320. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69321. /**
  69322. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69323. * @param defines The defines to update while falling back
  69324. * @param fallbacks The authorized effect fallbacks
  69325. * @param maxSimultaneousLights The maximum number of lights allowed
  69326. * @param rank the current rank of the Effect
  69327. * @returns The newly affected rank
  69328. */
  69329. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69330. /**
  69331. * Prepares the list of attributes required for morph targets according to the effect defines.
  69332. * @param attribs The current list of supported attribs
  69333. * @param mesh The mesh to prepare the morph targets attributes for
  69334. * @param defines The current Defines of the effect
  69335. */
  69336. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69337. /**
  69338. * Prepares the list of attributes required for bones according to the effect defines.
  69339. * @param attribs The current list of supported attribs
  69340. * @param mesh The mesh to prepare the bones attributes for
  69341. * @param defines The current Defines of the effect
  69342. * @param fallbacks The current efffect fallback strategy
  69343. */
  69344. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69345. /**
  69346. * Prepares the list of attributes required for instances according to the effect defines.
  69347. * @param attribs The current list of supported attribs
  69348. * @param defines The current Defines of the effect
  69349. */
  69350. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69351. /**
  69352. * Binds the light shadow information to the effect for the given mesh.
  69353. * @param light The light containing the generator
  69354. * @param scene The scene the lights belongs to
  69355. * @param mesh The mesh we are binding the information to render
  69356. * @param lightIndex The light index in the effect used to render the mesh
  69357. * @param effect The effect we are binding the data to
  69358. */
  69359. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69360. /**
  69361. * Binds the light information to the effect.
  69362. * @param light The light containing the generator
  69363. * @param effect The effect we are binding the data to
  69364. * @param lightIndex The light index in the effect used to render
  69365. */
  69366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69367. /**
  69368. * Binds the lights information from the scene to the effect for the given mesh.
  69369. * @param scene The scene the lights belongs to
  69370. * @param mesh The mesh we are binding the information to render
  69371. * @param effect The effect we are binding the data to
  69372. * @param defines The generated defines for the effect
  69373. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69374. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69375. */
  69376. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69377. private static _tempFogColor;
  69378. /**
  69379. * Binds the fog information from the scene to the effect for the given mesh.
  69380. * @param scene The scene the lights belongs to
  69381. * @param mesh The mesh we are binding the information to render
  69382. * @param effect The effect we are binding the data to
  69383. * @param linearSpace Defines if the fog effect is applied in linear space
  69384. */
  69385. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69386. /**
  69387. * Binds the bones information from the mesh to the effect.
  69388. * @param mesh The mesh we are binding the information to render
  69389. * @param effect The effect we are binding the data to
  69390. */
  69391. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69392. /**
  69393. * Binds the morph targets information from the mesh to the effect.
  69394. * @param abstractMesh The mesh we are binding the information to render
  69395. * @param effect The effect we are binding the data to
  69396. */
  69397. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69398. /**
  69399. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69400. * @param defines The generated defines used in the effect
  69401. * @param effect The effect we are binding the data to
  69402. * @param scene The scene we are willing to render with logarithmic scale for
  69403. */
  69404. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69405. /**
  69406. * Binds the clip plane information from the scene to the effect.
  69407. * @param scene The scene the clip plane information are extracted from
  69408. * @param effect The effect we are binding the data to
  69409. */
  69410. static BindClipPlane(effect: Effect, scene: Scene): void;
  69411. }
  69412. }
  69413. declare module BABYLON {
  69414. /** @hidden */
  69415. export var kernelBlurVaryingDeclaration: {
  69416. name: string;
  69417. shader: string;
  69418. };
  69419. }
  69420. declare module BABYLON {
  69421. /** @hidden */
  69422. export var kernelBlurFragment: {
  69423. name: string;
  69424. shader: string;
  69425. };
  69426. }
  69427. declare module BABYLON {
  69428. /** @hidden */
  69429. export var kernelBlurFragment2: {
  69430. name: string;
  69431. shader: string;
  69432. };
  69433. }
  69434. declare module BABYLON {
  69435. /** @hidden */
  69436. export var kernelBlurPixelShader: {
  69437. name: string;
  69438. shader: string;
  69439. };
  69440. }
  69441. declare module BABYLON {
  69442. /** @hidden */
  69443. export var kernelBlurVertex: {
  69444. name: string;
  69445. shader: string;
  69446. };
  69447. }
  69448. declare module BABYLON {
  69449. /** @hidden */
  69450. export var kernelBlurVertexShader: {
  69451. name: string;
  69452. shader: string;
  69453. };
  69454. }
  69455. declare module BABYLON {
  69456. /**
  69457. * The Blur Post Process which blurs an image based on a kernel and direction.
  69458. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69459. */
  69460. export class BlurPostProcess extends PostProcess {
  69461. /** The direction in which to blur the image. */
  69462. direction: Vector2;
  69463. private blockCompilation;
  69464. protected _kernel: number;
  69465. protected _idealKernel: number;
  69466. protected _packedFloat: boolean;
  69467. private _staticDefines;
  69468. /**
  69469. * Sets the length in pixels of the blur sample region
  69470. */
  69471. /**
  69472. * Gets the length in pixels of the blur sample region
  69473. */
  69474. kernel: number;
  69475. /**
  69476. * Sets wether or not the blur needs to unpack/repack floats
  69477. */
  69478. /**
  69479. * Gets wether or not the blur is unpacking/repacking floats
  69480. */
  69481. packedFloat: boolean;
  69482. /**
  69483. * Creates a new instance BlurPostProcess
  69484. * @param name The name of the effect.
  69485. * @param direction The direction in which to blur the image.
  69486. * @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.
  69487. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69488. * @param camera The camera to apply the render pass to.
  69489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69490. * @param engine The engine which the post process will be applied. (default: current engine)
  69491. * @param reusable If the post process can be reused on the same frame. (default: false)
  69492. * @param textureType Type of textures used when performing the post process. (default: 0)
  69493. * @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)
  69494. */
  69495. constructor(name: string,
  69496. /** The direction in which to blur the image. */
  69497. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69498. /**
  69499. * Updates the effect with the current post process compile time values and recompiles the shader.
  69500. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69501. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69502. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69503. * @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
  69504. * @param onCompiled Called when the shader has been compiled.
  69505. * @param onError Called if there is an error when compiling a shader.
  69506. */
  69507. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69508. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69509. /**
  69510. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69511. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69512. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69513. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69514. * The gaps between physical kernels are compensated for in the weighting of the samples
  69515. * @param idealKernel Ideal blur kernel.
  69516. * @return Nearest best kernel.
  69517. */
  69518. protected _nearestBestKernel(idealKernel: number): number;
  69519. /**
  69520. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69521. * @param x The point on the Gaussian distribution to sample.
  69522. * @return the value of the Gaussian function at x.
  69523. */
  69524. protected _gaussianWeight(x: number): number;
  69525. /**
  69526. * Generates a string that can be used as a floating point number in GLSL.
  69527. * @param x Value to print.
  69528. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69529. * @return GLSL float string.
  69530. */
  69531. protected _glslFloat(x: number, decimalFigures?: number): string;
  69532. }
  69533. }
  69534. declare module BABYLON {
  69535. /** @hidden */
  69536. export var shadowMapPixelShader: {
  69537. name: string;
  69538. shader: string;
  69539. };
  69540. }
  69541. declare module BABYLON {
  69542. /** @hidden */
  69543. export var bonesDeclaration: {
  69544. name: string;
  69545. shader: string;
  69546. };
  69547. }
  69548. declare module BABYLON {
  69549. /** @hidden */
  69550. export var morphTargetsVertexGlobalDeclaration: {
  69551. name: string;
  69552. shader: string;
  69553. };
  69554. }
  69555. declare module BABYLON {
  69556. /** @hidden */
  69557. export var morphTargetsVertexDeclaration: {
  69558. name: string;
  69559. shader: string;
  69560. };
  69561. }
  69562. declare module BABYLON {
  69563. /** @hidden */
  69564. export var instancesDeclaration: {
  69565. name: string;
  69566. shader: string;
  69567. };
  69568. }
  69569. declare module BABYLON {
  69570. /** @hidden */
  69571. export var helperFunctions: {
  69572. name: string;
  69573. shader: string;
  69574. };
  69575. }
  69576. declare module BABYLON {
  69577. /** @hidden */
  69578. export var morphTargetsVertex: {
  69579. name: string;
  69580. shader: string;
  69581. };
  69582. }
  69583. declare module BABYLON {
  69584. /** @hidden */
  69585. export var instancesVertex: {
  69586. name: string;
  69587. shader: string;
  69588. };
  69589. }
  69590. declare module BABYLON {
  69591. /** @hidden */
  69592. export var bonesVertex: {
  69593. name: string;
  69594. shader: string;
  69595. };
  69596. }
  69597. declare module BABYLON {
  69598. /** @hidden */
  69599. export var shadowMapVertexShader: {
  69600. name: string;
  69601. shader: string;
  69602. };
  69603. }
  69604. declare module BABYLON {
  69605. /** @hidden */
  69606. export var depthBoxBlurPixelShader: {
  69607. name: string;
  69608. shader: string;
  69609. };
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69614. */
  69615. export interface ICustomShaderOptions {
  69616. /**
  69617. * Gets or sets the custom shader name to use
  69618. */
  69619. shaderName: string;
  69620. /**
  69621. * The list of attribute names used in the shader
  69622. */
  69623. attributes?: string[];
  69624. /**
  69625. * The list of unifrom names used in the shader
  69626. */
  69627. uniforms?: string[];
  69628. /**
  69629. * The list of sampler names used in the shader
  69630. */
  69631. samplers?: string[];
  69632. /**
  69633. * The list of defines used in the shader
  69634. */
  69635. defines?: string[];
  69636. }
  69637. /**
  69638. * Interface to implement to create a shadow generator compatible with BJS.
  69639. */
  69640. export interface IShadowGenerator {
  69641. /**
  69642. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69643. * @returns The render target texture if present otherwise, null
  69644. */
  69645. getShadowMap(): Nullable<RenderTargetTexture>;
  69646. /**
  69647. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69648. * @returns The render target texture if the shadow map is present otherwise, null
  69649. */
  69650. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69651. /**
  69652. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69653. * @param subMesh The submesh we want to render in the shadow map
  69654. * @param useInstances Defines wether will draw in the map using instances
  69655. * @returns true if ready otherwise, false
  69656. */
  69657. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69658. /**
  69659. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69660. * @param defines Defines of the material we want to update
  69661. * @param lightIndex Index of the light in the enabled light list of the material
  69662. */
  69663. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69664. /**
  69665. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69666. * defined in the generator but impacting the effect).
  69667. * It implies the unifroms available on the materials are the standard BJS ones.
  69668. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69669. * @param effect The effect we are binfing the information for
  69670. */
  69671. bindShadowLight(lightIndex: string, effect: Effect): void;
  69672. /**
  69673. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69674. * (eq to shadow prjection matrix * light transform matrix)
  69675. * @returns The transform matrix used to create the shadow map
  69676. */
  69677. getTransformMatrix(): Matrix;
  69678. /**
  69679. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69680. * Cube and 2D textures for instance.
  69681. */
  69682. recreateShadowMap(): void;
  69683. /**
  69684. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69685. * @param onCompiled Callback triggered at the and of the effects compilation
  69686. * @param options Sets of optional options forcing the compilation with different modes
  69687. */
  69688. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69689. useInstances: boolean;
  69690. }>): void;
  69691. /**
  69692. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69693. * @param options Sets of optional options forcing the compilation with different modes
  69694. * @returns A promise that resolves when the compilation completes
  69695. */
  69696. forceCompilationAsync(options?: Partial<{
  69697. useInstances: boolean;
  69698. }>): Promise<void>;
  69699. /**
  69700. * Serializes the shadow generator setup to a json object.
  69701. * @returns The serialized JSON object
  69702. */
  69703. serialize(): any;
  69704. /**
  69705. * Disposes the Shadow map and related Textures and effects.
  69706. */
  69707. dispose(): void;
  69708. }
  69709. /**
  69710. * Default implementation IShadowGenerator.
  69711. * This is the main object responsible of generating shadows in the framework.
  69712. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69713. */
  69714. export class ShadowGenerator implements IShadowGenerator {
  69715. /**
  69716. * Shadow generator mode None: no filtering applied.
  69717. */
  69718. static readonly FILTER_NONE: number;
  69719. /**
  69720. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69721. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69722. */
  69723. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69724. /**
  69725. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69726. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69727. */
  69728. static readonly FILTER_POISSONSAMPLING: number;
  69729. /**
  69730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69731. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69732. */
  69733. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69734. /**
  69735. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69736. * edge artifacts on steep falloff.
  69737. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69738. */
  69739. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69740. /**
  69741. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69742. * edge artifacts on steep falloff.
  69743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69744. */
  69745. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69746. /**
  69747. * Shadow generator mode PCF: Percentage Closer Filtering
  69748. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69749. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69750. */
  69751. static readonly FILTER_PCF: number;
  69752. /**
  69753. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69754. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69755. * Contact Hardening
  69756. */
  69757. static readonly FILTER_PCSS: number;
  69758. /**
  69759. * Reserved for PCF and PCSS
  69760. * Highest Quality.
  69761. *
  69762. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69763. *
  69764. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69765. */
  69766. static readonly QUALITY_HIGH: number;
  69767. /**
  69768. * Reserved for PCF and PCSS
  69769. * Good tradeoff for quality/perf cross devices
  69770. *
  69771. * Execute PCF on a 3*3 kernel.
  69772. *
  69773. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69774. */
  69775. static readonly QUALITY_MEDIUM: number;
  69776. /**
  69777. * Reserved for PCF and PCSS
  69778. * The lowest quality but the fastest.
  69779. *
  69780. * Execute PCF on a 1*1 kernel.
  69781. *
  69782. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69783. */
  69784. static readonly QUALITY_LOW: number;
  69785. /** Gets or sets the custom shader name to use */
  69786. customShaderOptions: ICustomShaderOptions;
  69787. /**
  69788. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69789. */
  69790. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69791. /**
  69792. * Observable triggered before a mesh is rendered in the shadow map.
  69793. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69794. */
  69795. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69796. private _bias;
  69797. /**
  69798. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69799. */
  69800. /**
  69801. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69802. */
  69803. bias: number;
  69804. private _normalBias;
  69805. /**
  69806. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69807. */
  69808. /**
  69809. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69810. */
  69811. normalBias: number;
  69812. private _blurBoxOffset;
  69813. /**
  69814. * Gets the blur box offset: offset applied during the blur pass.
  69815. * Only useful if useKernelBlur = false
  69816. */
  69817. /**
  69818. * Sets the blur box offset: offset applied during the blur pass.
  69819. * Only useful if useKernelBlur = false
  69820. */
  69821. blurBoxOffset: number;
  69822. private _blurScale;
  69823. /**
  69824. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69825. * 2 means half of the size.
  69826. */
  69827. /**
  69828. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69829. * 2 means half of the size.
  69830. */
  69831. blurScale: number;
  69832. private _blurKernel;
  69833. /**
  69834. * Gets the blur kernel: kernel size of the blur pass.
  69835. * Only useful if useKernelBlur = true
  69836. */
  69837. /**
  69838. * Sets the blur kernel: kernel size of the blur pass.
  69839. * Only useful if useKernelBlur = true
  69840. */
  69841. blurKernel: number;
  69842. private _useKernelBlur;
  69843. /**
  69844. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69845. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69846. */
  69847. /**
  69848. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69849. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69850. */
  69851. useKernelBlur: boolean;
  69852. private _depthScale;
  69853. /**
  69854. * Gets the depth scale used in ESM mode.
  69855. */
  69856. /**
  69857. * Sets the depth scale used in ESM mode.
  69858. * This can override the scale stored on the light.
  69859. */
  69860. depthScale: number;
  69861. private _filter;
  69862. /**
  69863. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69864. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69865. */
  69866. /**
  69867. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69868. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69869. */
  69870. filter: number;
  69871. /**
  69872. * Gets if the current filter is set to Poisson Sampling.
  69873. */
  69874. /**
  69875. * Sets the current filter to Poisson Sampling.
  69876. */
  69877. usePoissonSampling: boolean;
  69878. /**
  69879. * Gets if the current filter is set to ESM.
  69880. */
  69881. /**
  69882. * Sets the current filter is to ESM.
  69883. */
  69884. useExponentialShadowMap: boolean;
  69885. /**
  69886. * Gets if the current filter is set to filtered ESM.
  69887. */
  69888. /**
  69889. * Gets if the current filter is set to filtered ESM.
  69890. */
  69891. useBlurExponentialShadowMap: boolean;
  69892. /**
  69893. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69894. * exponential to prevent steep falloff artifacts).
  69895. */
  69896. /**
  69897. * Sets the current filter to "close ESM" (using the inverse of the
  69898. * exponential to prevent steep falloff artifacts).
  69899. */
  69900. useCloseExponentialShadowMap: boolean;
  69901. /**
  69902. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69903. * exponential to prevent steep falloff artifacts).
  69904. */
  69905. /**
  69906. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69907. * exponential to prevent steep falloff artifacts).
  69908. */
  69909. useBlurCloseExponentialShadowMap: boolean;
  69910. /**
  69911. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69912. */
  69913. /**
  69914. * Sets the current filter to "PCF" (percentage closer filtering).
  69915. */
  69916. usePercentageCloserFiltering: boolean;
  69917. private _filteringQuality;
  69918. /**
  69919. * Gets the PCF or PCSS Quality.
  69920. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69921. */
  69922. /**
  69923. * Sets the PCF or PCSS Quality.
  69924. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69925. */
  69926. filteringQuality: number;
  69927. /**
  69928. * Gets if the current filter is set to "PCSS" (contact hardening).
  69929. */
  69930. /**
  69931. * Sets the current filter to "PCSS" (contact hardening).
  69932. */
  69933. useContactHardeningShadow: boolean;
  69934. private _contactHardeningLightSizeUVRatio;
  69935. /**
  69936. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69937. * Using a ratio helps keeping shape stability independently of the map size.
  69938. *
  69939. * It does not account for the light projection as it was having too much
  69940. * instability during the light setup or during light position changes.
  69941. *
  69942. * Only valid if useContactHardeningShadow is true.
  69943. */
  69944. /**
  69945. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69946. * Using a ratio helps keeping shape stability independently of the map size.
  69947. *
  69948. * It does not account for the light projection as it was having too much
  69949. * instability during the light setup or during light position changes.
  69950. *
  69951. * Only valid if useContactHardeningShadow is true.
  69952. */
  69953. contactHardeningLightSizeUVRatio: number;
  69954. private _darkness;
  69955. /**
  69956. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69957. * 0 means strongest and 1 would means no shadow.
  69958. * @returns the darkness.
  69959. */
  69960. getDarkness(): number;
  69961. /**
  69962. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69963. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69964. * @returns the shadow generator allowing fluent coding.
  69965. */
  69966. setDarkness(darkness: number): ShadowGenerator;
  69967. private _transparencyShadow;
  69968. /**
  69969. * Sets the ability to have transparent shadow (boolean).
  69970. * @param transparent True if transparent else False
  69971. * @returns the shadow generator allowing fluent coding
  69972. */
  69973. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69974. private _shadowMap;
  69975. private _shadowMap2;
  69976. /**
  69977. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69978. * @returns The render target texture if present otherwise, null
  69979. */
  69980. getShadowMap(): Nullable<RenderTargetTexture>;
  69981. /**
  69982. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69983. * @returns The render target texture if the shadow map is present otherwise, null
  69984. */
  69985. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69986. /**
  69987. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69988. * @param mesh Mesh to add
  69989. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69990. * @returns the Shadow Generator itself
  69991. */
  69992. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69993. /**
  69994. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69995. * @param mesh Mesh to remove
  69996. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69997. * @returns the Shadow Generator itself
  69998. */
  69999. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70000. /**
  70001. * Controls the extent to which the shadows fade out at the edge of the frustum
  70002. * Used only by directionals and spots
  70003. */
  70004. frustumEdgeFalloff: number;
  70005. private _light;
  70006. /**
  70007. * Returns the associated light object.
  70008. * @returns the light generating the shadow
  70009. */
  70010. getLight(): IShadowLight;
  70011. /**
  70012. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70013. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70014. * It might on the other hand introduce peter panning.
  70015. */
  70016. forceBackFacesOnly: boolean;
  70017. private _scene;
  70018. private _lightDirection;
  70019. private _effect;
  70020. private _viewMatrix;
  70021. private _projectionMatrix;
  70022. private _transformMatrix;
  70023. private _cachedPosition;
  70024. private _cachedDirection;
  70025. private _cachedDefines;
  70026. private _currentRenderID;
  70027. private _boxBlurPostprocess;
  70028. private _kernelBlurXPostprocess;
  70029. private _kernelBlurYPostprocess;
  70030. private _blurPostProcesses;
  70031. private _mapSize;
  70032. private _currentFaceIndex;
  70033. private _currentFaceIndexCache;
  70034. private _textureType;
  70035. private _defaultTextureMatrix;
  70036. /** @hidden */
  70037. static _SceneComponentInitialization: (scene: Scene) => void;
  70038. /**
  70039. * Creates a ShadowGenerator object.
  70040. * A ShadowGenerator is the required tool to use the shadows.
  70041. * Each light casting shadows needs to use its own ShadowGenerator.
  70042. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70043. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70044. * @param light The light object generating the shadows.
  70045. * @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.
  70046. */
  70047. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70048. private _initializeGenerator;
  70049. private _initializeShadowMap;
  70050. private _initializeBlurRTTAndPostProcesses;
  70051. private _renderForShadowMap;
  70052. private _renderSubMeshForShadowMap;
  70053. private _applyFilterValues;
  70054. /**
  70055. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70056. * @param onCompiled Callback triggered at the and of the effects compilation
  70057. * @param options Sets of optional options forcing the compilation with different modes
  70058. */
  70059. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70060. useInstances: boolean;
  70061. }>): void;
  70062. /**
  70063. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70064. * @param options Sets of optional options forcing the compilation with different modes
  70065. * @returns A promise that resolves when the compilation completes
  70066. */
  70067. forceCompilationAsync(options?: Partial<{
  70068. useInstances: boolean;
  70069. }>): Promise<void>;
  70070. /**
  70071. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70072. * @param subMesh The submesh we want to render in the shadow map
  70073. * @param useInstances Defines wether will draw in the map using instances
  70074. * @returns true if ready otherwise, false
  70075. */
  70076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70077. /**
  70078. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70079. * @param defines Defines of the material we want to update
  70080. * @param lightIndex Index of the light in the enabled light list of the material
  70081. */
  70082. prepareDefines(defines: any, lightIndex: number): void;
  70083. /**
  70084. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70085. * defined in the generator but impacting the effect).
  70086. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70087. * @param effect The effect we are binfing the information for
  70088. */
  70089. bindShadowLight(lightIndex: string, effect: Effect): void;
  70090. /**
  70091. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70092. * (eq to shadow prjection matrix * light transform matrix)
  70093. * @returns The transform matrix used to create the shadow map
  70094. */
  70095. getTransformMatrix(): Matrix;
  70096. /**
  70097. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70098. * Cube and 2D textures for instance.
  70099. */
  70100. recreateShadowMap(): void;
  70101. private _disposeBlurPostProcesses;
  70102. private _disposeRTTandPostProcesses;
  70103. /**
  70104. * Disposes the ShadowGenerator.
  70105. * Returns nothing.
  70106. */
  70107. dispose(): void;
  70108. /**
  70109. * Serializes the shadow generator setup to a json object.
  70110. * @returns The serialized JSON object
  70111. */
  70112. serialize(): any;
  70113. /**
  70114. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70115. * @param parsedShadowGenerator The JSON object to parse
  70116. * @param scene The scene to create the shadow map for
  70117. * @returns The parsed shadow generator
  70118. */
  70119. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70120. }
  70121. }
  70122. declare module BABYLON {
  70123. /**
  70124. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70125. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70126. * 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.
  70127. */
  70128. export abstract class Light extends Node {
  70129. /**
  70130. * Falloff Default: light is falling off following the material specification:
  70131. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70132. */
  70133. static readonly FALLOFF_DEFAULT: number;
  70134. /**
  70135. * Falloff Physical: light is falling off following the inverse squared distance law.
  70136. */
  70137. static readonly FALLOFF_PHYSICAL: number;
  70138. /**
  70139. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70140. * to enhance interoperability with other engines.
  70141. */
  70142. static readonly FALLOFF_GLTF: number;
  70143. /**
  70144. * Falloff Standard: light is falling off like in the standard material
  70145. * to enhance interoperability with other materials.
  70146. */
  70147. static readonly FALLOFF_STANDARD: number;
  70148. /**
  70149. * If every light affecting the material is in this lightmapMode,
  70150. * material.lightmapTexture adds or multiplies
  70151. * (depends on material.useLightmapAsShadowmap)
  70152. * after every other light calculations.
  70153. */
  70154. static readonly LIGHTMAP_DEFAULT: number;
  70155. /**
  70156. * material.lightmapTexture as only diffuse lighting from this light
  70157. * adds only specular lighting from this light
  70158. * adds dynamic shadows
  70159. */
  70160. static readonly LIGHTMAP_SPECULAR: number;
  70161. /**
  70162. * material.lightmapTexture as only lighting
  70163. * no light calculation from this light
  70164. * only adds dynamic shadows from this light
  70165. */
  70166. static readonly LIGHTMAP_SHADOWSONLY: number;
  70167. /**
  70168. * Each light type uses the default quantity according to its type:
  70169. * point/spot lights use luminous intensity
  70170. * directional lights use illuminance
  70171. */
  70172. static readonly INTENSITYMODE_AUTOMATIC: number;
  70173. /**
  70174. * lumen (lm)
  70175. */
  70176. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70177. /**
  70178. * candela (lm/sr)
  70179. */
  70180. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70181. /**
  70182. * lux (lm/m^2)
  70183. */
  70184. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70185. /**
  70186. * nit (cd/m^2)
  70187. */
  70188. static readonly INTENSITYMODE_LUMINANCE: number;
  70189. /**
  70190. * Light type const id of the point light.
  70191. */
  70192. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70193. /**
  70194. * Light type const id of the directional light.
  70195. */
  70196. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70197. /**
  70198. * Light type const id of the spot light.
  70199. */
  70200. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70201. /**
  70202. * Light type const id of the hemispheric light.
  70203. */
  70204. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70205. /**
  70206. * Diffuse gives the basic color to an object.
  70207. */
  70208. diffuse: Color3;
  70209. /**
  70210. * Specular produces a highlight color on an object.
  70211. * Note: This is note affecting PBR materials.
  70212. */
  70213. specular: Color3;
  70214. /**
  70215. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70216. * falling off base on range or angle.
  70217. * This can be set to any values in Light.FALLOFF_x.
  70218. *
  70219. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70220. * other types of materials.
  70221. */
  70222. falloffType: number;
  70223. /**
  70224. * Strength of the light.
  70225. * Note: By default it is define in the framework own unit.
  70226. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70227. */
  70228. intensity: number;
  70229. private _range;
  70230. protected _inverseSquaredRange: number;
  70231. /**
  70232. * Defines how far from the source the light is impacting in scene units.
  70233. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70234. */
  70235. /**
  70236. * Defines how far from the source the light is impacting in scene units.
  70237. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70238. */
  70239. range: number;
  70240. /**
  70241. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70242. * of light.
  70243. */
  70244. private _photometricScale;
  70245. private _intensityMode;
  70246. /**
  70247. * Gets the photometric scale used to interpret the intensity.
  70248. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70249. */
  70250. /**
  70251. * Sets the photometric scale used to interpret the intensity.
  70252. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70253. */
  70254. intensityMode: number;
  70255. private _radius;
  70256. /**
  70257. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70258. */
  70259. /**
  70260. * sets the light radius used by PBR Materials to simulate soft area lights.
  70261. */
  70262. radius: number;
  70263. private _renderPriority;
  70264. /**
  70265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70266. * exceeding the number allowed of the materials.
  70267. */
  70268. renderPriority: number;
  70269. private _shadowEnabled;
  70270. /**
  70271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70272. * the current shadow generator.
  70273. */
  70274. /**
  70275. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70276. * the current shadow generator.
  70277. */
  70278. shadowEnabled: boolean;
  70279. private _includedOnlyMeshes;
  70280. /**
  70281. * Gets the only meshes impacted by this light.
  70282. */
  70283. /**
  70284. * Sets the only meshes impacted by this light.
  70285. */
  70286. includedOnlyMeshes: AbstractMesh[];
  70287. private _excludedMeshes;
  70288. /**
  70289. * Gets the meshes not impacted by this light.
  70290. */
  70291. /**
  70292. * Sets the meshes not impacted by this light.
  70293. */
  70294. excludedMeshes: AbstractMesh[];
  70295. private _excludeWithLayerMask;
  70296. /**
  70297. * Gets the layer id use to find what meshes are not impacted by the light.
  70298. * Inactive if 0
  70299. */
  70300. /**
  70301. * Sets the layer id use to find what meshes are not impacted by the light.
  70302. * Inactive if 0
  70303. */
  70304. excludeWithLayerMask: number;
  70305. private _includeOnlyWithLayerMask;
  70306. /**
  70307. * Gets the layer id use to find what meshes are impacted by the light.
  70308. * Inactive if 0
  70309. */
  70310. /**
  70311. * Sets the layer id use to find what meshes are impacted by the light.
  70312. * Inactive if 0
  70313. */
  70314. includeOnlyWithLayerMask: number;
  70315. private _lightmapMode;
  70316. /**
  70317. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70318. */
  70319. /**
  70320. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70321. */
  70322. lightmapMode: number;
  70323. /**
  70324. * Shadow generator associted to the light.
  70325. * @hidden Internal use only.
  70326. */
  70327. _shadowGenerator: Nullable<IShadowGenerator>;
  70328. /**
  70329. * @hidden Internal use only.
  70330. */
  70331. _excludedMeshesIds: string[];
  70332. /**
  70333. * @hidden Internal use only.
  70334. */
  70335. _includedOnlyMeshesIds: string[];
  70336. /**
  70337. * The current light unifom buffer.
  70338. * @hidden Internal use only.
  70339. */
  70340. _uniformBuffer: UniformBuffer;
  70341. /**
  70342. * Creates a Light object in the scene.
  70343. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70344. * @param name The firendly name of the light
  70345. * @param scene The scene the light belongs too
  70346. */
  70347. constructor(name: string, scene: Scene);
  70348. protected abstract _buildUniformLayout(): void;
  70349. /**
  70350. * Sets the passed Effect "effect" with the Light information.
  70351. * @param effect The effect to update
  70352. * @param lightIndex The index of the light in the effect to update
  70353. * @returns The light
  70354. */
  70355. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70356. /**
  70357. * Returns the string "Light".
  70358. * @returns the class name
  70359. */
  70360. getClassName(): string;
  70361. /** @hidden */
  70362. readonly _isLight: boolean;
  70363. /**
  70364. * Converts the light information to a readable string for debug purpose.
  70365. * @param fullDetails Supports for multiple levels of logging within scene loading
  70366. * @returns the human readable light info
  70367. */
  70368. toString(fullDetails?: boolean): string;
  70369. /** @hidden */
  70370. protected _syncParentEnabledState(): void;
  70371. /**
  70372. * Set the enabled state of this node.
  70373. * @param value - the new enabled state
  70374. */
  70375. setEnabled(value: boolean): void;
  70376. /**
  70377. * Returns the Light associated shadow generator if any.
  70378. * @return the associated shadow generator.
  70379. */
  70380. getShadowGenerator(): Nullable<IShadowGenerator>;
  70381. /**
  70382. * Returns a Vector3, the absolute light position in the World.
  70383. * @returns the world space position of the light
  70384. */
  70385. getAbsolutePosition(): Vector3;
  70386. /**
  70387. * Specifies if the light will affect the passed mesh.
  70388. * @param mesh The mesh to test against the light
  70389. * @return true the mesh is affected otherwise, false.
  70390. */
  70391. canAffectMesh(mesh: AbstractMesh): boolean;
  70392. /**
  70393. * Sort function to order lights for rendering.
  70394. * @param a First Light object to compare to second.
  70395. * @param b Second Light object to compare first.
  70396. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70397. */
  70398. static CompareLightsPriority(a: Light, b: Light): number;
  70399. /**
  70400. * Releases resources associated with this node.
  70401. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70402. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70403. */
  70404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70405. /**
  70406. * Returns the light type ID (integer).
  70407. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70408. */
  70409. getTypeID(): number;
  70410. /**
  70411. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70412. * @returns the scaled intensity in intensity mode unit
  70413. */
  70414. getScaledIntensity(): number;
  70415. /**
  70416. * Returns a new Light object, named "name", from the current one.
  70417. * @param name The name of the cloned light
  70418. * @returns the new created light
  70419. */
  70420. clone(name: string): Nullable<Light>;
  70421. /**
  70422. * Serializes the current light into a Serialization object.
  70423. * @returns the serialized object.
  70424. */
  70425. serialize(): any;
  70426. /**
  70427. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70428. * This new light is named "name" and added to the passed scene.
  70429. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70430. * @param name The friendly name of the light
  70431. * @param scene The scene the new light will belong to
  70432. * @returns the constructor function
  70433. */
  70434. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70435. /**
  70436. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70437. * @param parsedLight The JSON representation of the light
  70438. * @param scene The scene to create the parsed light in
  70439. * @returns the created light after parsing
  70440. */
  70441. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70442. private _hookArrayForExcluded;
  70443. private _hookArrayForIncludedOnly;
  70444. private _resyncMeshes;
  70445. /**
  70446. * Forces the meshes to update their light related information in their rendering used effects
  70447. * @hidden Internal Use Only
  70448. */
  70449. _markMeshesAsLightDirty(): void;
  70450. /**
  70451. * Recomputes the cached photometric scale if needed.
  70452. */
  70453. private _computePhotometricScale;
  70454. /**
  70455. * Returns the Photometric Scale according to the light type and intensity mode.
  70456. */
  70457. private _getPhotometricScale;
  70458. /**
  70459. * Reorder the light in the scene according to their defined priority.
  70460. * @hidden Internal Use Only
  70461. */
  70462. _reorderLightsInScene(): void;
  70463. /**
  70464. * Prepares the list of defines specific to the light type.
  70465. * @param defines the list of defines
  70466. * @param lightIndex defines the index of the light for the effect
  70467. */
  70468. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. /**
  70473. * Interface used to define Action
  70474. */
  70475. export interface IAction {
  70476. /**
  70477. * Trigger for the action
  70478. */
  70479. trigger: number;
  70480. /** Options of the trigger */
  70481. triggerOptions: any;
  70482. /**
  70483. * Gets the trigger parameters
  70484. * @returns the trigger parameters
  70485. */
  70486. getTriggerParameter(): any;
  70487. /**
  70488. * Internal only - executes current action event
  70489. * @hidden
  70490. */
  70491. _executeCurrent(evt?: ActionEvent): void;
  70492. /**
  70493. * Serialize placeholder for child classes
  70494. * @param parent of child
  70495. * @returns the serialized object
  70496. */
  70497. serialize(parent: any): any;
  70498. /**
  70499. * Internal only
  70500. * @hidden
  70501. */
  70502. _prepare(): void;
  70503. /**
  70504. * Internal only - manager for action
  70505. * @hidden
  70506. */
  70507. _actionManager: AbstractActionManager;
  70508. }
  70509. /**
  70510. * The action to be carried out following a trigger
  70511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70512. */
  70513. export class Action implements IAction {
  70514. /** the trigger, with or without parameters, for the action */
  70515. triggerOptions: any;
  70516. /**
  70517. * Trigger for the action
  70518. */
  70519. trigger: number;
  70520. /**
  70521. * Internal only - manager for action
  70522. * @hidden
  70523. */
  70524. _actionManager: ActionManager;
  70525. private _nextActiveAction;
  70526. private _child;
  70527. private _condition?;
  70528. private _triggerParameter;
  70529. /**
  70530. * An event triggered prior to action being executed.
  70531. */
  70532. onBeforeExecuteObservable: Observable<Action>;
  70533. /**
  70534. * Creates a new Action
  70535. * @param triggerOptions the trigger, with or without parameters, for the action
  70536. * @param condition an optional determinant of action
  70537. */
  70538. constructor(
  70539. /** the trigger, with or without parameters, for the action */
  70540. triggerOptions: any, condition?: Condition);
  70541. /**
  70542. * Internal only
  70543. * @hidden
  70544. */
  70545. _prepare(): void;
  70546. /**
  70547. * Gets the trigger parameters
  70548. * @returns the trigger parameters
  70549. */
  70550. getTriggerParameter(): any;
  70551. /**
  70552. * Internal only - executes current action event
  70553. * @hidden
  70554. */
  70555. _executeCurrent(evt?: ActionEvent): void;
  70556. /**
  70557. * Execute placeholder for child classes
  70558. * @param evt optional action event
  70559. */
  70560. execute(evt?: ActionEvent): void;
  70561. /**
  70562. * Skips to next active action
  70563. */
  70564. skipToNextActiveAction(): void;
  70565. /**
  70566. * Adds action to chain of actions, may be a DoNothingAction
  70567. * @param action defines the next action to execute
  70568. * @returns The action passed in
  70569. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70570. */
  70571. then(action: Action): Action;
  70572. /**
  70573. * Internal only
  70574. * @hidden
  70575. */
  70576. _getProperty(propertyPath: string): string;
  70577. /**
  70578. * Internal only
  70579. * @hidden
  70580. */
  70581. _getEffectiveTarget(target: any, propertyPath: string): any;
  70582. /**
  70583. * Serialize placeholder for child classes
  70584. * @param parent of child
  70585. * @returns the serialized object
  70586. */
  70587. serialize(parent: any): any;
  70588. /**
  70589. * Internal only called by serialize
  70590. * @hidden
  70591. */
  70592. protected _serialize(serializedAction: any, parent?: any): any;
  70593. /**
  70594. * Internal only
  70595. * @hidden
  70596. */
  70597. static _SerializeValueAsString: (value: any) => string;
  70598. /**
  70599. * Internal only
  70600. * @hidden
  70601. */
  70602. static _GetTargetProperty: (target: Scene | Node) => {
  70603. name: string;
  70604. targetType: string;
  70605. value: string;
  70606. };
  70607. }
  70608. }
  70609. declare module BABYLON {
  70610. /**
  70611. * A Condition applied to an Action
  70612. */
  70613. export class Condition {
  70614. /**
  70615. * Internal only - manager for action
  70616. * @hidden
  70617. */
  70618. _actionManager: ActionManager;
  70619. /**
  70620. * Internal only
  70621. * @hidden
  70622. */
  70623. _evaluationId: number;
  70624. /**
  70625. * Internal only
  70626. * @hidden
  70627. */
  70628. _currentResult: boolean;
  70629. /**
  70630. * Creates a new Condition
  70631. * @param actionManager the manager of the action the condition is applied to
  70632. */
  70633. constructor(actionManager: ActionManager);
  70634. /**
  70635. * Check if the current condition is valid
  70636. * @returns a boolean
  70637. */
  70638. isValid(): boolean;
  70639. /**
  70640. * Internal only
  70641. * @hidden
  70642. */
  70643. _getProperty(propertyPath: string): string;
  70644. /**
  70645. * Internal only
  70646. * @hidden
  70647. */
  70648. _getEffectiveTarget(target: any, propertyPath: string): any;
  70649. /**
  70650. * Serialize placeholder for child classes
  70651. * @returns the serialized object
  70652. */
  70653. serialize(): any;
  70654. /**
  70655. * Internal only
  70656. * @hidden
  70657. */
  70658. protected _serialize(serializedCondition: any): any;
  70659. }
  70660. /**
  70661. * Defines specific conditional operators as extensions of Condition
  70662. */
  70663. export class ValueCondition extends Condition {
  70664. /** path to specify the property of the target the conditional operator uses */
  70665. propertyPath: string;
  70666. /** the value compared by the conditional operator against the current value of the property */
  70667. value: any;
  70668. /** the conditional operator, default ValueCondition.IsEqual */
  70669. operator: number;
  70670. /**
  70671. * Internal only
  70672. * @hidden
  70673. */
  70674. private static _IsEqual;
  70675. /**
  70676. * Internal only
  70677. * @hidden
  70678. */
  70679. private static _IsDifferent;
  70680. /**
  70681. * Internal only
  70682. * @hidden
  70683. */
  70684. private static _IsGreater;
  70685. /**
  70686. * Internal only
  70687. * @hidden
  70688. */
  70689. private static _IsLesser;
  70690. /**
  70691. * returns the number for IsEqual
  70692. */
  70693. static readonly IsEqual: number;
  70694. /**
  70695. * Returns the number for IsDifferent
  70696. */
  70697. static readonly IsDifferent: number;
  70698. /**
  70699. * Returns the number for IsGreater
  70700. */
  70701. static readonly IsGreater: number;
  70702. /**
  70703. * Returns the number for IsLesser
  70704. */
  70705. static readonly IsLesser: number;
  70706. /**
  70707. * Internal only The action manager for the condition
  70708. * @hidden
  70709. */
  70710. _actionManager: ActionManager;
  70711. /**
  70712. * Internal only
  70713. * @hidden
  70714. */
  70715. private _target;
  70716. /**
  70717. * Internal only
  70718. * @hidden
  70719. */
  70720. private _effectiveTarget;
  70721. /**
  70722. * Internal only
  70723. * @hidden
  70724. */
  70725. private _property;
  70726. /**
  70727. * Creates a new ValueCondition
  70728. * @param actionManager manager for the action the condition applies to
  70729. * @param target for the action
  70730. * @param propertyPath path to specify the property of the target the conditional operator uses
  70731. * @param value the value compared by the conditional operator against the current value of the property
  70732. * @param operator the conditional operator, default ValueCondition.IsEqual
  70733. */
  70734. constructor(actionManager: ActionManager, target: any,
  70735. /** path to specify the property of the target the conditional operator uses */
  70736. propertyPath: string,
  70737. /** the value compared by the conditional operator against the current value of the property */
  70738. value: any,
  70739. /** the conditional operator, default ValueCondition.IsEqual */
  70740. operator?: number);
  70741. /**
  70742. * Compares the given value with the property value for the specified conditional operator
  70743. * @returns the result of the comparison
  70744. */
  70745. isValid(): boolean;
  70746. /**
  70747. * Serialize the ValueCondition into a JSON compatible object
  70748. * @returns serialization object
  70749. */
  70750. serialize(): any;
  70751. /**
  70752. * Gets the name of the conditional operator for the ValueCondition
  70753. * @param operator the conditional operator
  70754. * @returns the name
  70755. */
  70756. static GetOperatorName(operator: number): string;
  70757. }
  70758. /**
  70759. * Defines a predicate condition as an extension of Condition
  70760. */
  70761. export class PredicateCondition extends Condition {
  70762. /** defines the predicate function used to validate the condition */
  70763. predicate: () => boolean;
  70764. /**
  70765. * Internal only - manager for action
  70766. * @hidden
  70767. */
  70768. _actionManager: ActionManager;
  70769. /**
  70770. * Creates a new PredicateCondition
  70771. * @param actionManager manager for the action the condition applies to
  70772. * @param predicate defines the predicate function used to validate the condition
  70773. */
  70774. constructor(actionManager: ActionManager,
  70775. /** defines the predicate function used to validate the condition */
  70776. predicate: () => boolean);
  70777. /**
  70778. * @returns the validity of the predicate condition
  70779. */
  70780. isValid(): boolean;
  70781. }
  70782. /**
  70783. * Defines a state condition as an extension of Condition
  70784. */
  70785. export class StateCondition extends Condition {
  70786. /** Value to compare with target state */
  70787. value: string;
  70788. /**
  70789. * Internal only - manager for action
  70790. * @hidden
  70791. */
  70792. _actionManager: ActionManager;
  70793. /**
  70794. * Internal only
  70795. * @hidden
  70796. */
  70797. private _target;
  70798. /**
  70799. * Creates a new StateCondition
  70800. * @param actionManager manager for the action the condition applies to
  70801. * @param target of the condition
  70802. * @param value to compare with target state
  70803. */
  70804. constructor(actionManager: ActionManager, target: any,
  70805. /** Value to compare with target state */
  70806. value: string);
  70807. /**
  70808. * Gets a boolean indicating if the current condition is met
  70809. * @returns the validity of the state
  70810. */
  70811. isValid(): boolean;
  70812. /**
  70813. * Serialize the StateCondition into a JSON compatible object
  70814. * @returns serialization object
  70815. */
  70816. serialize(): any;
  70817. }
  70818. }
  70819. declare module BABYLON {
  70820. /**
  70821. * This defines an action responsible to toggle a boolean once triggered.
  70822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70823. */
  70824. export class SwitchBooleanAction extends Action {
  70825. /**
  70826. * The path to the boolean property in the target object
  70827. */
  70828. propertyPath: string;
  70829. private _target;
  70830. private _effectiveTarget;
  70831. private _property;
  70832. /**
  70833. * Instantiate the action
  70834. * @param triggerOptions defines the trigger options
  70835. * @param target defines the object containing the boolean
  70836. * @param propertyPath defines the path to the boolean property in the target object
  70837. * @param condition defines the trigger related conditions
  70838. */
  70839. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70840. /** @hidden */
  70841. _prepare(): void;
  70842. /**
  70843. * Execute the action toggle the boolean value.
  70844. */
  70845. execute(): void;
  70846. /**
  70847. * Serializes the actions and its related information.
  70848. * @param parent defines the object to serialize in
  70849. * @returns the serialized object
  70850. */
  70851. serialize(parent: any): any;
  70852. }
  70853. /**
  70854. * This defines an action responsible to set a the state field of the target
  70855. * to a desired value once triggered.
  70856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70857. */
  70858. export class SetStateAction extends Action {
  70859. /**
  70860. * The value to store in the state field.
  70861. */
  70862. value: string;
  70863. private _target;
  70864. /**
  70865. * Instantiate the action
  70866. * @param triggerOptions defines the trigger options
  70867. * @param target defines the object containing the state property
  70868. * @param value defines the value to store in the state field
  70869. * @param condition defines the trigger related conditions
  70870. */
  70871. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70872. /**
  70873. * Execute the action and store the value on the target state property.
  70874. */
  70875. execute(): void;
  70876. /**
  70877. * Serializes the actions and its related information.
  70878. * @param parent defines the object to serialize in
  70879. * @returns the serialized object
  70880. */
  70881. serialize(parent: any): any;
  70882. }
  70883. /**
  70884. * This defines an action responsible to set a property of the target
  70885. * to a desired value once triggered.
  70886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70887. */
  70888. export class SetValueAction extends Action {
  70889. /**
  70890. * The path of the property to set in the target.
  70891. */
  70892. propertyPath: string;
  70893. /**
  70894. * The value to set in the property
  70895. */
  70896. value: any;
  70897. private _target;
  70898. private _effectiveTarget;
  70899. private _property;
  70900. /**
  70901. * Instantiate the action
  70902. * @param triggerOptions defines the trigger options
  70903. * @param target defines the object containing the property
  70904. * @param propertyPath defines the path of the property to set in the target
  70905. * @param value defines the value to set in the property
  70906. * @param condition defines the trigger related conditions
  70907. */
  70908. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70909. /** @hidden */
  70910. _prepare(): void;
  70911. /**
  70912. * Execute the action and set the targetted property to the desired value.
  70913. */
  70914. execute(): void;
  70915. /**
  70916. * Serializes the actions and its related information.
  70917. * @param parent defines the object to serialize in
  70918. * @returns the serialized object
  70919. */
  70920. serialize(parent: any): any;
  70921. }
  70922. /**
  70923. * This defines an action responsible to increment the target value
  70924. * to a desired value once triggered.
  70925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70926. */
  70927. export class IncrementValueAction extends Action {
  70928. /**
  70929. * The path of the property to increment in the target.
  70930. */
  70931. propertyPath: string;
  70932. /**
  70933. * The value we should increment the property by.
  70934. */
  70935. value: any;
  70936. private _target;
  70937. private _effectiveTarget;
  70938. private _property;
  70939. /**
  70940. * Instantiate the action
  70941. * @param triggerOptions defines the trigger options
  70942. * @param target defines the object containing the property
  70943. * @param propertyPath defines the path of the property to increment in the target
  70944. * @param value defines the value value we should increment the property by
  70945. * @param condition defines the trigger related conditions
  70946. */
  70947. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70948. /** @hidden */
  70949. _prepare(): void;
  70950. /**
  70951. * Execute the action and increment the target of the value amount.
  70952. */
  70953. execute(): void;
  70954. /**
  70955. * Serializes the actions and its related information.
  70956. * @param parent defines the object to serialize in
  70957. * @returns the serialized object
  70958. */
  70959. serialize(parent: any): any;
  70960. }
  70961. /**
  70962. * This defines an action responsible to start an animation once triggered.
  70963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70964. */
  70965. export class PlayAnimationAction extends Action {
  70966. /**
  70967. * Where the animation should start (animation frame)
  70968. */
  70969. from: number;
  70970. /**
  70971. * Where the animation should stop (animation frame)
  70972. */
  70973. to: number;
  70974. /**
  70975. * Define if the animation should loop or stop after the first play.
  70976. */
  70977. loop?: boolean;
  70978. private _target;
  70979. /**
  70980. * Instantiate the action
  70981. * @param triggerOptions defines the trigger options
  70982. * @param target defines the target animation or animation name
  70983. * @param from defines from where the animation should start (animation frame)
  70984. * @param end defines where the animation should stop (animation frame)
  70985. * @param loop defines if the animation should loop or stop after the first play
  70986. * @param condition defines the trigger related conditions
  70987. */
  70988. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70989. /** @hidden */
  70990. _prepare(): void;
  70991. /**
  70992. * Execute the action and play the animation.
  70993. */
  70994. execute(): void;
  70995. /**
  70996. * Serializes the actions and its related information.
  70997. * @param parent defines the object to serialize in
  70998. * @returns the serialized object
  70999. */
  71000. serialize(parent: any): any;
  71001. }
  71002. /**
  71003. * This defines an action responsible to stop an animation once triggered.
  71004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71005. */
  71006. export class StopAnimationAction extends Action {
  71007. private _target;
  71008. /**
  71009. * Instantiate the action
  71010. * @param triggerOptions defines the trigger options
  71011. * @param target defines the target animation or animation name
  71012. * @param condition defines the trigger related conditions
  71013. */
  71014. constructor(triggerOptions: any, target: any, condition?: Condition);
  71015. /** @hidden */
  71016. _prepare(): void;
  71017. /**
  71018. * Execute the action and stop the animation.
  71019. */
  71020. execute(): void;
  71021. /**
  71022. * Serializes the actions and its related information.
  71023. * @param parent defines the object to serialize in
  71024. * @returns the serialized object
  71025. */
  71026. serialize(parent: any): any;
  71027. }
  71028. /**
  71029. * This defines an action responsible that does nothing once triggered.
  71030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71031. */
  71032. export class DoNothingAction extends Action {
  71033. /**
  71034. * Instantiate the action
  71035. * @param triggerOptions defines the trigger options
  71036. * @param condition defines the trigger related conditions
  71037. */
  71038. constructor(triggerOptions?: any, condition?: Condition);
  71039. /**
  71040. * Execute the action and do nothing.
  71041. */
  71042. execute(): void;
  71043. /**
  71044. * Serializes the actions and its related information.
  71045. * @param parent defines the object to serialize in
  71046. * @returns the serialized object
  71047. */
  71048. serialize(parent: any): any;
  71049. }
  71050. /**
  71051. * This defines an action responsible to trigger several actions once triggered.
  71052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71053. */
  71054. export class CombineAction extends Action {
  71055. /**
  71056. * The list of aggregated animations to run.
  71057. */
  71058. children: Action[];
  71059. /**
  71060. * Instantiate the action
  71061. * @param triggerOptions defines the trigger options
  71062. * @param children defines the list of aggregated animations to run
  71063. * @param condition defines the trigger related conditions
  71064. */
  71065. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71066. /** @hidden */
  71067. _prepare(): void;
  71068. /**
  71069. * Execute the action and executes all the aggregated actions.
  71070. */
  71071. execute(evt: ActionEvent): void;
  71072. /**
  71073. * Serializes the actions and its related information.
  71074. * @param parent defines the object to serialize in
  71075. * @returns the serialized object
  71076. */
  71077. serialize(parent: any): any;
  71078. }
  71079. /**
  71080. * This defines an action responsible to run code (external event) once triggered.
  71081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71082. */
  71083. export class ExecuteCodeAction extends Action {
  71084. /**
  71085. * The callback function to run.
  71086. */
  71087. func: (evt: ActionEvent) => void;
  71088. /**
  71089. * Instantiate the action
  71090. * @param triggerOptions defines the trigger options
  71091. * @param func defines the callback function to run
  71092. * @param condition defines the trigger related conditions
  71093. */
  71094. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71095. /**
  71096. * Execute the action and run the attached code.
  71097. */
  71098. execute(evt: ActionEvent): void;
  71099. }
  71100. /**
  71101. * This defines an action responsible to set the parent property of the target once triggered.
  71102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71103. */
  71104. export class SetParentAction extends Action {
  71105. private _parent;
  71106. private _target;
  71107. /**
  71108. * Instantiate the action
  71109. * @param triggerOptions defines the trigger options
  71110. * @param target defines the target containing the parent property
  71111. * @param parent defines from where the animation should start (animation frame)
  71112. * @param condition defines the trigger related conditions
  71113. */
  71114. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71115. /** @hidden */
  71116. _prepare(): void;
  71117. /**
  71118. * Execute the action and set the parent property.
  71119. */
  71120. execute(): void;
  71121. /**
  71122. * Serializes the actions and its related information.
  71123. * @param parent defines the object to serialize in
  71124. * @returns the serialized object
  71125. */
  71126. serialize(parent: any): any;
  71127. }
  71128. }
  71129. declare module BABYLON {
  71130. /**
  71131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71134. */
  71135. export class ActionManager extends AbstractActionManager {
  71136. /**
  71137. * Nothing
  71138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71139. */
  71140. static readonly NothingTrigger: number;
  71141. /**
  71142. * On pick
  71143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71144. */
  71145. static readonly OnPickTrigger: number;
  71146. /**
  71147. * On left pick
  71148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71149. */
  71150. static readonly OnLeftPickTrigger: number;
  71151. /**
  71152. * On right pick
  71153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71154. */
  71155. static readonly OnRightPickTrigger: number;
  71156. /**
  71157. * On center pick
  71158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71159. */
  71160. static readonly OnCenterPickTrigger: number;
  71161. /**
  71162. * On pick down
  71163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71164. */
  71165. static readonly OnPickDownTrigger: number;
  71166. /**
  71167. * On double pick
  71168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71169. */
  71170. static readonly OnDoublePickTrigger: number;
  71171. /**
  71172. * On pick up
  71173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71174. */
  71175. static readonly OnPickUpTrigger: number;
  71176. /**
  71177. * On pick out.
  71178. * This trigger will only be raised if you also declared a OnPickDown
  71179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71180. */
  71181. static readonly OnPickOutTrigger: number;
  71182. /**
  71183. * On long press
  71184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71185. */
  71186. static readonly OnLongPressTrigger: number;
  71187. /**
  71188. * On pointer over
  71189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71190. */
  71191. static readonly OnPointerOverTrigger: number;
  71192. /**
  71193. * On pointer out
  71194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71195. */
  71196. static readonly OnPointerOutTrigger: number;
  71197. /**
  71198. * On every frame
  71199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71200. */
  71201. static readonly OnEveryFrameTrigger: number;
  71202. /**
  71203. * On intersection enter
  71204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71205. */
  71206. static readonly OnIntersectionEnterTrigger: number;
  71207. /**
  71208. * On intersection exit
  71209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71210. */
  71211. static readonly OnIntersectionExitTrigger: number;
  71212. /**
  71213. * On key down
  71214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71215. */
  71216. static readonly OnKeyDownTrigger: number;
  71217. /**
  71218. * On key up
  71219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71220. */
  71221. static readonly OnKeyUpTrigger: number;
  71222. private _scene;
  71223. /**
  71224. * Creates a new action manager
  71225. * @param scene defines the hosting scene
  71226. */
  71227. constructor(scene: Scene);
  71228. /**
  71229. * Releases all associated resources
  71230. */
  71231. dispose(): void;
  71232. /**
  71233. * Gets hosting scene
  71234. * @returns the hosting scene
  71235. */
  71236. getScene(): Scene;
  71237. /**
  71238. * Does this action manager handles actions of any of the given triggers
  71239. * @param triggers defines the triggers to be tested
  71240. * @return a boolean indicating whether one (or more) of the triggers is handled
  71241. */
  71242. hasSpecificTriggers(triggers: number[]): boolean;
  71243. /**
  71244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71245. * speed.
  71246. * @param triggerA defines the trigger to be tested
  71247. * @param triggerB defines the trigger to be tested
  71248. * @return a boolean indicating whether one (or more) of the triggers is handled
  71249. */
  71250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71251. /**
  71252. * Does this action manager handles actions of a given trigger
  71253. * @param trigger defines the trigger to be tested
  71254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71255. * @return whether the trigger is handled
  71256. */
  71257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71258. /**
  71259. * Does this action manager has pointer triggers
  71260. */
  71261. readonly hasPointerTriggers: boolean;
  71262. /**
  71263. * Does this action manager has pick triggers
  71264. */
  71265. readonly hasPickTriggers: boolean;
  71266. /**
  71267. * Registers an action to this action manager
  71268. * @param action defines the action to be registered
  71269. * @return the action amended (prepared) after registration
  71270. */
  71271. registerAction(action: IAction): Nullable<IAction>;
  71272. /**
  71273. * Unregisters an action to this action manager
  71274. * @param action defines the action to be unregistered
  71275. * @return a boolean indicating whether the action has been unregistered
  71276. */
  71277. unregisterAction(action: IAction): Boolean;
  71278. /**
  71279. * Process a specific trigger
  71280. * @param trigger defines the trigger to process
  71281. * @param evt defines the event details to be processed
  71282. */
  71283. processTrigger(trigger: number, evt?: IActionEvent): void;
  71284. /** @hidden */
  71285. _getEffectiveTarget(target: any, propertyPath: string): any;
  71286. /** @hidden */
  71287. _getProperty(propertyPath: string): string;
  71288. /**
  71289. * Serialize this manager to a JSON object
  71290. * @param name defines the property name to store this manager
  71291. * @returns a JSON representation of this manager
  71292. */
  71293. serialize(name: string): any;
  71294. /**
  71295. * Creates a new ActionManager from a JSON data
  71296. * @param parsedActions defines the JSON data to read from
  71297. * @param object defines the hosting mesh
  71298. * @param scene defines the hosting scene
  71299. */
  71300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71301. /**
  71302. * Get a trigger name by index
  71303. * @param trigger defines the trigger index
  71304. * @returns a trigger name
  71305. */
  71306. static GetTriggerName(trigger: number): string;
  71307. }
  71308. }
  71309. declare module BABYLON {
  71310. /**
  71311. * Class representing a ray with position and direction
  71312. */
  71313. export class Ray {
  71314. /** origin point */
  71315. origin: Vector3;
  71316. /** direction */
  71317. direction: Vector3;
  71318. /** length of the ray */
  71319. length: number;
  71320. private static readonly TmpVector3;
  71321. private _tmpRay;
  71322. /**
  71323. * Creates a new ray
  71324. * @param origin origin point
  71325. * @param direction direction
  71326. * @param length length of the ray
  71327. */
  71328. constructor(
  71329. /** origin point */
  71330. origin: Vector3,
  71331. /** direction */
  71332. direction: Vector3,
  71333. /** length of the ray */
  71334. length?: number);
  71335. /**
  71336. * Checks if the ray intersects a box
  71337. * @param minimum bound of the box
  71338. * @param maximum bound of the box
  71339. * @param intersectionTreshold extra extend to be added to the box in all direction
  71340. * @returns if the box was hit
  71341. */
  71342. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71343. /**
  71344. * Checks if the ray intersects a box
  71345. * @param box the bounding box to check
  71346. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71347. * @returns if the box was hit
  71348. */
  71349. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71350. /**
  71351. * If the ray hits a sphere
  71352. * @param sphere the bounding sphere to check
  71353. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71354. * @returns true if it hits the sphere
  71355. */
  71356. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71357. /**
  71358. * If the ray hits a triange
  71359. * @param vertex0 triangle vertex
  71360. * @param vertex1 triangle vertex
  71361. * @param vertex2 triangle vertex
  71362. * @returns intersection information if hit
  71363. */
  71364. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71365. /**
  71366. * Checks if ray intersects a plane
  71367. * @param plane the plane to check
  71368. * @returns the distance away it was hit
  71369. */
  71370. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71371. /**
  71372. * Checks if ray intersects a mesh
  71373. * @param mesh the mesh to check
  71374. * @param fastCheck if only the bounding box should checked
  71375. * @returns picking info of the intersecton
  71376. */
  71377. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71378. /**
  71379. * Checks if ray intersects a mesh
  71380. * @param meshes the meshes to check
  71381. * @param fastCheck if only the bounding box should checked
  71382. * @param results array to store result in
  71383. * @returns Array of picking infos
  71384. */
  71385. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71386. private _comparePickingInfo;
  71387. private static smallnum;
  71388. private static rayl;
  71389. /**
  71390. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71391. * @param sega the first point of the segment to test the intersection against
  71392. * @param segb the second point of the segment to test the intersection against
  71393. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71394. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71395. */
  71396. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71397. /**
  71398. * Update the ray from viewport position
  71399. * @param x position
  71400. * @param y y position
  71401. * @param viewportWidth viewport width
  71402. * @param viewportHeight viewport height
  71403. * @param world world matrix
  71404. * @param view view matrix
  71405. * @param projection projection matrix
  71406. * @returns this ray updated
  71407. */
  71408. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71409. /**
  71410. * Creates a ray with origin and direction of 0,0,0
  71411. * @returns the new ray
  71412. */
  71413. static Zero(): Ray;
  71414. /**
  71415. * Creates a new ray from screen space and viewport
  71416. * @param x position
  71417. * @param y y position
  71418. * @param viewportWidth viewport width
  71419. * @param viewportHeight viewport height
  71420. * @param world world matrix
  71421. * @param view view matrix
  71422. * @param projection projection matrix
  71423. * @returns new ray
  71424. */
  71425. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71426. /**
  71427. * 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
  71428. * transformed to the given world matrix.
  71429. * @param origin The origin point
  71430. * @param end The end point
  71431. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71432. * @returns the new ray
  71433. */
  71434. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71435. /**
  71436. * Transforms a ray by a matrix
  71437. * @param ray ray to transform
  71438. * @param matrix matrix to apply
  71439. * @returns the resulting new ray
  71440. */
  71441. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71442. /**
  71443. * Transforms a ray by a matrix
  71444. * @param ray ray to transform
  71445. * @param matrix matrix to apply
  71446. * @param result ray to store result in
  71447. */
  71448. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71449. /**
  71450. * Unproject a ray from screen space to object space
  71451. * @param sourceX defines the screen space x coordinate to use
  71452. * @param sourceY defines the screen space y coordinate to use
  71453. * @param viewportWidth defines the current width of the viewport
  71454. * @param viewportHeight defines the current height of the viewport
  71455. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71456. * @param view defines the view matrix to use
  71457. * @param projection defines the projection matrix to use
  71458. */
  71459. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71460. }
  71461. /**
  71462. * Type used to define predicate used to select faces when a mesh intersection is detected
  71463. */
  71464. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71465. interface Scene {
  71466. /** @hidden */
  71467. _tempPickingRay: Nullable<Ray>;
  71468. /** @hidden */
  71469. _cachedRayForTransform: Ray;
  71470. /** @hidden */
  71471. _pickWithRayInverseMatrix: Matrix;
  71472. /** @hidden */
  71473. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71474. /** @hidden */
  71475. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71476. }
  71477. }
  71478. declare module BABYLON {
  71479. /**
  71480. * Groups all the scene component constants in one place to ease maintenance.
  71481. * @hidden
  71482. */
  71483. export class SceneComponentConstants {
  71484. static readonly NAME_EFFECTLAYER: string;
  71485. static readonly NAME_LAYER: string;
  71486. static readonly NAME_LENSFLARESYSTEM: string;
  71487. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71488. static readonly NAME_PARTICLESYSTEM: string;
  71489. static readonly NAME_GAMEPAD: string;
  71490. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71491. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71492. static readonly NAME_DEPTHRENDERER: string;
  71493. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71494. static readonly NAME_SPRITE: string;
  71495. static readonly NAME_OUTLINERENDERER: string;
  71496. static readonly NAME_PROCEDURALTEXTURE: string;
  71497. static readonly NAME_SHADOWGENERATOR: string;
  71498. static readonly NAME_OCTREE: string;
  71499. static readonly NAME_PHYSICSENGINE: string;
  71500. static readonly NAME_AUDIO: string;
  71501. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71502. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71503. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71504. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71505. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71506. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71507. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71508. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71509. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71510. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71511. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71512. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71513. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71514. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71515. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71516. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71517. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71518. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71520. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71521. static readonly STEP_AFTERRENDER_AUDIO: number;
  71522. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71523. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71524. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71525. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71526. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71527. static readonly STEP_POINTERMOVE_SPRITE: number;
  71528. static readonly STEP_POINTERDOWN_SPRITE: number;
  71529. static readonly STEP_POINTERUP_SPRITE: number;
  71530. }
  71531. /**
  71532. * This represents a scene component.
  71533. *
  71534. * This is used to decouple the dependency the scene is having on the different workloads like
  71535. * layers, post processes...
  71536. */
  71537. export interface ISceneComponent {
  71538. /**
  71539. * The name of the component. Each component must have a unique name.
  71540. */
  71541. name: string;
  71542. /**
  71543. * The scene the component belongs to.
  71544. */
  71545. scene: Scene;
  71546. /**
  71547. * Register the component to one instance of a scene.
  71548. */
  71549. register(): void;
  71550. /**
  71551. * Rebuilds the elements related to this component in case of
  71552. * context lost for instance.
  71553. */
  71554. rebuild(): void;
  71555. /**
  71556. * Disposes the component and the associated ressources.
  71557. */
  71558. dispose(): void;
  71559. }
  71560. /**
  71561. * This represents a SERIALIZABLE scene component.
  71562. *
  71563. * This extends Scene Component to add Serialization methods on top.
  71564. */
  71565. export interface ISceneSerializableComponent extends ISceneComponent {
  71566. /**
  71567. * Adds all the element from the container to the scene
  71568. * @param container the container holding the elements
  71569. */
  71570. addFromContainer(container: AbstractScene): void;
  71571. /**
  71572. * Removes all the elements in the container from the scene
  71573. * @param container contains the elements to remove
  71574. * @param dispose if the removed element should be disposed (default: false)
  71575. */
  71576. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71577. /**
  71578. * Serializes the component data to the specified json object
  71579. * @param serializationObject The object to serialize to
  71580. */
  71581. serialize(serializationObject: any): void;
  71582. }
  71583. /**
  71584. * Strong typing of a Mesh related stage step action
  71585. */
  71586. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71587. /**
  71588. * Strong typing of a Evaluate Sub Mesh related stage step action
  71589. */
  71590. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71591. /**
  71592. * Strong typing of a Active Mesh related stage step action
  71593. */
  71594. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71595. /**
  71596. * Strong typing of a Camera related stage step action
  71597. */
  71598. export type CameraStageAction = (camera: Camera) => void;
  71599. /**
  71600. * Strong typing of a Camera Frame buffer related stage step action
  71601. */
  71602. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71603. /**
  71604. * Strong typing of a Render Target related stage step action
  71605. */
  71606. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71607. /**
  71608. * Strong typing of a RenderingGroup related stage step action
  71609. */
  71610. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71611. /**
  71612. * Strong typing of a Mesh Render related stage step action
  71613. */
  71614. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71615. /**
  71616. * Strong typing of a simple stage step action
  71617. */
  71618. export type SimpleStageAction = () => void;
  71619. /**
  71620. * Strong typing of a render target action.
  71621. */
  71622. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71623. /**
  71624. * Strong typing of a pointer move action.
  71625. */
  71626. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71627. /**
  71628. * Strong typing of a pointer up/down action.
  71629. */
  71630. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71631. /**
  71632. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71633. * @hidden
  71634. */
  71635. export class Stage<T extends Function> extends Array<{
  71636. index: number;
  71637. component: ISceneComponent;
  71638. action: T;
  71639. }> {
  71640. /**
  71641. * Hide ctor from the rest of the world.
  71642. * @param items The items to add.
  71643. */
  71644. private constructor();
  71645. /**
  71646. * Creates a new Stage.
  71647. * @returns A new instance of a Stage
  71648. */
  71649. static Create<T extends Function>(): Stage<T>;
  71650. /**
  71651. * Registers a step in an ordered way in the targeted stage.
  71652. * @param index Defines the position to register the step in
  71653. * @param component Defines the component attached to the step
  71654. * @param action Defines the action to launch during the step
  71655. */
  71656. registerStep(index: number, component: ISceneComponent, action: T): void;
  71657. /**
  71658. * Clears all the steps from the stage.
  71659. */
  71660. clear(): void;
  71661. }
  71662. }
  71663. declare module BABYLON {
  71664. interface Scene {
  71665. /** @hidden */
  71666. _pointerOverSprite: Nullable<Sprite>;
  71667. /** @hidden */
  71668. _pickedDownSprite: Nullable<Sprite>;
  71669. /** @hidden */
  71670. _tempSpritePickingRay: Nullable<Ray>;
  71671. /**
  71672. * All of the sprite managers added to this scene
  71673. * @see http://doc.babylonjs.com/babylon101/sprites
  71674. */
  71675. spriteManagers: Array<ISpriteManager>;
  71676. /**
  71677. * An event triggered when sprites rendering is about to start
  71678. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71679. */
  71680. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71681. /**
  71682. * An event triggered when sprites rendering is done
  71683. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71684. */
  71685. onAfterSpritesRenderingObservable: Observable<Scene>;
  71686. /** @hidden */
  71687. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71688. /** Launch a ray to try to pick a sprite in the scene
  71689. * @param x position on screen
  71690. * @param y position on screen
  71691. * @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
  71692. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71693. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71694. * @returns a PickingInfo
  71695. */
  71696. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71697. /** Use the given ray to pick a sprite in the scene
  71698. * @param ray The ray (in world space) to use to pick meshes
  71699. * @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
  71700. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71701. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71702. * @returns a PickingInfo
  71703. */
  71704. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71705. /**
  71706. * Force the sprite under the pointer
  71707. * @param sprite defines the sprite to use
  71708. */
  71709. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71710. /**
  71711. * Gets the sprite under the pointer
  71712. * @returns a Sprite or null if no sprite is under the pointer
  71713. */
  71714. getPointerOverSprite(): Nullable<Sprite>;
  71715. }
  71716. /**
  71717. * Defines the sprite scene component responsible to manage sprites
  71718. * in a given scene.
  71719. */
  71720. export class SpriteSceneComponent implements ISceneComponent {
  71721. /**
  71722. * The component name helpfull to identify the component in the list of scene components.
  71723. */
  71724. readonly name: string;
  71725. /**
  71726. * The scene the component belongs to.
  71727. */
  71728. scene: Scene;
  71729. /** @hidden */
  71730. private _spritePredicate;
  71731. /**
  71732. * Creates a new instance of the component for the given scene
  71733. * @param scene Defines the scene to register the component in
  71734. */
  71735. constructor(scene: Scene);
  71736. /**
  71737. * Registers the component in a given scene
  71738. */
  71739. register(): void;
  71740. /**
  71741. * Rebuilds the elements related to this component in case of
  71742. * context lost for instance.
  71743. */
  71744. rebuild(): void;
  71745. /**
  71746. * Disposes the component and the associated ressources.
  71747. */
  71748. dispose(): void;
  71749. private _pickSpriteButKeepRay;
  71750. private _pointerMove;
  71751. private _pointerDown;
  71752. private _pointerUp;
  71753. }
  71754. }
  71755. declare module BABYLON {
  71756. /** @hidden */
  71757. export var fogFragmentDeclaration: {
  71758. name: string;
  71759. shader: string;
  71760. };
  71761. }
  71762. declare module BABYLON {
  71763. /** @hidden */
  71764. export var fogFragment: {
  71765. name: string;
  71766. shader: string;
  71767. };
  71768. }
  71769. declare module BABYLON {
  71770. /** @hidden */
  71771. export var spritesPixelShader: {
  71772. name: string;
  71773. shader: string;
  71774. };
  71775. }
  71776. declare module BABYLON {
  71777. /** @hidden */
  71778. export var fogVertexDeclaration: {
  71779. name: string;
  71780. shader: string;
  71781. };
  71782. }
  71783. declare module BABYLON {
  71784. /** @hidden */
  71785. export var spritesVertexShader: {
  71786. name: string;
  71787. shader: string;
  71788. };
  71789. }
  71790. declare module BABYLON {
  71791. /**
  71792. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71793. */
  71794. export interface ISpriteManager extends IDisposable {
  71795. /**
  71796. * Restricts the camera to viewing objects with the same layerMask.
  71797. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71798. */
  71799. layerMask: number;
  71800. /**
  71801. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71802. */
  71803. isPickable: boolean;
  71804. /**
  71805. * Specifies the rendering group id for this mesh (0 by default)
  71806. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71807. */
  71808. renderingGroupId: number;
  71809. /**
  71810. * Defines the list of sprites managed by the manager.
  71811. */
  71812. sprites: Array<Sprite>;
  71813. /**
  71814. * Tests the intersection of a sprite with a specific ray.
  71815. * @param ray The ray we are sending to test the collision
  71816. * @param camera The camera space we are sending rays in
  71817. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71818. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71819. * @returns picking info or null.
  71820. */
  71821. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71822. /**
  71823. * Renders the list of sprites on screen.
  71824. */
  71825. render(): void;
  71826. }
  71827. /**
  71828. * Class used to manage multiple sprites on the same spritesheet
  71829. * @see http://doc.babylonjs.com/babylon101/sprites
  71830. */
  71831. export class SpriteManager implements ISpriteManager {
  71832. /** defines the manager's name */
  71833. name: string;
  71834. /** Gets the list of sprites */
  71835. sprites: Sprite[];
  71836. /** Gets or sets the rendering group id (0 by default) */
  71837. renderingGroupId: number;
  71838. /** Gets or sets camera layer mask */
  71839. layerMask: number;
  71840. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71841. fogEnabled: boolean;
  71842. /** Gets or sets a boolean indicating if the sprites are pickable */
  71843. isPickable: boolean;
  71844. /** Defines the default width of a cell in the spritesheet */
  71845. cellWidth: number;
  71846. /** Defines the default height of a cell in the spritesheet */
  71847. cellHeight: number;
  71848. /**
  71849. * An event triggered when the manager is disposed.
  71850. */
  71851. onDisposeObservable: Observable<SpriteManager>;
  71852. private _onDisposeObserver;
  71853. /**
  71854. * Callback called when the manager is disposed
  71855. */
  71856. onDispose: () => void;
  71857. private _capacity;
  71858. private _spriteTexture;
  71859. private _epsilon;
  71860. private _scene;
  71861. private _vertexData;
  71862. private _buffer;
  71863. private _vertexBuffers;
  71864. private _indexBuffer;
  71865. private _effectBase;
  71866. private _effectFog;
  71867. /**
  71868. * Gets or sets the spritesheet texture
  71869. */
  71870. texture: Texture;
  71871. /**
  71872. * Creates a new sprite manager
  71873. * @param name defines the manager's name
  71874. * @param imgUrl defines the sprite sheet url
  71875. * @param capacity defines the maximum allowed number of sprites
  71876. * @param cellSize defines the size of a sprite cell
  71877. * @param scene defines the hosting scene
  71878. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71879. * @param samplingMode defines the smapling mode to use with spritesheet
  71880. */
  71881. constructor(
  71882. /** defines the manager's name */
  71883. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71884. private _appendSpriteVertex;
  71885. /**
  71886. * Intersects the sprites with a ray
  71887. * @param ray defines the ray to intersect with
  71888. * @param camera defines the current active camera
  71889. * @param predicate defines a predicate used to select candidate sprites
  71890. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71891. * @returns null if no hit or a PickingInfo
  71892. */
  71893. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71894. /**
  71895. * Render all child sprites
  71896. */
  71897. render(): void;
  71898. /**
  71899. * Release associated resources
  71900. */
  71901. dispose(): void;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /**
  71906. * Class used to represent a sprite
  71907. * @see http://doc.babylonjs.com/babylon101/sprites
  71908. */
  71909. export class Sprite {
  71910. /** defines the name */
  71911. name: string;
  71912. /** Gets or sets the current world position */
  71913. position: Vector3;
  71914. /** Gets or sets the main color */
  71915. color: Color4;
  71916. /** Gets or sets the width */
  71917. width: number;
  71918. /** Gets or sets the height */
  71919. height: number;
  71920. /** Gets or sets rotation angle */
  71921. angle: number;
  71922. /** Gets or sets the cell index in the sprite sheet */
  71923. cellIndex: number;
  71924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71925. invertU: number;
  71926. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71927. invertV: number;
  71928. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71929. disposeWhenFinishedAnimating: boolean;
  71930. /** Gets the list of attached animations */
  71931. animations: Animation[];
  71932. /** Gets or sets a boolean indicating if the sprite can be picked */
  71933. isPickable: boolean;
  71934. /**
  71935. * Gets or sets the associated action manager
  71936. */
  71937. actionManager: Nullable<ActionManager>;
  71938. private _animationStarted;
  71939. private _loopAnimation;
  71940. private _fromIndex;
  71941. private _toIndex;
  71942. private _delay;
  71943. private _direction;
  71944. private _manager;
  71945. private _time;
  71946. private _onAnimationEnd;
  71947. /**
  71948. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71949. */
  71950. isVisible: boolean;
  71951. /**
  71952. * Gets or sets the sprite size
  71953. */
  71954. size: number;
  71955. /**
  71956. * Creates a new Sprite
  71957. * @param name defines the name
  71958. * @param manager defines the manager
  71959. */
  71960. constructor(
  71961. /** defines the name */
  71962. name: string, manager: ISpriteManager);
  71963. /**
  71964. * Starts an animation
  71965. * @param from defines the initial key
  71966. * @param to defines the end key
  71967. * @param loop defines if the animation must loop
  71968. * @param delay defines the start delay (in ms)
  71969. * @param onAnimationEnd defines a callback to call when animation ends
  71970. */
  71971. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71972. /** Stops current animation (if any) */
  71973. stopAnimation(): void;
  71974. /** @hidden */
  71975. _animate(deltaTime: number): void;
  71976. /** Release associated resources */
  71977. dispose(): void;
  71978. }
  71979. }
  71980. declare module BABYLON {
  71981. /**
  71982. * Information about the result of picking within a scene
  71983. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71984. */
  71985. export class PickingInfo {
  71986. /** @hidden */
  71987. _pickingUnavailable: boolean;
  71988. /**
  71989. * If the pick collided with an object
  71990. */
  71991. hit: boolean;
  71992. /**
  71993. * Distance away where the pick collided
  71994. */
  71995. distance: number;
  71996. /**
  71997. * The location of pick collision
  71998. */
  71999. pickedPoint: Nullable<Vector3>;
  72000. /**
  72001. * The mesh corresponding the the pick collision
  72002. */
  72003. pickedMesh: Nullable<AbstractMesh>;
  72004. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72005. bu: number;
  72006. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72007. bv: number;
  72008. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72009. faceId: number;
  72010. /** Id of the the submesh that was picked */
  72011. subMeshId: number;
  72012. /** If a sprite was picked, this will be the sprite the pick collided with */
  72013. pickedSprite: Nullable<Sprite>;
  72014. /**
  72015. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72016. */
  72017. originMesh: Nullable<AbstractMesh>;
  72018. /**
  72019. * The ray that was used to perform the picking.
  72020. */
  72021. ray: Nullable<Ray>;
  72022. /**
  72023. * Gets the normal correspodning to the face the pick collided with
  72024. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72025. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72026. * @returns The normal correspodning to the face the pick collided with
  72027. */
  72028. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72029. /**
  72030. * Gets the texture coordinates of where the pick occured
  72031. * @returns the vector containing the coordnates of the texture
  72032. */
  72033. getTextureCoordinates(): Nullable<Vector2>;
  72034. }
  72035. }
  72036. declare module BABYLON {
  72037. /**
  72038. * Gather the list of pointer event types as constants.
  72039. */
  72040. export class PointerEventTypes {
  72041. /**
  72042. * 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.
  72043. */
  72044. static readonly POINTERDOWN: number;
  72045. /**
  72046. * The pointerup event is fired when a pointer is no longer active.
  72047. */
  72048. static readonly POINTERUP: number;
  72049. /**
  72050. * The pointermove event is fired when a pointer changes coordinates.
  72051. */
  72052. static readonly POINTERMOVE: number;
  72053. /**
  72054. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72055. */
  72056. static readonly POINTERWHEEL: number;
  72057. /**
  72058. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72059. */
  72060. static readonly POINTERPICK: number;
  72061. /**
  72062. * The pointertap event is fired when a the object has been touched and released without drag.
  72063. */
  72064. static readonly POINTERTAP: number;
  72065. /**
  72066. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72067. */
  72068. static readonly POINTERDOUBLETAP: number;
  72069. }
  72070. /**
  72071. * Base class of pointer info types.
  72072. */
  72073. export class PointerInfoBase {
  72074. /**
  72075. * Defines the type of event (PointerEventTypes)
  72076. */
  72077. type: number;
  72078. /**
  72079. * Defines the related dom event
  72080. */
  72081. event: PointerEvent | MouseWheelEvent;
  72082. /**
  72083. * Instantiates the base class of pointers info.
  72084. * @param type Defines the type of event (PointerEventTypes)
  72085. * @param event Defines the related dom event
  72086. */
  72087. constructor(
  72088. /**
  72089. * Defines the type of event (PointerEventTypes)
  72090. */
  72091. type: number,
  72092. /**
  72093. * Defines the related dom event
  72094. */
  72095. event: PointerEvent | MouseWheelEvent);
  72096. }
  72097. /**
  72098. * This class is used to store pointer related info for the onPrePointerObservable event.
  72099. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72100. */
  72101. export class PointerInfoPre extends PointerInfoBase {
  72102. /**
  72103. * Ray from a pointer if availible (eg. 6dof controller)
  72104. */
  72105. ray: Nullable<Ray>;
  72106. /**
  72107. * Defines the local position of the pointer on the canvas.
  72108. */
  72109. localPosition: Vector2;
  72110. /**
  72111. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72112. */
  72113. skipOnPointerObservable: boolean;
  72114. /**
  72115. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72116. * @param type Defines the type of event (PointerEventTypes)
  72117. * @param event Defines the related dom event
  72118. * @param localX Defines the local x coordinates of the pointer when the event occured
  72119. * @param localY Defines the local y coordinates of the pointer when the event occured
  72120. */
  72121. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72122. }
  72123. /**
  72124. * This type contains all the data related to a pointer event in Babylon.js.
  72125. * 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.
  72126. */
  72127. export class PointerInfo extends PointerInfoBase {
  72128. /**
  72129. * Defines the picking info associated to the info (if any)\
  72130. */
  72131. pickInfo: Nullable<PickingInfo>;
  72132. /**
  72133. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72134. * @param type Defines the type of event (PointerEventTypes)
  72135. * @param event Defines the related dom event
  72136. * @param pickInfo Defines the picking info associated to the info (if any)\
  72137. */
  72138. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72139. /**
  72140. * Defines the picking info associated to the info (if any)\
  72141. */
  72142. pickInfo: Nullable<PickingInfo>);
  72143. }
  72144. /**
  72145. * Data relating to a touch event on the screen.
  72146. */
  72147. export interface PointerTouch {
  72148. /**
  72149. * X coordinate of touch.
  72150. */
  72151. x: number;
  72152. /**
  72153. * Y coordinate of touch.
  72154. */
  72155. y: number;
  72156. /**
  72157. * Id of touch. Unique for each finger.
  72158. */
  72159. pointerId: number;
  72160. /**
  72161. * Event type passed from DOM.
  72162. */
  72163. type: any;
  72164. }
  72165. }
  72166. declare module BABYLON {
  72167. /**
  72168. * Manage the mouse inputs to control the movement of a free camera.
  72169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72170. */
  72171. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72172. /**
  72173. * Define if touch is enabled in the mouse input
  72174. */
  72175. touchEnabled: boolean;
  72176. /**
  72177. * Defines the camera the input is attached to.
  72178. */
  72179. camera: FreeCamera;
  72180. /**
  72181. * Defines the buttons associated with the input to handle camera move.
  72182. */
  72183. buttons: number[];
  72184. /**
  72185. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72186. */
  72187. angularSensibility: number;
  72188. private _pointerInput;
  72189. private _onMouseMove;
  72190. private _observer;
  72191. private previousPosition;
  72192. /**
  72193. * Observable for when a pointer move event occurs containing the move offset
  72194. */
  72195. onPointerMovedObservable: Observable<{
  72196. offsetX: number;
  72197. offsetY: number;
  72198. }>;
  72199. /**
  72200. * @hidden
  72201. * If the camera should be rotated automatically based on pointer movement
  72202. */
  72203. _allowCameraRotation: boolean;
  72204. /**
  72205. * Manage the mouse inputs to control the movement of a free camera.
  72206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72207. * @param touchEnabled Defines if touch is enabled or not
  72208. */
  72209. constructor(
  72210. /**
  72211. * Define if touch is enabled in the mouse input
  72212. */
  72213. touchEnabled?: boolean);
  72214. /**
  72215. * Attach the input controls to a specific dom element to get the input from.
  72216. * @param element Defines the element the controls should be listened from
  72217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72218. */
  72219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72220. /**
  72221. * Called on JS contextmenu event.
  72222. * Override this method to provide functionality.
  72223. */
  72224. protected onContextMenu(evt: PointerEvent): void;
  72225. /**
  72226. * Detach the current controls from the specified dom element.
  72227. * @param element Defines the element to stop listening the inputs from
  72228. */
  72229. detachControl(element: Nullable<HTMLElement>): void;
  72230. /**
  72231. * Gets the class name of the current intput.
  72232. * @returns the class name
  72233. */
  72234. getClassName(): string;
  72235. /**
  72236. * Get the friendly name associated with the input class.
  72237. * @returns the input friendly name
  72238. */
  72239. getSimpleName(): string;
  72240. }
  72241. }
  72242. declare module BABYLON {
  72243. /**
  72244. * Manage the touch inputs to control the movement of a free camera.
  72245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72246. */
  72247. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72248. /**
  72249. * Defines the camera the input is attached to.
  72250. */
  72251. camera: FreeCamera;
  72252. /**
  72253. * Defines the touch sensibility for rotation.
  72254. * The higher the faster.
  72255. */
  72256. touchAngularSensibility: number;
  72257. /**
  72258. * Defines the touch sensibility for move.
  72259. * The higher the faster.
  72260. */
  72261. touchMoveSensibility: number;
  72262. private _offsetX;
  72263. private _offsetY;
  72264. private _pointerPressed;
  72265. private _pointerInput;
  72266. private _observer;
  72267. private _onLostFocus;
  72268. /**
  72269. * Attach the input controls to a specific dom element to get the input from.
  72270. * @param element Defines the element the controls should be listened from
  72271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72272. */
  72273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72274. /**
  72275. * Detach the current controls from the specified dom element.
  72276. * @param element Defines the element to stop listening the inputs from
  72277. */
  72278. detachControl(element: Nullable<HTMLElement>): void;
  72279. /**
  72280. * Update the current camera state depending on the inputs that have been used this frame.
  72281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72282. */
  72283. checkInputs(): void;
  72284. /**
  72285. * Gets the class name of the current intput.
  72286. * @returns the class name
  72287. */
  72288. getClassName(): string;
  72289. /**
  72290. * Get the friendly name associated with the input class.
  72291. * @returns the input friendly name
  72292. */
  72293. getSimpleName(): string;
  72294. }
  72295. }
  72296. declare module BABYLON {
  72297. /**
  72298. * Default Inputs manager for the FreeCamera.
  72299. * It groups all the default supported inputs for ease of use.
  72300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72301. */
  72302. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72303. /**
  72304. * @hidden
  72305. */
  72306. _mouseInput: Nullable<FreeCameraMouseInput>;
  72307. /**
  72308. * Instantiates a new FreeCameraInputsManager.
  72309. * @param camera Defines the camera the inputs belong to
  72310. */
  72311. constructor(camera: FreeCamera);
  72312. /**
  72313. * Add keyboard input support to the input manager.
  72314. * @returns the current input manager
  72315. */
  72316. addKeyboard(): FreeCameraInputsManager;
  72317. /**
  72318. * Add mouse input support to the input manager.
  72319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72320. * @returns the current input manager
  72321. */
  72322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72323. /**
  72324. * Removes the mouse input support from the manager
  72325. * @returns the current input manager
  72326. */
  72327. removeMouse(): FreeCameraInputsManager;
  72328. /**
  72329. * Add touch input support to the input manager.
  72330. * @returns the current input manager
  72331. */
  72332. addTouch(): FreeCameraInputsManager;
  72333. /**
  72334. * Remove all attached input methods from a camera
  72335. */
  72336. clear(): void;
  72337. }
  72338. }
  72339. declare module BABYLON {
  72340. /**
  72341. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72342. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72344. */
  72345. export class FreeCamera extends TargetCamera {
  72346. /**
  72347. * Define the collision ellipsoid of the camera.
  72348. * This is helpful to simulate a camera body like the player body around the camera
  72349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72350. */
  72351. ellipsoid: Vector3;
  72352. /**
  72353. * Define an offset for the position of the ellipsoid around the camera.
  72354. * This can be helpful to determine the center of the body near the gravity center of the body
  72355. * instead of its head.
  72356. */
  72357. ellipsoidOffset: Vector3;
  72358. /**
  72359. * Enable or disable collisions of the camera with the rest of the scene objects.
  72360. */
  72361. checkCollisions: boolean;
  72362. /**
  72363. * Enable or disable gravity on the camera.
  72364. */
  72365. applyGravity: boolean;
  72366. /**
  72367. * Define the input manager associated to the camera.
  72368. */
  72369. inputs: FreeCameraInputsManager;
  72370. /**
  72371. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72372. * Higher values reduce sensitivity.
  72373. */
  72374. /**
  72375. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72376. * Higher values reduce sensitivity.
  72377. */
  72378. angularSensibility: number;
  72379. /**
  72380. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72381. */
  72382. keysUp: number[];
  72383. /**
  72384. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72385. */
  72386. keysDown: number[];
  72387. /**
  72388. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72389. */
  72390. keysLeft: number[];
  72391. /**
  72392. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72393. */
  72394. keysRight: number[];
  72395. /**
  72396. * Event raised when the camera collide with a mesh in the scene.
  72397. */
  72398. onCollide: (collidedMesh: AbstractMesh) => void;
  72399. private _collider;
  72400. private _needMoveForGravity;
  72401. private _oldPosition;
  72402. private _diffPosition;
  72403. private _newPosition;
  72404. /** @hidden */
  72405. _localDirection: Vector3;
  72406. /** @hidden */
  72407. _transformedDirection: Vector3;
  72408. /**
  72409. * Instantiates a Free Camera.
  72410. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72411. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72412. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72413. * @param name Define the name of the camera in the scene
  72414. * @param position Define the start position of the camera in the scene
  72415. * @param scene Define the scene the camera belongs to
  72416. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72417. */
  72418. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72419. /**
  72420. * Attached controls to the current camera.
  72421. * @param element Defines the element the controls should be listened from
  72422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72423. */
  72424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72425. /**
  72426. * Detach the current controls from the camera.
  72427. * The camera will stop reacting to inputs.
  72428. * @param element Defines the element to stop listening the inputs from
  72429. */
  72430. detachControl(element: HTMLElement): void;
  72431. private _collisionMask;
  72432. /**
  72433. * Define a collision mask to limit the list of object the camera can collide with
  72434. */
  72435. collisionMask: number;
  72436. /** @hidden */
  72437. _collideWithWorld(displacement: Vector3): void;
  72438. private _onCollisionPositionChange;
  72439. /** @hidden */
  72440. _checkInputs(): void;
  72441. /** @hidden */
  72442. _decideIfNeedsToMove(): boolean;
  72443. /** @hidden */
  72444. _updatePosition(): void;
  72445. /**
  72446. * Destroy the camera and release the current resources hold by it.
  72447. */
  72448. dispose(): void;
  72449. /**
  72450. * Gets the current object class name.
  72451. * @return the class name
  72452. */
  72453. getClassName(): string;
  72454. }
  72455. }
  72456. declare module BABYLON {
  72457. /**
  72458. * Represents a gamepad control stick position
  72459. */
  72460. export class StickValues {
  72461. /**
  72462. * The x component of the control stick
  72463. */
  72464. x: number;
  72465. /**
  72466. * The y component of the control stick
  72467. */
  72468. y: number;
  72469. /**
  72470. * Initializes the gamepad x and y control stick values
  72471. * @param x The x component of the gamepad control stick value
  72472. * @param y The y component of the gamepad control stick value
  72473. */
  72474. constructor(
  72475. /**
  72476. * The x component of the control stick
  72477. */
  72478. x: number,
  72479. /**
  72480. * The y component of the control stick
  72481. */
  72482. y: number);
  72483. }
  72484. /**
  72485. * An interface which manages callbacks for gamepad button changes
  72486. */
  72487. export interface GamepadButtonChanges {
  72488. /**
  72489. * Called when a gamepad has been changed
  72490. */
  72491. changed: boolean;
  72492. /**
  72493. * Called when a gamepad press event has been triggered
  72494. */
  72495. pressChanged: boolean;
  72496. /**
  72497. * Called when a touch event has been triggered
  72498. */
  72499. touchChanged: boolean;
  72500. /**
  72501. * Called when a value has changed
  72502. */
  72503. valueChanged: boolean;
  72504. }
  72505. /**
  72506. * Represents a gamepad
  72507. */
  72508. export class Gamepad {
  72509. /**
  72510. * The id of the gamepad
  72511. */
  72512. id: string;
  72513. /**
  72514. * The index of the gamepad
  72515. */
  72516. index: number;
  72517. /**
  72518. * The browser gamepad
  72519. */
  72520. browserGamepad: any;
  72521. /**
  72522. * Specifies what type of gamepad this represents
  72523. */
  72524. type: number;
  72525. private _leftStick;
  72526. private _rightStick;
  72527. /** @hidden */
  72528. _isConnected: boolean;
  72529. private _leftStickAxisX;
  72530. private _leftStickAxisY;
  72531. private _rightStickAxisX;
  72532. private _rightStickAxisY;
  72533. /**
  72534. * Triggered when the left control stick has been changed
  72535. */
  72536. private _onleftstickchanged;
  72537. /**
  72538. * Triggered when the right control stick has been changed
  72539. */
  72540. private _onrightstickchanged;
  72541. /**
  72542. * Represents a gamepad controller
  72543. */
  72544. static GAMEPAD: number;
  72545. /**
  72546. * Represents a generic controller
  72547. */
  72548. static GENERIC: number;
  72549. /**
  72550. * Represents an XBox controller
  72551. */
  72552. static XBOX: number;
  72553. /**
  72554. * Represents a pose-enabled controller
  72555. */
  72556. static POSE_ENABLED: number;
  72557. /**
  72558. * Specifies whether the left control stick should be Y-inverted
  72559. */
  72560. protected _invertLeftStickY: boolean;
  72561. /**
  72562. * Specifies if the gamepad has been connected
  72563. */
  72564. readonly isConnected: boolean;
  72565. /**
  72566. * Initializes the gamepad
  72567. * @param id The id of the gamepad
  72568. * @param index The index of the gamepad
  72569. * @param browserGamepad The browser gamepad
  72570. * @param leftStickX The x component of the left joystick
  72571. * @param leftStickY The y component of the left joystick
  72572. * @param rightStickX The x component of the right joystick
  72573. * @param rightStickY The y component of the right joystick
  72574. */
  72575. constructor(
  72576. /**
  72577. * The id of the gamepad
  72578. */
  72579. id: string,
  72580. /**
  72581. * The index of the gamepad
  72582. */
  72583. index: number,
  72584. /**
  72585. * The browser gamepad
  72586. */
  72587. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72588. /**
  72589. * Callback triggered when the left joystick has changed
  72590. * @param callback
  72591. */
  72592. onleftstickchanged(callback: (values: StickValues) => void): void;
  72593. /**
  72594. * Callback triggered when the right joystick has changed
  72595. * @param callback
  72596. */
  72597. onrightstickchanged(callback: (values: StickValues) => void): void;
  72598. /**
  72599. * Gets the left joystick
  72600. */
  72601. /**
  72602. * Sets the left joystick values
  72603. */
  72604. leftStick: StickValues;
  72605. /**
  72606. * Gets the right joystick
  72607. */
  72608. /**
  72609. * Sets the right joystick value
  72610. */
  72611. rightStick: StickValues;
  72612. /**
  72613. * Updates the gamepad joystick positions
  72614. */
  72615. update(): void;
  72616. /**
  72617. * Disposes the gamepad
  72618. */
  72619. dispose(): void;
  72620. }
  72621. /**
  72622. * Represents a generic gamepad
  72623. */
  72624. export class GenericPad extends Gamepad {
  72625. private _buttons;
  72626. private _onbuttondown;
  72627. private _onbuttonup;
  72628. /**
  72629. * Observable triggered when a button has been pressed
  72630. */
  72631. onButtonDownObservable: Observable<number>;
  72632. /**
  72633. * Observable triggered when a button has been released
  72634. */
  72635. onButtonUpObservable: Observable<number>;
  72636. /**
  72637. * Callback triggered when a button has been pressed
  72638. * @param callback Called when a button has been pressed
  72639. */
  72640. onbuttondown(callback: (buttonPressed: number) => void): void;
  72641. /**
  72642. * Callback triggered when a button has been released
  72643. * @param callback Called when a button has been released
  72644. */
  72645. onbuttonup(callback: (buttonReleased: number) => void): void;
  72646. /**
  72647. * Initializes the generic gamepad
  72648. * @param id The id of the generic gamepad
  72649. * @param index The index of the generic gamepad
  72650. * @param browserGamepad The browser gamepad
  72651. */
  72652. constructor(id: string, index: number, browserGamepad: any);
  72653. private _setButtonValue;
  72654. /**
  72655. * Updates the generic gamepad
  72656. */
  72657. update(): void;
  72658. /**
  72659. * Disposes the generic gamepad
  72660. */
  72661. dispose(): void;
  72662. }
  72663. }
  72664. declare module BABYLON {
  72665. /**
  72666. * Defines the types of pose enabled controllers that are supported
  72667. */
  72668. export enum PoseEnabledControllerType {
  72669. /**
  72670. * HTC Vive
  72671. */
  72672. VIVE = 0,
  72673. /**
  72674. * Oculus Rift
  72675. */
  72676. OCULUS = 1,
  72677. /**
  72678. * Windows mixed reality
  72679. */
  72680. WINDOWS = 2,
  72681. /**
  72682. * Samsung gear VR
  72683. */
  72684. GEAR_VR = 3,
  72685. /**
  72686. * Google Daydream
  72687. */
  72688. DAYDREAM = 4,
  72689. /**
  72690. * Generic
  72691. */
  72692. GENERIC = 5
  72693. }
  72694. /**
  72695. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72696. */
  72697. export interface MutableGamepadButton {
  72698. /**
  72699. * Value of the button/trigger
  72700. */
  72701. value: number;
  72702. /**
  72703. * If the button/trigger is currently touched
  72704. */
  72705. touched: boolean;
  72706. /**
  72707. * If the button/trigger is currently pressed
  72708. */
  72709. pressed: boolean;
  72710. }
  72711. /**
  72712. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72713. * @hidden
  72714. */
  72715. export interface ExtendedGamepadButton extends GamepadButton {
  72716. /**
  72717. * If the button/trigger is currently pressed
  72718. */
  72719. readonly pressed: boolean;
  72720. /**
  72721. * If the button/trigger is currently touched
  72722. */
  72723. readonly touched: boolean;
  72724. /**
  72725. * Value of the button/trigger
  72726. */
  72727. readonly value: number;
  72728. }
  72729. /** @hidden */
  72730. export interface _GamePadFactory {
  72731. /**
  72732. * Returns wether or not the current gamepad can be created for this type of controller.
  72733. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72734. * @returns true if it can be created, otherwise false
  72735. */
  72736. canCreate(gamepadInfo: any): boolean;
  72737. /**
  72738. * Creates a new instance of the Gamepad.
  72739. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72740. * @returns the new gamepad instance
  72741. */
  72742. create(gamepadInfo: any): Gamepad;
  72743. }
  72744. /**
  72745. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72746. */
  72747. export class PoseEnabledControllerHelper {
  72748. /** @hidden */
  72749. static _ControllerFactories: _GamePadFactory[];
  72750. /** @hidden */
  72751. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72752. /**
  72753. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72754. * @param vrGamepad the gamepad to initialized
  72755. * @returns a vr controller of the type the gamepad identified as
  72756. */
  72757. static InitiateController(vrGamepad: any): Gamepad;
  72758. }
  72759. /**
  72760. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72761. */
  72762. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72763. private _deviceRoomPosition;
  72764. private _deviceRoomRotationQuaternion;
  72765. /**
  72766. * The device position in babylon space
  72767. */
  72768. devicePosition: Vector3;
  72769. /**
  72770. * The device rotation in babylon space
  72771. */
  72772. deviceRotationQuaternion: Quaternion;
  72773. /**
  72774. * The scale factor of the device in babylon space
  72775. */
  72776. deviceScaleFactor: number;
  72777. /**
  72778. * (Likely devicePosition should be used instead) The device position in its room space
  72779. */
  72780. position: Vector3;
  72781. /**
  72782. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72783. */
  72784. rotationQuaternion: Quaternion;
  72785. /**
  72786. * The type of controller (Eg. Windows mixed reality)
  72787. */
  72788. controllerType: PoseEnabledControllerType;
  72789. protected _calculatedPosition: Vector3;
  72790. private _calculatedRotation;
  72791. /**
  72792. * The raw pose from the device
  72793. */
  72794. rawPose: DevicePose;
  72795. private _trackPosition;
  72796. private _maxRotationDistFromHeadset;
  72797. private _draggedRoomRotation;
  72798. /**
  72799. * @hidden
  72800. */
  72801. _disableTrackPosition(fixedPosition: Vector3): void;
  72802. /**
  72803. * Internal, the mesh attached to the controller
  72804. * @hidden
  72805. */
  72806. _mesh: Nullable<AbstractMesh>;
  72807. private _poseControlledCamera;
  72808. private _leftHandSystemQuaternion;
  72809. /**
  72810. * Internal, matrix used to convert room space to babylon space
  72811. * @hidden
  72812. */
  72813. _deviceToWorld: Matrix;
  72814. /**
  72815. * Node to be used when casting a ray from the controller
  72816. * @hidden
  72817. */
  72818. _pointingPoseNode: Nullable<TransformNode>;
  72819. /**
  72820. * Name of the child mesh that can be used to cast a ray from the controller
  72821. */
  72822. static readonly POINTING_POSE: string;
  72823. /**
  72824. * Creates a new PoseEnabledController from a gamepad
  72825. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72826. */
  72827. constructor(browserGamepad: any);
  72828. private _workingMatrix;
  72829. /**
  72830. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72831. */
  72832. update(): void;
  72833. /**
  72834. * Updates only the pose device and mesh without doing any button event checking
  72835. */
  72836. protected _updatePoseAndMesh(): void;
  72837. /**
  72838. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72839. * @param poseData raw pose fromthe device
  72840. */
  72841. updateFromDevice(poseData: DevicePose): void;
  72842. /**
  72843. * @hidden
  72844. */
  72845. _meshAttachedObservable: Observable<AbstractMesh>;
  72846. /**
  72847. * Attaches a mesh to the controller
  72848. * @param mesh the mesh to be attached
  72849. */
  72850. attachToMesh(mesh: AbstractMesh): void;
  72851. /**
  72852. * Attaches the controllers mesh to a camera
  72853. * @param camera the camera the mesh should be attached to
  72854. */
  72855. attachToPoseControlledCamera(camera: TargetCamera): void;
  72856. /**
  72857. * Disposes of the controller
  72858. */
  72859. dispose(): void;
  72860. /**
  72861. * The mesh that is attached to the controller
  72862. */
  72863. readonly mesh: Nullable<AbstractMesh>;
  72864. /**
  72865. * Gets the ray of the controller in the direction the controller is pointing
  72866. * @param length the length the resulting ray should be
  72867. * @returns a ray in the direction the controller is pointing
  72868. */
  72869. getForwardRay(length?: number): Ray;
  72870. }
  72871. }
  72872. declare module BABYLON {
  72873. /**
  72874. * Defines the WebVRController object that represents controllers tracked in 3D space
  72875. */
  72876. export abstract class WebVRController extends PoseEnabledController {
  72877. /**
  72878. * Internal, the default controller model for the controller
  72879. */
  72880. protected _defaultModel: AbstractMesh;
  72881. /**
  72882. * Fired when the trigger state has changed
  72883. */
  72884. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72885. /**
  72886. * Fired when the main button state has changed
  72887. */
  72888. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72889. /**
  72890. * Fired when the secondary button state has changed
  72891. */
  72892. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72893. /**
  72894. * Fired when the pad state has changed
  72895. */
  72896. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72897. /**
  72898. * Fired when controllers stick values have changed
  72899. */
  72900. onPadValuesChangedObservable: Observable<StickValues>;
  72901. /**
  72902. * Array of button availible on the controller
  72903. */
  72904. protected _buttons: Array<MutableGamepadButton>;
  72905. private _onButtonStateChange;
  72906. /**
  72907. * Fired when a controller button's state has changed
  72908. * @param callback the callback containing the button that was modified
  72909. */
  72910. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72911. /**
  72912. * X and Y axis corrisponding to the controllers joystick
  72913. */
  72914. pad: StickValues;
  72915. /**
  72916. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72917. */
  72918. hand: string;
  72919. /**
  72920. * The default controller model for the controller
  72921. */
  72922. readonly defaultModel: AbstractMesh;
  72923. /**
  72924. * Creates a new WebVRController from a gamepad
  72925. * @param vrGamepad the gamepad that the WebVRController should be created from
  72926. */
  72927. constructor(vrGamepad: any);
  72928. /**
  72929. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72930. */
  72931. update(): void;
  72932. /**
  72933. * Function to be called when a button is modified
  72934. */
  72935. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72936. /**
  72937. * Loads a mesh and attaches it to the controller
  72938. * @param scene the scene the mesh should be added to
  72939. * @param meshLoaded callback for when the mesh has been loaded
  72940. */
  72941. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72942. private _setButtonValue;
  72943. private _changes;
  72944. private _checkChanges;
  72945. /**
  72946. * Disposes of th webVRCOntroller
  72947. */
  72948. dispose(): void;
  72949. }
  72950. }
  72951. declare module BABYLON {
  72952. /**
  72953. * The HemisphericLight simulates the ambient environment light,
  72954. * so the passed direction is the light reflection direction, not the incoming direction.
  72955. */
  72956. export class HemisphericLight extends Light {
  72957. /**
  72958. * The groundColor is the light in the opposite direction to the one specified during creation.
  72959. * 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.
  72960. */
  72961. groundColor: Color3;
  72962. /**
  72963. * The light reflection direction, not the incoming direction.
  72964. */
  72965. direction: Vector3;
  72966. /**
  72967. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72968. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72969. * The HemisphericLight can't cast shadows.
  72970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72971. * @param name The friendly name of the light
  72972. * @param direction The direction of the light reflection
  72973. * @param scene The scene the light belongs to
  72974. */
  72975. constructor(name: string, direction: Vector3, scene: Scene);
  72976. protected _buildUniformLayout(): void;
  72977. /**
  72978. * Returns the string "HemisphericLight".
  72979. * @return The class name
  72980. */
  72981. getClassName(): string;
  72982. /**
  72983. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72984. * Returns the updated direction.
  72985. * @param target The target the direction should point to
  72986. * @return The computed direction
  72987. */
  72988. setDirectionToTarget(target: Vector3): Vector3;
  72989. /**
  72990. * Returns the shadow generator associated to the light.
  72991. * @returns Always null for hemispheric lights because it does not support shadows.
  72992. */
  72993. getShadowGenerator(): Nullable<IShadowGenerator>;
  72994. /**
  72995. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72996. * @param effect The effect to update
  72997. * @param lightIndex The index of the light in the effect to update
  72998. * @returns The hemispheric light
  72999. */
  73000. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73001. /**
  73002. * Computes the world matrix of the node
  73003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73004. * @param useWasUpdatedFlag defines a reserved property
  73005. * @returns the world matrix
  73006. */
  73007. computeWorldMatrix(): Matrix;
  73008. /**
  73009. * Returns the integer 3.
  73010. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73011. */
  73012. getTypeID(): number;
  73013. /**
  73014. * Prepares the list of defines specific to the light type.
  73015. * @param defines the list of defines
  73016. * @param lightIndex defines the index of the light for the effect
  73017. */
  73018. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73019. }
  73020. }
  73021. declare module BABYLON {
  73022. /** @hidden */
  73023. export var vrMultiviewToSingleviewPixelShader: {
  73024. name: string;
  73025. shader: string;
  73026. };
  73027. }
  73028. declare module BABYLON {
  73029. /**
  73030. * Renders to multiple views with a single draw call
  73031. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73032. */
  73033. export class MultiviewRenderTarget extends RenderTargetTexture {
  73034. /**
  73035. * Creates a multiview render target
  73036. * @param scene scene used with the render target
  73037. * @param size the size of the render target (used for each view)
  73038. */
  73039. constructor(scene: Scene, size?: number | {
  73040. width: number;
  73041. height: number;
  73042. } | {
  73043. ratio: number;
  73044. });
  73045. /**
  73046. * @hidden
  73047. * @param faceIndex the face index, if its a cube texture
  73048. */
  73049. _bindFrameBuffer(faceIndex?: number): void;
  73050. /**
  73051. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73052. * @returns the view count
  73053. */
  73054. getViewCount(): number;
  73055. }
  73056. }
  73057. declare module BABYLON {
  73058. interface Engine {
  73059. /**
  73060. * Creates a new multiview render target
  73061. * @param width defines the width of the texture
  73062. * @param height defines the height of the texture
  73063. * @returns the created multiview texture
  73064. */
  73065. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73066. /**
  73067. * Binds a multiview framebuffer to be drawn to
  73068. * @param multiviewTexture texture to bind
  73069. */
  73070. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73071. }
  73072. interface Camera {
  73073. /**
  73074. * @hidden
  73075. * 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)
  73076. */
  73077. _useMultiviewToSingleView: boolean;
  73078. /**
  73079. * @hidden
  73080. * 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)
  73081. */
  73082. _multiviewTexture: Nullable<RenderTargetTexture>;
  73083. /**
  73084. * @hidden
  73085. * ensures the multiview texture of the camera exists and has the specified width/height
  73086. * @param width height to set on the multiview texture
  73087. * @param height width to set on the multiview texture
  73088. */
  73089. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73090. }
  73091. interface Scene {
  73092. /** @hidden */
  73093. _transformMatrixR: Matrix;
  73094. /** @hidden */
  73095. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73096. /** @hidden */
  73097. _createMultiviewUbo(): void;
  73098. /** @hidden */
  73099. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73100. /** @hidden */
  73101. _renderMultiviewToSingleView(camera: Camera): void;
  73102. }
  73103. }
  73104. declare module BABYLON {
  73105. /**
  73106. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73107. * This will not be used for webXR as it supports displaying texture arrays directly
  73108. */
  73109. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73110. /**
  73111. * Initializes a VRMultiviewToSingleview
  73112. * @param name name of the post process
  73113. * @param camera camera to be applied to
  73114. * @param scaleFactor scaling factor to the size of the output texture
  73115. */
  73116. constructor(name: string, camera: Camera, scaleFactor: number);
  73117. }
  73118. }
  73119. declare module BABYLON {
  73120. /**
  73121. * Defines the interface used by display changed events
  73122. */
  73123. interface IDisplayChangedEventArgs {
  73124. /** Gets the vrDisplay object (if any) */
  73125. vrDisplay: Nullable<any>;
  73126. /** Gets a boolean indicating if webVR is supported */
  73127. vrSupported: boolean;
  73128. }
  73129. interface Engine {
  73130. /** @hidden */
  73131. _vrDisplay: any;
  73132. /** @hidden */
  73133. _vrSupported: boolean;
  73134. /** @hidden */
  73135. _oldSize: Size;
  73136. /** @hidden */
  73137. _oldHardwareScaleFactor: number;
  73138. /** @hidden */
  73139. _vrExclusivePointerMode: boolean;
  73140. /** @hidden */
  73141. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73142. /** @hidden */
  73143. _onVRDisplayPointerRestricted: () => void;
  73144. /** @hidden */
  73145. _onVRDisplayPointerUnrestricted: () => void;
  73146. /** @hidden */
  73147. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73148. /** @hidden */
  73149. _onVrDisplayDisconnect: Nullable<() => void>;
  73150. /** @hidden */
  73151. _onVrDisplayPresentChange: Nullable<() => void>;
  73152. /**
  73153. * Observable signaled when VR display mode changes
  73154. */
  73155. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73156. /**
  73157. * Observable signaled when VR request present is complete
  73158. */
  73159. onVRRequestPresentComplete: Observable<boolean>;
  73160. /**
  73161. * Observable signaled when VR request present starts
  73162. */
  73163. onVRRequestPresentStart: Observable<Engine>;
  73164. /**
  73165. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73166. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73167. */
  73168. isInVRExclusivePointerMode: boolean;
  73169. /**
  73170. * Gets a boolean indicating if a webVR device was detected
  73171. * @returns true if a webVR device was detected
  73172. */
  73173. isVRDevicePresent(): boolean;
  73174. /**
  73175. * Gets the current webVR device
  73176. * @returns the current webVR device (or null)
  73177. */
  73178. getVRDevice(): any;
  73179. /**
  73180. * Initializes a webVR display and starts listening to display change events
  73181. * The onVRDisplayChangedObservable will be notified upon these changes
  73182. * @returns A promise containing a VRDisplay and if vr is supported
  73183. */
  73184. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73185. /** @hidden */
  73186. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73187. /**
  73188. * Call this function to switch to webVR mode
  73189. * Will do nothing if webVR is not supported or if there is no webVR device
  73190. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73191. */
  73192. enableVR(): void;
  73193. /** @hidden */
  73194. _onVRFullScreenTriggered(): void;
  73195. }
  73196. }
  73197. declare module BABYLON {
  73198. /**
  73199. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73200. * IMPORTANT!! The data is right-hand data.
  73201. * @export
  73202. * @interface DevicePose
  73203. */
  73204. export interface DevicePose {
  73205. /**
  73206. * The position of the device, values in array are [x,y,z].
  73207. */
  73208. readonly position: Nullable<Float32Array>;
  73209. /**
  73210. * The linearVelocity of the device, values in array are [x,y,z].
  73211. */
  73212. readonly linearVelocity: Nullable<Float32Array>;
  73213. /**
  73214. * The linearAcceleration of the device, values in array are [x,y,z].
  73215. */
  73216. readonly linearAcceleration: Nullable<Float32Array>;
  73217. /**
  73218. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73219. */
  73220. readonly orientation: Nullable<Float32Array>;
  73221. /**
  73222. * The angularVelocity of the device, values in array are [x,y,z].
  73223. */
  73224. readonly angularVelocity: Nullable<Float32Array>;
  73225. /**
  73226. * The angularAcceleration of the device, values in array are [x,y,z].
  73227. */
  73228. readonly angularAcceleration: Nullable<Float32Array>;
  73229. }
  73230. /**
  73231. * Interface representing a pose controlled object in Babylon.
  73232. * A pose controlled object has both regular pose values as well as pose values
  73233. * from an external device such as a VR head mounted display
  73234. */
  73235. export interface PoseControlled {
  73236. /**
  73237. * The position of the object in babylon space.
  73238. */
  73239. position: Vector3;
  73240. /**
  73241. * The rotation quaternion of the object in babylon space.
  73242. */
  73243. rotationQuaternion: Quaternion;
  73244. /**
  73245. * The position of the device in babylon space.
  73246. */
  73247. devicePosition?: Vector3;
  73248. /**
  73249. * The rotation quaternion of the device in babylon space.
  73250. */
  73251. deviceRotationQuaternion: Quaternion;
  73252. /**
  73253. * The raw pose coming from the device.
  73254. */
  73255. rawPose: Nullable<DevicePose>;
  73256. /**
  73257. * The scale of the device to be used when translating from device space to babylon space.
  73258. */
  73259. deviceScaleFactor: number;
  73260. /**
  73261. * Updates the poseControlled values based on the input device pose.
  73262. * @param poseData the pose data to update the object with
  73263. */
  73264. updateFromDevice(poseData: DevicePose): void;
  73265. }
  73266. /**
  73267. * Set of options to customize the webVRCamera
  73268. */
  73269. export interface WebVROptions {
  73270. /**
  73271. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73272. */
  73273. trackPosition?: boolean;
  73274. /**
  73275. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73276. */
  73277. positionScale?: number;
  73278. /**
  73279. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73280. */
  73281. displayName?: string;
  73282. /**
  73283. * Should the native controller meshes be initialized. (default: true)
  73284. */
  73285. controllerMeshes?: boolean;
  73286. /**
  73287. * Creating a default HemiLight only on controllers. (default: true)
  73288. */
  73289. defaultLightingOnControllers?: boolean;
  73290. /**
  73291. * If you don't want to use the default VR button of the helper. (default: false)
  73292. */
  73293. useCustomVRButton?: boolean;
  73294. /**
  73295. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73296. */
  73297. customVRButton?: HTMLButtonElement;
  73298. /**
  73299. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73300. */
  73301. rayLength?: number;
  73302. /**
  73303. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73304. */
  73305. defaultHeight?: number;
  73306. /**
  73307. * If multiview should be used if availible (default: false)
  73308. */
  73309. useMultiview?: boolean;
  73310. }
  73311. /**
  73312. * This represents a WebVR camera.
  73313. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73314. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73315. */
  73316. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73317. private webVROptions;
  73318. /**
  73319. * @hidden
  73320. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73321. */
  73322. _vrDevice: any;
  73323. /**
  73324. * The rawPose of the vrDevice.
  73325. */
  73326. rawPose: Nullable<DevicePose>;
  73327. private _onVREnabled;
  73328. private _specsVersion;
  73329. private _attached;
  73330. private _frameData;
  73331. protected _descendants: Array<Node>;
  73332. private _deviceRoomPosition;
  73333. /** @hidden */
  73334. _deviceRoomRotationQuaternion: Quaternion;
  73335. private _standingMatrix;
  73336. /**
  73337. * Represents device position in babylon space.
  73338. */
  73339. devicePosition: Vector3;
  73340. /**
  73341. * Represents device rotation in babylon space.
  73342. */
  73343. deviceRotationQuaternion: Quaternion;
  73344. /**
  73345. * The scale of the device to be used when translating from device space to babylon space.
  73346. */
  73347. deviceScaleFactor: number;
  73348. private _deviceToWorld;
  73349. private _worldToDevice;
  73350. /**
  73351. * References to the webVR controllers for the vrDevice.
  73352. */
  73353. controllers: Array<WebVRController>;
  73354. /**
  73355. * Emits an event when a controller is attached.
  73356. */
  73357. onControllersAttachedObservable: Observable<WebVRController[]>;
  73358. /**
  73359. * Emits an event when a controller's mesh has been loaded;
  73360. */
  73361. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73362. /**
  73363. * Emits an event when the HMD's pose has been updated.
  73364. */
  73365. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73366. private _poseSet;
  73367. /**
  73368. * If the rig cameras be used as parent instead of this camera.
  73369. */
  73370. rigParenting: boolean;
  73371. private _lightOnControllers;
  73372. private _defaultHeight?;
  73373. /**
  73374. * Instantiates a WebVRFreeCamera.
  73375. * @param name The name of the WebVRFreeCamera
  73376. * @param position The starting anchor position for the camera
  73377. * @param scene The scene the camera belongs to
  73378. * @param webVROptions a set of customizable options for the webVRCamera
  73379. */
  73380. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73381. /**
  73382. * Gets the device distance from the ground in meters.
  73383. * @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.
  73384. */
  73385. deviceDistanceToRoomGround(): number;
  73386. /**
  73387. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73388. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73389. */
  73390. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73391. /**
  73392. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73393. * @returns A promise with a boolean set to if the standing matrix is supported.
  73394. */
  73395. useStandingMatrixAsync(): Promise<boolean>;
  73396. /**
  73397. * Disposes the camera
  73398. */
  73399. dispose(): void;
  73400. /**
  73401. * Gets a vrController by name.
  73402. * @param name The name of the controller to retreive
  73403. * @returns the controller matching the name specified or null if not found
  73404. */
  73405. getControllerByName(name: string): Nullable<WebVRController>;
  73406. private _leftController;
  73407. /**
  73408. * The controller corrisponding to the users left hand.
  73409. */
  73410. readonly leftController: Nullable<WebVRController>;
  73411. private _rightController;
  73412. /**
  73413. * The controller corrisponding to the users right hand.
  73414. */
  73415. readonly rightController: Nullable<WebVRController>;
  73416. /**
  73417. * Casts a ray forward from the vrCamera's gaze.
  73418. * @param length Length of the ray (default: 100)
  73419. * @returns the ray corrisponding to the gaze
  73420. */
  73421. getForwardRay(length?: number): Ray;
  73422. /**
  73423. * @hidden
  73424. * Updates the camera based on device's frame data
  73425. */
  73426. _checkInputs(): void;
  73427. /**
  73428. * Updates the poseControlled values based on the input device pose.
  73429. * @param poseData Pose coming from the device
  73430. */
  73431. updateFromDevice(poseData: DevicePose): void;
  73432. private _htmlElementAttached;
  73433. private _detachIfAttached;
  73434. /**
  73435. * WebVR's attach control will start broadcasting frames to the device.
  73436. * Note that in certain browsers (chrome for example) this function must be called
  73437. * within a user-interaction callback. Example:
  73438. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73439. *
  73440. * @param element html element to attach the vrDevice to
  73441. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73442. */
  73443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73444. /**
  73445. * Detaches the camera from the html element and disables VR
  73446. *
  73447. * @param element html element to detach from
  73448. */
  73449. detachControl(element: HTMLElement): void;
  73450. /**
  73451. * @returns the name of this class
  73452. */
  73453. getClassName(): string;
  73454. /**
  73455. * Calls resetPose on the vrDisplay
  73456. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73457. */
  73458. resetToCurrentRotation(): void;
  73459. /**
  73460. * @hidden
  73461. * Updates the rig cameras (left and right eye)
  73462. */
  73463. _updateRigCameras(): void;
  73464. private _workingVector;
  73465. private _oneVector;
  73466. private _workingMatrix;
  73467. private updateCacheCalled;
  73468. private _correctPositionIfNotTrackPosition;
  73469. /**
  73470. * @hidden
  73471. * Updates the cached values of the camera
  73472. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73473. */
  73474. _updateCache(ignoreParentClass?: boolean): void;
  73475. /**
  73476. * @hidden
  73477. * Get current device position in babylon world
  73478. */
  73479. _computeDevicePosition(): void;
  73480. /**
  73481. * Updates the current device position and rotation in the babylon world
  73482. */
  73483. update(): void;
  73484. /**
  73485. * @hidden
  73486. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73487. * @returns an identity matrix
  73488. */
  73489. _getViewMatrix(): Matrix;
  73490. private _tmpMatrix;
  73491. /**
  73492. * This function is called by the two RIG cameras.
  73493. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73494. * @hidden
  73495. */
  73496. _getWebVRViewMatrix(): Matrix;
  73497. /** @hidden */
  73498. _getWebVRProjectionMatrix(): Matrix;
  73499. private _onGamepadConnectedObserver;
  73500. private _onGamepadDisconnectedObserver;
  73501. private _updateCacheWhenTrackingDisabledObserver;
  73502. /**
  73503. * Initializes the controllers and their meshes
  73504. */
  73505. initControllers(): void;
  73506. }
  73507. }
  73508. declare module BABYLON {
  73509. /**
  73510. * Size options for a post process
  73511. */
  73512. export type PostProcessOptions = {
  73513. width: number;
  73514. height: number;
  73515. };
  73516. /**
  73517. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73518. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73519. */
  73520. export class PostProcess {
  73521. /** Name of the PostProcess. */
  73522. name: string;
  73523. /**
  73524. * Gets or sets the unique id of the post process
  73525. */
  73526. uniqueId: number;
  73527. /**
  73528. * Width of the texture to apply the post process on
  73529. */
  73530. width: number;
  73531. /**
  73532. * Height of the texture to apply the post process on
  73533. */
  73534. height: number;
  73535. /**
  73536. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73537. * @hidden
  73538. */
  73539. _outputTexture: Nullable<InternalTexture>;
  73540. /**
  73541. * Sampling mode used by the shader
  73542. * See https://doc.babylonjs.com/classes/3.1/texture
  73543. */
  73544. renderTargetSamplingMode: number;
  73545. /**
  73546. * Clear color to use when screen clearing
  73547. */
  73548. clearColor: Color4;
  73549. /**
  73550. * If the buffer needs to be cleared before applying the post process. (default: true)
  73551. * Should be set to false if shader will overwrite all previous pixels.
  73552. */
  73553. autoClear: boolean;
  73554. /**
  73555. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73556. */
  73557. alphaMode: number;
  73558. /**
  73559. * Sets the setAlphaBlendConstants of the babylon engine
  73560. */
  73561. alphaConstants: Color4;
  73562. /**
  73563. * Animations to be used for the post processing
  73564. */
  73565. animations: Animation[];
  73566. /**
  73567. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73568. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73569. */
  73570. enablePixelPerfectMode: boolean;
  73571. /**
  73572. * Force the postprocess to be applied without taking in account viewport
  73573. */
  73574. forceFullscreenViewport: boolean;
  73575. /**
  73576. * List of inspectable custom properties (used by the Inspector)
  73577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73578. */
  73579. inspectableCustomProperties: IInspectable[];
  73580. /**
  73581. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73582. *
  73583. * | Value | Type | Description |
  73584. * | ----- | ----------------------------------- | ----------- |
  73585. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73586. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73587. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73588. *
  73589. */
  73590. scaleMode: number;
  73591. /**
  73592. * Force textures to be a power of two (default: false)
  73593. */
  73594. alwaysForcePOT: boolean;
  73595. private _samples;
  73596. /**
  73597. * Number of sample textures (default: 1)
  73598. */
  73599. samples: number;
  73600. /**
  73601. * Modify the scale of the post process to be the same as the viewport (default: false)
  73602. */
  73603. adaptScaleToCurrentViewport: boolean;
  73604. private _camera;
  73605. private _scene;
  73606. private _engine;
  73607. private _options;
  73608. private _reusable;
  73609. private _textureType;
  73610. /**
  73611. * Smart array of input and output textures for the post process.
  73612. * @hidden
  73613. */
  73614. _textures: SmartArray<InternalTexture>;
  73615. /**
  73616. * The index in _textures that corresponds to the output texture.
  73617. * @hidden
  73618. */
  73619. _currentRenderTextureInd: number;
  73620. private _effect;
  73621. private _samplers;
  73622. private _fragmentUrl;
  73623. private _vertexUrl;
  73624. private _parameters;
  73625. private _scaleRatio;
  73626. protected _indexParameters: any;
  73627. private _shareOutputWithPostProcess;
  73628. private _texelSize;
  73629. private _forcedOutputTexture;
  73630. /**
  73631. * Returns the fragment url or shader name used in the post process.
  73632. * @returns the fragment url or name in the shader store.
  73633. */
  73634. getEffectName(): string;
  73635. /**
  73636. * An event triggered when the postprocess is activated.
  73637. */
  73638. onActivateObservable: Observable<Camera>;
  73639. private _onActivateObserver;
  73640. /**
  73641. * A function that is added to the onActivateObservable
  73642. */
  73643. onActivate: Nullable<(camera: Camera) => void>;
  73644. /**
  73645. * An event triggered when the postprocess changes its size.
  73646. */
  73647. onSizeChangedObservable: Observable<PostProcess>;
  73648. private _onSizeChangedObserver;
  73649. /**
  73650. * A function that is added to the onSizeChangedObservable
  73651. */
  73652. onSizeChanged: (postProcess: PostProcess) => void;
  73653. /**
  73654. * An event triggered when the postprocess applies its effect.
  73655. */
  73656. onApplyObservable: Observable<Effect>;
  73657. private _onApplyObserver;
  73658. /**
  73659. * A function that is added to the onApplyObservable
  73660. */
  73661. onApply: (effect: Effect) => void;
  73662. /**
  73663. * An event triggered before rendering the postprocess
  73664. */
  73665. onBeforeRenderObservable: Observable<Effect>;
  73666. private _onBeforeRenderObserver;
  73667. /**
  73668. * A function that is added to the onBeforeRenderObservable
  73669. */
  73670. onBeforeRender: (effect: Effect) => void;
  73671. /**
  73672. * An event triggered after rendering the postprocess
  73673. */
  73674. onAfterRenderObservable: Observable<Effect>;
  73675. private _onAfterRenderObserver;
  73676. /**
  73677. * A function that is added to the onAfterRenderObservable
  73678. */
  73679. onAfterRender: (efect: Effect) => void;
  73680. /**
  73681. * 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
  73682. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73683. */
  73684. inputTexture: InternalTexture;
  73685. /**
  73686. * Gets the camera which post process is applied to.
  73687. * @returns The camera the post process is applied to.
  73688. */
  73689. getCamera(): Camera;
  73690. /**
  73691. * Gets the texel size of the postprocess.
  73692. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73693. */
  73694. readonly texelSize: Vector2;
  73695. /**
  73696. * Creates a new instance PostProcess
  73697. * @param name The name of the PostProcess.
  73698. * @param fragmentUrl The url of the fragment shader to be used.
  73699. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73700. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73701. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73702. * @param camera The camera to apply the render pass to.
  73703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73704. * @param engine The engine which the post process will be applied. (default: current engine)
  73705. * @param reusable If the post process can be reused on the same frame. (default: false)
  73706. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73707. * @param textureType Type of textures used when performing the post process. (default: 0)
  73708. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73709. * @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
  73710. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73711. */
  73712. constructor(
  73713. /** Name of the PostProcess. */
  73714. 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);
  73715. /**
  73716. * Gets a string idenfifying the name of the class
  73717. * @returns "PostProcess" string
  73718. */
  73719. getClassName(): string;
  73720. /**
  73721. * Gets the engine which this post process belongs to.
  73722. * @returns The engine the post process was enabled with.
  73723. */
  73724. getEngine(): Engine;
  73725. /**
  73726. * The effect that is created when initializing the post process.
  73727. * @returns The created effect corrisponding the the postprocess.
  73728. */
  73729. getEffect(): Effect;
  73730. /**
  73731. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73732. * @param postProcess The post process to share the output with.
  73733. * @returns This post process.
  73734. */
  73735. shareOutputWith(postProcess: PostProcess): PostProcess;
  73736. /**
  73737. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73738. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73739. */
  73740. useOwnOutput(): void;
  73741. /**
  73742. * Updates the effect with the current post process compile time values and recompiles the shader.
  73743. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73744. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73745. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73746. * @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
  73747. * @param onCompiled Called when the shader has been compiled.
  73748. * @param onError Called if there is an error when compiling a shader.
  73749. */
  73750. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73751. /**
  73752. * The post process is reusable if it can be used multiple times within one frame.
  73753. * @returns If the post process is reusable
  73754. */
  73755. isReusable(): boolean;
  73756. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73757. markTextureDirty(): void;
  73758. /**
  73759. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73760. * 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.
  73761. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73762. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73763. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73764. * @returns The target texture that was bound to be written to.
  73765. */
  73766. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73767. /**
  73768. * If the post process is supported.
  73769. */
  73770. readonly isSupported: boolean;
  73771. /**
  73772. * The aspect ratio of the output texture.
  73773. */
  73774. readonly aspectRatio: number;
  73775. /**
  73776. * Get a value indicating if the post-process is ready to be used
  73777. * @returns true if the post-process is ready (shader is compiled)
  73778. */
  73779. isReady(): boolean;
  73780. /**
  73781. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73782. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73783. */
  73784. apply(): Nullable<Effect>;
  73785. private _disposeTextures;
  73786. /**
  73787. * Disposes the post process.
  73788. * @param camera The camera to dispose the post process on.
  73789. */
  73790. dispose(camera?: Camera): void;
  73791. }
  73792. }
  73793. declare module BABYLON {
  73794. /**
  73795. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73796. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73797. */
  73798. export class PostProcessManager {
  73799. private _scene;
  73800. private _indexBuffer;
  73801. private _vertexBuffers;
  73802. /**
  73803. * Creates a new instance PostProcess
  73804. * @param scene The scene that the post process is associated with.
  73805. */
  73806. constructor(scene: Scene);
  73807. private _prepareBuffers;
  73808. private _buildIndexBuffer;
  73809. /**
  73810. * Rebuilds the vertex buffers of the manager.
  73811. * @hidden
  73812. */
  73813. _rebuild(): void;
  73814. /**
  73815. * Prepares a frame to be run through a post process.
  73816. * @param sourceTexture The input texture to the post procesess. (default: null)
  73817. * @param postProcesses An array of post processes to be run. (default: null)
  73818. * @returns True if the post processes were able to be run.
  73819. * @hidden
  73820. */
  73821. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73822. /**
  73823. * Manually render a set of post processes to a texture.
  73824. * @param postProcesses An array of post processes to be run.
  73825. * @param targetTexture The target texture to render to.
  73826. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73827. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73828. * @param lodLevel defines which lod of the texture to render to
  73829. */
  73830. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73831. /**
  73832. * Finalize the result of the output of the postprocesses.
  73833. * @param doNotPresent If true the result will not be displayed to the screen.
  73834. * @param targetTexture The target texture to render to.
  73835. * @param faceIndex The index of the face to bind the target texture to.
  73836. * @param postProcesses The array of post processes to render.
  73837. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73838. * @hidden
  73839. */
  73840. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73841. /**
  73842. * Disposes of the post process manager.
  73843. */
  73844. dispose(): void;
  73845. }
  73846. }
  73847. declare module BABYLON {
  73848. interface AbstractScene {
  73849. /**
  73850. * The list of layers (background and foreground) of the scene
  73851. */
  73852. layers: Array<Layer>;
  73853. }
  73854. /**
  73855. * Defines the layer scene component responsible to manage any layers
  73856. * in a given scene.
  73857. */
  73858. export class LayerSceneComponent implements ISceneComponent {
  73859. /**
  73860. * The component name helpfull to identify the component in the list of scene components.
  73861. */
  73862. readonly name: string;
  73863. /**
  73864. * The scene the component belongs to.
  73865. */
  73866. scene: Scene;
  73867. private _engine;
  73868. /**
  73869. * Creates a new instance of the component for the given scene
  73870. * @param scene Defines the scene to register the component in
  73871. */
  73872. constructor(scene: Scene);
  73873. /**
  73874. * Registers the component in a given scene
  73875. */
  73876. register(): void;
  73877. /**
  73878. * Rebuilds the elements related to this component in case of
  73879. * context lost for instance.
  73880. */
  73881. rebuild(): void;
  73882. /**
  73883. * Disposes the component and the associated ressources.
  73884. */
  73885. dispose(): void;
  73886. private _draw;
  73887. private _drawCameraPredicate;
  73888. private _drawCameraBackground;
  73889. private _drawCameraForeground;
  73890. private _drawRenderTargetPredicate;
  73891. private _drawRenderTargetBackground;
  73892. private _drawRenderTargetForeground;
  73893. }
  73894. }
  73895. declare module BABYLON {
  73896. /** @hidden */
  73897. export var layerPixelShader: {
  73898. name: string;
  73899. shader: string;
  73900. };
  73901. }
  73902. declare module BABYLON {
  73903. /** @hidden */
  73904. export var layerVertexShader: {
  73905. name: string;
  73906. shader: string;
  73907. };
  73908. }
  73909. declare module BABYLON {
  73910. /**
  73911. * This represents a full screen 2d layer.
  73912. * This can be useful to display a picture in the background of your scene for instance.
  73913. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73914. */
  73915. export class Layer {
  73916. /**
  73917. * Define the name of the layer.
  73918. */
  73919. name: string;
  73920. /**
  73921. * Define the texture the layer should display.
  73922. */
  73923. texture: Nullable<Texture>;
  73924. /**
  73925. * Is the layer in background or foreground.
  73926. */
  73927. isBackground: boolean;
  73928. /**
  73929. * Define the color of the layer (instead of texture).
  73930. */
  73931. color: Color4;
  73932. /**
  73933. * Define the scale of the layer in order to zoom in out of the texture.
  73934. */
  73935. scale: Vector2;
  73936. /**
  73937. * Define an offset for the layer in order to shift the texture.
  73938. */
  73939. offset: Vector2;
  73940. /**
  73941. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73942. */
  73943. alphaBlendingMode: number;
  73944. /**
  73945. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73946. * Alpha test will not mix with the background color in case of transparency.
  73947. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73948. */
  73949. alphaTest: boolean;
  73950. /**
  73951. * Define a mask to restrict the layer to only some of the scene cameras.
  73952. */
  73953. layerMask: number;
  73954. /**
  73955. * Define the list of render target the layer is visible into.
  73956. */
  73957. renderTargetTextures: RenderTargetTexture[];
  73958. /**
  73959. * Define if the layer is only used in renderTarget or if it also
  73960. * renders in the main frame buffer of the canvas.
  73961. */
  73962. renderOnlyInRenderTargetTextures: boolean;
  73963. private _scene;
  73964. private _vertexBuffers;
  73965. private _indexBuffer;
  73966. private _effect;
  73967. private _alphaTestEffect;
  73968. /**
  73969. * An event triggered when the layer is disposed.
  73970. */
  73971. onDisposeObservable: Observable<Layer>;
  73972. private _onDisposeObserver;
  73973. /**
  73974. * Back compatibility with callback before the onDisposeObservable existed.
  73975. * The set callback will be triggered when the layer has been disposed.
  73976. */
  73977. onDispose: () => void;
  73978. /**
  73979. * An event triggered before rendering the scene
  73980. */
  73981. onBeforeRenderObservable: Observable<Layer>;
  73982. private _onBeforeRenderObserver;
  73983. /**
  73984. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73985. * The set callback will be triggered just before rendering the layer.
  73986. */
  73987. onBeforeRender: () => void;
  73988. /**
  73989. * An event triggered after rendering the scene
  73990. */
  73991. onAfterRenderObservable: Observable<Layer>;
  73992. private _onAfterRenderObserver;
  73993. /**
  73994. * Back compatibility with callback before the onAfterRenderObservable existed.
  73995. * The set callback will be triggered just after rendering the layer.
  73996. */
  73997. onAfterRender: () => void;
  73998. /**
  73999. * Instantiates a new layer.
  74000. * This represents a full screen 2d layer.
  74001. * This can be useful to display a picture in the background of your scene for instance.
  74002. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74003. * @param name Define the name of the layer in the scene
  74004. * @param imgUrl Define the url of the texture to display in the layer
  74005. * @param scene Define the scene the layer belongs to
  74006. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74007. * @param color Defines a color for the layer
  74008. */
  74009. constructor(
  74010. /**
  74011. * Define the name of the layer.
  74012. */
  74013. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74014. private _createIndexBuffer;
  74015. /** @hidden */
  74016. _rebuild(): void;
  74017. /**
  74018. * Renders the layer in the scene.
  74019. */
  74020. render(): void;
  74021. /**
  74022. * Disposes and releases the associated ressources.
  74023. */
  74024. dispose(): void;
  74025. }
  74026. }
  74027. declare module BABYLON {
  74028. interface AbstractScene {
  74029. /**
  74030. * The list of procedural textures added to the scene
  74031. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74032. */
  74033. proceduralTextures: Array<ProceduralTexture>;
  74034. }
  74035. /**
  74036. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74037. * in a given scene.
  74038. */
  74039. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74040. /**
  74041. * The component name helpfull to identify the component in the list of scene components.
  74042. */
  74043. readonly name: string;
  74044. /**
  74045. * The scene the component belongs to.
  74046. */
  74047. scene: Scene;
  74048. /**
  74049. * Creates a new instance of the component for the given scene
  74050. * @param scene Defines the scene to register the component in
  74051. */
  74052. constructor(scene: Scene);
  74053. /**
  74054. * Registers the component in a given scene
  74055. */
  74056. register(): void;
  74057. /**
  74058. * Rebuilds the elements related to this component in case of
  74059. * context lost for instance.
  74060. */
  74061. rebuild(): void;
  74062. /**
  74063. * Disposes the component and the associated ressources.
  74064. */
  74065. dispose(): void;
  74066. private _beforeClear;
  74067. }
  74068. }
  74069. declare module BABYLON {
  74070. interface Engine {
  74071. /**
  74072. * Creates a new render target cube texture
  74073. * @param size defines the size of the texture
  74074. * @param options defines the options used to create the texture
  74075. * @returns a new render target cube texture stored in an InternalTexture
  74076. */
  74077. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74078. }
  74079. }
  74080. declare module BABYLON {
  74081. /** @hidden */
  74082. export var proceduralVertexShader: {
  74083. name: string;
  74084. shader: string;
  74085. };
  74086. }
  74087. declare module BABYLON {
  74088. /**
  74089. * 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.
  74090. * This is the base class of any Procedural texture and contains most of the shareable code.
  74091. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74092. */
  74093. export class ProceduralTexture extends Texture {
  74094. isCube: boolean;
  74095. /**
  74096. * Define if the texture is enabled or not (disabled texture will not render)
  74097. */
  74098. isEnabled: boolean;
  74099. /**
  74100. * Define if the texture must be cleared before rendering (default is true)
  74101. */
  74102. autoClear: boolean;
  74103. /**
  74104. * Callback called when the texture is generated
  74105. */
  74106. onGenerated: () => void;
  74107. /**
  74108. * Event raised when the texture is generated
  74109. */
  74110. onGeneratedObservable: Observable<ProceduralTexture>;
  74111. /** @hidden */
  74112. _generateMipMaps: boolean;
  74113. /** @hidden **/
  74114. _effect: Effect;
  74115. /** @hidden */
  74116. _textures: {
  74117. [key: string]: Texture;
  74118. };
  74119. private _size;
  74120. private _currentRefreshId;
  74121. private _refreshRate;
  74122. private _vertexBuffers;
  74123. private _indexBuffer;
  74124. private _uniforms;
  74125. private _samplers;
  74126. private _fragment;
  74127. private _floats;
  74128. private _ints;
  74129. private _floatsArrays;
  74130. private _colors3;
  74131. private _colors4;
  74132. private _vectors2;
  74133. private _vectors3;
  74134. private _matrices;
  74135. private _fallbackTexture;
  74136. private _fallbackTextureUsed;
  74137. private _engine;
  74138. private _cachedDefines;
  74139. private _contentUpdateId;
  74140. private _contentData;
  74141. /**
  74142. * Instantiates a new procedural texture.
  74143. * 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.
  74144. * This is the base class of any Procedural texture and contains most of the shareable code.
  74145. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74146. * @param name Define the name of the texture
  74147. * @param size Define the size of the texture to create
  74148. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74149. * @param scene Define the scene the texture belongs to
  74150. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74151. * @param generateMipMaps Define if the texture should creates mip maps or not
  74152. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74153. */
  74154. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74155. /**
  74156. * The effect that is created when initializing the post process.
  74157. * @returns The created effect corrisponding the the postprocess.
  74158. */
  74159. getEffect(): Effect;
  74160. /**
  74161. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74162. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74163. */
  74164. getContent(): Nullable<ArrayBufferView>;
  74165. private _createIndexBuffer;
  74166. /** @hidden */
  74167. _rebuild(): void;
  74168. /**
  74169. * Resets the texture in order to recreate its associated resources.
  74170. * This can be called in case of context loss
  74171. */
  74172. reset(): void;
  74173. protected _getDefines(): string;
  74174. /**
  74175. * Is the texture ready to be used ? (rendered at least once)
  74176. * @returns true if ready, otherwise, false.
  74177. */
  74178. isReady(): boolean;
  74179. /**
  74180. * Resets the refresh counter of the texture and start bak from scratch.
  74181. * Could be useful to regenerate the texture if it is setup to render only once.
  74182. */
  74183. resetRefreshCounter(): void;
  74184. /**
  74185. * Set the fragment shader to use in order to render the texture.
  74186. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74187. */
  74188. setFragment(fragment: any): void;
  74189. /**
  74190. * Define the refresh rate of the texture or the rendering frequency.
  74191. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74192. */
  74193. refreshRate: number;
  74194. /** @hidden */
  74195. _shouldRender(): boolean;
  74196. /**
  74197. * Get the size the texture is rendering at.
  74198. * @returns the size (texture is always squared)
  74199. */
  74200. getRenderSize(): number;
  74201. /**
  74202. * Resize the texture to new value.
  74203. * @param size Define the new size the texture should have
  74204. * @param generateMipMaps Define whether the new texture should create mip maps
  74205. */
  74206. resize(size: number, generateMipMaps: boolean): void;
  74207. private _checkUniform;
  74208. /**
  74209. * Set a texture in the shader program used to render.
  74210. * @param name Define the name of the uniform samplers as defined in the shader
  74211. * @param texture Define the texture to bind to this sampler
  74212. * @return the texture itself allowing "fluent" like uniform updates
  74213. */
  74214. setTexture(name: string, texture: Texture): ProceduralTexture;
  74215. /**
  74216. * Set a float in the shader.
  74217. * @param name Define the name of the uniform as defined in the shader
  74218. * @param value Define the value to give to the uniform
  74219. * @return the texture itself allowing "fluent" like uniform updates
  74220. */
  74221. setFloat(name: string, value: number): ProceduralTexture;
  74222. /**
  74223. * Set a int in the shader.
  74224. * @param name Define the name of the uniform as defined in the shader
  74225. * @param value Define the value to give to the uniform
  74226. * @return the texture itself allowing "fluent" like uniform updates
  74227. */
  74228. setInt(name: string, value: number): ProceduralTexture;
  74229. /**
  74230. * Set an array of floats in the shader.
  74231. * @param name Define the name of the uniform as defined in the shader
  74232. * @param value Define the value to give to the uniform
  74233. * @return the texture itself allowing "fluent" like uniform updates
  74234. */
  74235. setFloats(name: string, value: number[]): ProceduralTexture;
  74236. /**
  74237. * Set a vec3 in the shader from a Color3.
  74238. * @param name Define the name of the uniform as defined in the shader
  74239. * @param value Define the value to give to the uniform
  74240. * @return the texture itself allowing "fluent" like uniform updates
  74241. */
  74242. setColor3(name: string, value: Color3): ProceduralTexture;
  74243. /**
  74244. * Set a vec4 in the shader from a Color4.
  74245. * @param name Define the name of the uniform as defined in the shader
  74246. * @param value Define the value to give to the uniform
  74247. * @return the texture itself allowing "fluent" like uniform updates
  74248. */
  74249. setColor4(name: string, value: Color4): ProceduralTexture;
  74250. /**
  74251. * Set a vec2 in the shader from a Vector2.
  74252. * @param name Define the name of the uniform as defined in the shader
  74253. * @param value Define the value to give to the uniform
  74254. * @return the texture itself allowing "fluent" like uniform updates
  74255. */
  74256. setVector2(name: string, value: Vector2): ProceduralTexture;
  74257. /**
  74258. * Set a vec3 in the shader from a Vector3.
  74259. * @param name Define the name of the uniform as defined in the shader
  74260. * @param value Define the value to give to the uniform
  74261. * @return the texture itself allowing "fluent" like uniform updates
  74262. */
  74263. setVector3(name: string, value: Vector3): ProceduralTexture;
  74264. /**
  74265. * Set a mat4 in the shader from a MAtrix.
  74266. * @param name Define the name of the uniform as defined in the shader
  74267. * @param value Define the value to give to the uniform
  74268. * @return the texture itself allowing "fluent" like uniform updates
  74269. */
  74270. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74271. /**
  74272. * Render the texture to its associated render target.
  74273. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74274. */
  74275. render(useCameraPostProcess?: boolean): void;
  74276. /**
  74277. * Clone the texture.
  74278. * @returns the cloned texture
  74279. */
  74280. clone(): ProceduralTexture;
  74281. /**
  74282. * Dispose the texture and release its asoociated resources.
  74283. */
  74284. dispose(): void;
  74285. }
  74286. }
  74287. declare module BABYLON {
  74288. /**
  74289. * This represents the base class for particle system in Babylon.
  74290. * 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.
  74291. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74292. * @example https://doc.babylonjs.com/babylon101/particles
  74293. */
  74294. export class BaseParticleSystem {
  74295. /**
  74296. * Source color is added to the destination color without alpha affecting the result
  74297. */
  74298. static BLENDMODE_ONEONE: number;
  74299. /**
  74300. * Blend current color and particle color using particle’s alpha
  74301. */
  74302. static BLENDMODE_STANDARD: number;
  74303. /**
  74304. * Add current color and particle color multiplied by particle’s alpha
  74305. */
  74306. static BLENDMODE_ADD: number;
  74307. /**
  74308. * Multiply current color with particle color
  74309. */
  74310. static BLENDMODE_MULTIPLY: number;
  74311. /**
  74312. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74313. */
  74314. static BLENDMODE_MULTIPLYADD: number;
  74315. /**
  74316. * List of animations used by the particle system.
  74317. */
  74318. animations: Animation[];
  74319. /**
  74320. * The id of the Particle system.
  74321. */
  74322. id: string;
  74323. /**
  74324. * The friendly name of the Particle system.
  74325. */
  74326. name: string;
  74327. /**
  74328. * The rendering group used by the Particle system to chose when to render.
  74329. */
  74330. renderingGroupId: number;
  74331. /**
  74332. * The emitter represents the Mesh or position we are attaching the particle system to.
  74333. */
  74334. emitter: Nullable<AbstractMesh | Vector3>;
  74335. /**
  74336. * The maximum number of particles to emit per frame
  74337. */
  74338. emitRate: number;
  74339. /**
  74340. * If you want to launch only a few particles at once, that can be done, as well.
  74341. */
  74342. manualEmitCount: number;
  74343. /**
  74344. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74345. */
  74346. updateSpeed: number;
  74347. /**
  74348. * The amount of time the particle system is running (depends of the overall update speed).
  74349. */
  74350. targetStopDuration: number;
  74351. /**
  74352. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74353. */
  74354. disposeOnStop: boolean;
  74355. /**
  74356. * Minimum power of emitting particles.
  74357. */
  74358. minEmitPower: number;
  74359. /**
  74360. * Maximum power of emitting particles.
  74361. */
  74362. maxEmitPower: number;
  74363. /**
  74364. * Minimum life time of emitting particles.
  74365. */
  74366. minLifeTime: number;
  74367. /**
  74368. * Maximum life time of emitting particles.
  74369. */
  74370. maxLifeTime: number;
  74371. /**
  74372. * Minimum Size of emitting particles.
  74373. */
  74374. minSize: number;
  74375. /**
  74376. * Maximum Size of emitting particles.
  74377. */
  74378. maxSize: number;
  74379. /**
  74380. * Minimum scale of emitting particles on X axis.
  74381. */
  74382. minScaleX: number;
  74383. /**
  74384. * Maximum scale of emitting particles on X axis.
  74385. */
  74386. maxScaleX: number;
  74387. /**
  74388. * Minimum scale of emitting particles on Y axis.
  74389. */
  74390. minScaleY: number;
  74391. /**
  74392. * Maximum scale of emitting particles on Y axis.
  74393. */
  74394. maxScaleY: number;
  74395. /**
  74396. * Gets or sets the minimal initial rotation in radians.
  74397. */
  74398. minInitialRotation: number;
  74399. /**
  74400. * Gets or sets the maximal initial rotation in radians.
  74401. */
  74402. maxInitialRotation: number;
  74403. /**
  74404. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74405. */
  74406. minAngularSpeed: number;
  74407. /**
  74408. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74409. */
  74410. maxAngularSpeed: number;
  74411. /**
  74412. * The texture used to render each particle. (this can be a spritesheet)
  74413. */
  74414. particleTexture: Nullable<Texture>;
  74415. /**
  74416. * The layer mask we are rendering the particles through.
  74417. */
  74418. layerMask: number;
  74419. /**
  74420. * This can help using your own shader to render the particle system.
  74421. * The according effect will be created
  74422. */
  74423. customShader: any;
  74424. /**
  74425. * By default particle system starts as soon as they are created. This prevents the
  74426. * automatic start to happen and let you decide when to start emitting particles.
  74427. */
  74428. preventAutoStart: boolean;
  74429. private _noiseTexture;
  74430. /**
  74431. * Gets or sets a texture used to add random noise to particle positions
  74432. */
  74433. noiseTexture: Nullable<ProceduralTexture>;
  74434. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74435. noiseStrength: Vector3;
  74436. /**
  74437. * Callback triggered when the particle animation is ending.
  74438. */
  74439. onAnimationEnd: Nullable<() => void>;
  74440. /**
  74441. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74442. */
  74443. blendMode: number;
  74444. /**
  74445. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74446. * to override the particles.
  74447. */
  74448. forceDepthWrite: boolean;
  74449. /** 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 */
  74450. preWarmCycles: number;
  74451. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74452. preWarmStepOffset: number;
  74453. /**
  74454. * 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)
  74455. */
  74456. spriteCellChangeSpeed: number;
  74457. /**
  74458. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74459. */
  74460. startSpriteCellID: number;
  74461. /**
  74462. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74463. */
  74464. endSpriteCellID: number;
  74465. /**
  74466. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74467. */
  74468. spriteCellWidth: number;
  74469. /**
  74470. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74471. */
  74472. spriteCellHeight: number;
  74473. /**
  74474. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74475. */
  74476. spriteRandomStartCell: boolean;
  74477. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74478. translationPivot: Vector2;
  74479. /** @hidden */
  74480. protected _isAnimationSheetEnabled: boolean;
  74481. /**
  74482. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74483. */
  74484. beginAnimationOnStart: boolean;
  74485. /**
  74486. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74487. */
  74488. beginAnimationFrom: number;
  74489. /**
  74490. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74491. */
  74492. beginAnimationTo: number;
  74493. /**
  74494. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74495. */
  74496. beginAnimationLoop: boolean;
  74497. /**
  74498. * Gets or sets a world offset applied to all particles
  74499. */
  74500. worldOffset: Vector3;
  74501. /**
  74502. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74503. */
  74504. isAnimationSheetEnabled: boolean;
  74505. /**
  74506. * Get hosting scene
  74507. * @returns the scene
  74508. */
  74509. getScene(): Scene;
  74510. /**
  74511. * You can use gravity if you want to give an orientation to your particles.
  74512. */
  74513. gravity: Vector3;
  74514. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74515. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74516. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74517. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74518. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74519. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74520. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74521. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74522. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74523. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74524. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74525. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74526. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74527. /**
  74528. * Defines the delay in milliseconds before starting the system (0 by default)
  74529. */
  74530. startDelay: number;
  74531. /**
  74532. * Gets the current list of drag gradients.
  74533. * You must use addDragGradient and removeDragGradient to udpate this list
  74534. * @returns the list of drag gradients
  74535. */
  74536. getDragGradients(): Nullable<Array<FactorGradient>>;
  74537. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74538. limitVelocityDamping: number;
  74539. /**
  74540. * Gets the current list of limit velocity gradients.
  74541. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74542. * @returns the list of limit velocity gradients
  74543. */
  74544. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74545. /**
  74546. * Gets the current list of color gradients.
  74547. * You must use addColorGradient and removeColorGradient to udpate this list
  74548. * @returns the list of color gradients
  74549. */
  74550. getColorGradients(): Nullable<Array<ColorGradient>>;
  74551. /**
  74552. * Gets the current list of size gradients.
  74553. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74554. * @returns the list of size gradients
  74555. */
  74556. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74557. /**
  74558. * Gets the current list of color remap gradients.
  74559. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74560. * @returns the list of color remap gradients
  74561. */
  74562. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74563. /**
  74564. * Gets the current list of alpha remap gradients.
  74565. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74566. * @returns the list of alpha remap gradients
  74567. */
  74568. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74569. /**
  74570. * Gets the current list of life time gradients.
  74571. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74572. * @returns the list of life time gradients
  74573. */
  74574. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74575. /**
  74576. * Gets the current list of angular speed gradients.
  74577. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74578. * @returns the list of angular speed gradients
  74579. */
  74580. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74581. /**
  74582. * Gets the current list of velocity gradients.
  74583. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74584. * @returns the list of velocity gradients
  74585. */
  74586. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74587. /**
  74588. * Gets the current list of start size gradients.
  74589. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74590. * @returns the list of start size gradients
  74591. */
  74592. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74593. /**
  74594. * Gets the current list of emit rate gradients.
  74595. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74596. * @returns the list of emit rate gradients
  74597. */
  74598. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74599. /**
  74600. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74601. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74602. */
  74603. direction1: Vector3;
  74604. /**
  74605. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74606. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74607. */
  74608. direction2: Vector3;
  74609. /**
  74610. * 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.
  74611. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74612. */
  74613. minEmitBox: Vector3;
  74614. /**
  74615. * 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.
  74616. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74617. */
  74618. maxEmitBox: Vector3;
  74619. /**
  74620. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74621. */
  74622. color1: Color4;
  74623. /**
  74624. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74625. */
  74626. color2: Color4;
  74627. /**
  74628. * Color the particle will have at the end of its lifetime
  74629. */
  74630. colorDead: Color4;
  74631. /**
  74632. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74633. */
  74634. textureMask: Color4;
  74635. /**
  74636. * The particle emitter type defines the emitter used by the particle system.
  74637. * It can be for example box, sphere, or cone...
  74638. */
  74639. particleEmitterType: IParticleEmitterType;
  74640. /** @hidden */
  74641. _isSubEmitter: boolean;
  74642. /**
  74643. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74644. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74645. */
  74646. billboardMode: number;
  74647. protected _isBillboardBased: boolean;
  74648. /**
  74649. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74650. */
  74651. isBillboardBased: boolean;
  74652. /**
  74653. * The scene the particle system belongs to.
  74654. */
  74655. protected _scene: Scene;
  74656. /**
  74657. * Local cache of defines for image processing.
  74658. */
  74659. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74660. /**
  74661. * Default configuration related to image processing available in the standard Material.
  74662. */
  74663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74664. /**
  74665. * Gets the image processing configuration used either in this material.
  74666. */
  74667. /**
  74668. * Sets the Default image processing configuration used either in the this material.
  74669. *
  74670. * If sets to null, the scene one is in use.
  74671. */
  74672. imageProcessingConfiguration: ImageProcessingConfiguration;
  74673. /**
  74674. * Attaches a new image processing configuration to the Standard Material.
  74675. * @param configuration
  74676. */
  74677. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74678. /** @hidden */
  74679. protected _reset(): void;
  74680. /** @hidden */
  74681. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74682. /**
  74683. * Instantiates a particle system.
  74684. * 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.
  74685. * @param name The name of the particle system
  74686. */
  74687. constructor(name: string);
  74688. /**
  74689. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74692. * @returns the emitter
  74693. */
  74694. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74695. /**
  74696. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74697. * @param radius The radius of the hemisphere to emit from
  74698. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74699. * @returns the emitter
  74700. */
  74701. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74702. /**
  74703. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74704. * @param radius The radius of the sphere to emit from
  74705. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74706. * @returns the emitter
  74707. */
  74708. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74709. /**
  74710. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74711. * @param radius The radius of the sphere to emit from
  74712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74714. * @returns the emitter
  74715. */
  74716. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74717. /**
  74718. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74719. * @param radius The radius of the emission cylinder
  74720. * @param height The height of the emission cylinder
  74721. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74722. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74723. * @returns the emitter
  74724. */
  74725. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74726. /**
  74727. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74728. * @param radius The radius of the cylinder to emit from
  74729. * @param height The height of the emission cylinder
  74730. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74733. * @returns the emitter
  74734. */
  74735. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74736. /**
  74737. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74738. * @param radius The radius of the cone to emit from
  74739. * @param angle The base angle of the cone
  74740. * @returns the emitter
  74741. */
  74742. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74743. /**
  74744. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74747. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74748. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74749. * @returns the emitter
  74750. */
  74751. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74752. }
  74753. }
  74754. declare module BABYLON {
  74755. /**
  74756. * Type of sub emitter
  74757. */
  74758. export enum SubEmitterType {
  74759. /**
  74760. * Attached to the particle over it's lifetime
  74761. */
  74762. ATTACHED = 0,
  74763. /**
  74764. * Created when the particle dies
  74765. */
  74766. END = 1
  74767. }
  74768. /**
  74769. * Sub emitter class used to emit particles from an existing particle
  74770. */
  74771. export class SubEmitter {
  74772. /**
  74773. * the particle system to be used by the sub emitter
  74774. */
  74775. particleSystem: ParticleSystem;
  74776. /**
  74777. * Type of the submitter (Default: END)
  74778. */
  74779. type: SubEmitterType;
  74780. /**
  74781. * 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)
  74782. * Note: This only is supported when using an emitter of type Mesh
  74783. */
  74784. inheritDirection: boolean;
  74785. /**
  74786. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74787. */
  74788. inheritedVelocityAmount: number;
  74789. /**
  74790. * Creates a sub emitter
  74791. * @param particleSystem the particle system to be used by the sub emitter
  74792. */
  74793. constructor(
  74794. /**
  74795. * the particle system to be used by the sub emitter
  74796. */
  74797. particleSystem: ParticleSystem);
  74798. /**
  74799. * Clones the sub emitter
  74800. * @returns the cloned sub emitter
  74801. */
  74802. clone(): SubEmitter;
  74803. /**
  74804. * Serialize current object to a JSON object
  74805. * @returns the serialized object
  74806. */
  74807. serialize(): any;
  74808. /** @hidden */
  74809. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74810. /**
  74811. * Creates a new SubEmitter from a serialized JSON version
  74812. * @param serializationObject defines the JSON object to read from
  74813. * @param scene defines the hosting scene
  74814. * @param rootUrl defines the rootUrl for data loading
  74815. * @returns a new SubEmitter
  74816. */
  74817. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74818. /** Release associated resources */
  74819. dispose(): void;
  74820. }
  74821. }
  74822. declare module BABYLON {
  74823. /** @hidden */
  74824. export var clipPlaneFragmentDeclaration: {
  74825. name: string;
  74826. shader: string;
  74827. };
  74828. }
  74829. declare module BABYLON {
  74830. /** @hidden */
  74831. export var imageProcessingDeclaration: {
  74832. name: string;
  74833. shader: string;
  74834. };
  74835. }
  74836. declare module BABYLON {
  74837. /** @hidden */
  74838. export var imageProcessingFunctions: {
  74839. name: string;
  74840. shader: string;
  74841. };
  74842. }
  74843. declare module BABYLON {
  74844. /** @hidden */
  74845. export var clipPlaneFragment: {
  74846. name: string;
  74847. shader: string;
  74848. };
  74849. }
  74850. declare module BABYLON {
  74851. /** @hidden */
  74852. export var particlesPixelShader: {
  74853. name: string;
  74854. shader: string;
  74855. };
  74856. }
  74857. declare module BABYLON {
  74858. /** @hidden */
  74859. export var clipPlaneVertexDeclaration: {
  74860. name: string;
  74861. shader: string;
  74862. };
  74863. }
  74864. declare module BABYLON {
  74865. /** @hidden */
  74866. export var clipPlaneVertex: {
  74867. name: string;
  74868. shader: string;
  74869. };
  74870. }
  74871. declare module BABYLON {
  74872. /** @hidden */
  74873. export var particlesVertexShader: {
  74874. name: string;
  74875. shader: string;
  74876. };
  74877. }
  74878. declare module BABYLON {
  74879. /**
  74880. * This represents a particle system in Babylon.
  74881. * 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.
  74882. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74883. * @example https://doc.babylonjs.com/babylon101/particles
  74884. */
  74885. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74886. /**
  74887. * Billboard mode will only apply to Y axis
  74888. */
  74889. static readonly BILLBOARDMODE_Y: number;
  74890. /**
  74891. * Billboard mode will apply to all axes
  74892. */
  74893. static readonly BILLBOARDMODE_ALL: number;
  74894. /**
  74895. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74896. */
  74897. static readonly BILLBOARDMODE_STRETCHED: number;
  74898. /**
  74899. * This function can be defined to provide custom update for active particles.
  74900. * This function will be called instead of regular update (age, position, color, etc.).
  74901. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74902. */
  74903. updateFunction: (particles: Particle[]) => void;
  74904. private _emitterWorldMatrix;
  74905. /**
  74906. * This function can be defined to specify initial direction for every new particle.
  74907. * It by default use the emitterType defined function
  74908. */
  74909. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74910. /**
  74911. * This function can be defined to specify initial position for every new particle.
  74912. * It by default use the emitterType defined function
  74913. */
  74914. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74915. /**
  74916. * @hidden
  74917. */
  74918. _inheritedVelocityOffset: Vector3;
  74919. /**
  74920. * An event triggered when the system is disposed
  74921. */
  74922. onDisposeObservable: Observable<ParticleSystem>;
  74923. private _onDisposeObserver;
  74924. /**
  74925. * Sets a callback that will be triggered when the system is disposed
  74926. */
  74927. onDispose: () => void;
  74928. private _particles;
  74929. private _epsilon;
  74930. private _capacity;
  74931. private _stockParticles;
  74932. private _newPartsExcess;
  74933. private _vertexData;
  74934. private _vertexBuffer;
  74935. private _vertexBuffers;
  74936. private _spriteBuffer;
  74937. private _indexBuffer;
  74938. private _effect;
  74939. private _customEffect;
  74940. private _cachedDefines;
  74941. private _scaledColorStep;
  74942. private _colorDiff;
  74943. private _scaledDirection;
  74944. private _scaledGravity;
  74945. private _currentRenderId;
  74946. private _alive;
  74947. private _useInstancing;
  74948. private _started;
  74949. private _stopped;
  74950. private _actualFrame;
  74951. private _scaledUpdateSpeed;
  74952. private _vertexBufferSize;
  74953. /** @hidden */
  74954. _currentEmitRateGradient: Nullable<FactorGradient>;
  74955. /** @hidden */
  74956. _currentEmitRate1: number;
  74957. /** @hidden */
  74958. _currentEmitRate2: number;
  74959. /** @hidden */
  74960. _currentStartSizeGradient: Nullable<FactorGradient>;
  74961. /** @hidden */
  74962. _currentStartSize1: number;
  74963. /** @hidden */
  74964. _currentStartSize2: number;
  74965. private readonly _rawTextureWidth;
  74966. private _rampGradientsTexture;
  74967. private _useRampGradients;
  74968. /** Gets or sets a boolean indicating that ramp gradients must be used
  74969. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74970. */
  74971. useRampGradients: boolean;
  74972. /**
  74973. * 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.
  74974. * 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: [])
  74975. */
  74976. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74977. private _subEmitters;
  74978. /**
  74979. * @hidden
  74980. * If the particle systems emitter should be disposed when the particle system is disposed
  74981. */
  74982. _disposeEmitterOnDispose: boolean;
  74983. /**
  74984. * The current active Sub-systems, this property is used by the root particle system only.
  74985. */
  74986. activeSubSystems: Array<ParticleSystem>;
  74987. private _rootParticleSystem;
  74988. /**
  74989. * Gets the current list of active particles
  74990. */
  74991. readonly particles: Particle[];
  74992. /**
  74993. * Returns the string "ParticleSystem"
  74994. * @returns a string containing the class name
  74995. */
  74996. getClassName(): string;
  74997. /**
  74998. * Instantiates a particle system.
  74999. * 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.
  75000. * @param name The name of the particle system
  75001. * @param capacity The max number of particles alive at the same time
  75002. * @param scene The scene the particle system belongs to
  75003. * @param customEffect a custom effect used to change the way particles are rendered by default
  75004. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75005. * @param epsilon Offset used to render the particles
  75006. */
  75007. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75008. private _addFactorGradient;
  75009. private _removeFactorGradient;
  75010. /**
  75011. * Adds a new life time gradient
  75012. * @param gradient defines the gradient to use (between 0 and 1)
  75013. * @param factor defines the life time factor to affect to the specified gradient
  75014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75015. * @returns the current particle system
  75016. */
  75017. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75018. /**
  75019. * Remove a specific life time gradient
  75020. * @param gradient defines the gradient to remove
  75021. * @returns the current particle system
  75022. */
  75023. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75024. /**
  75025. * Adds a new size gradient
  75026. * @param gradient defines the gradient to use (between 0 and 1)
  75027. * @param factor defines the size factor to affect to the specified gradient
  75028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75029. * @returns the current particle system
  75030. */
  75031. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75032. /**
  75033. * Remove a specific size gradient
  75034. * @param gradient defines the gradient to remove
  75035. * @returns the current particle system
  75036. */
  75037. removeSizeGradient(gradient: number): IParticleSystem;
  75038. /**
  75039. * Adds a new color remap gradient
  75040. * @param gradient defines the gradient to use (between 0 and 1)
  75041. * @param min defines the color remap minimal range
  75042. * @param max defines the color remap maximal range
  75043. * @returns the current particle system
  75044. */
  75045. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75046. /**
  75047. * Remove a specific color remap gradient
  75048. * @param gradient defines the gradient to remove
  75049. * @returns the current particle system
  75050. */
  75051. removeColorRemapGradient(gradient: number): IParticleSystem;
  75052. /**
  75053. * Adds a new alpha remap gradient
  75054. * @param gradient defines the gradient to use (between 0 and 1)
  75055. * @param min defines the alpha remap minimal range
  75056. * @param max defines the alpha remap maximal range
  75057. * @returns the current particle system
  75058. */
  75059. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75060. /**
  75061. * Remove a specific alpha remap gradient
  75062. * @param gradient defines the gradient to remove
  75063. * @returns the current particle system
  75064. */
  75065. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75066. /**
  75067. * Adds a new angular speed gradient
  75068. * @param gradient defines the gradient to use (between 0 and 1)
  75069. * @param factor defines the angular speed to affect to the specified gradient
  75070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75071. * @returns the current particle system
  75072. */
  75073. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75074. /**
  75075. * Remove a specific angular speed gradient
  75076. * @param gradient defines the gradient to remove
  75077. * @returns the current particle system
  75078. */
  75079. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75080. /**
  75081. * Adds a new velocity gradient
  75082. * @param gradient defines the gradient to use (between 0 and 1)
  75083. * @param factor defines the velocity to affect to the specified gradient
  75084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75085. * @returns the current particle system
  75086. */
  75087. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75088. /**
  75089. * Remove a specific velocity gradient
  75090. * @param gradient defines the gradient to remove
  75091. * @returns the current particle system
  75092. */
  75093. removeVelocityGradient(gradient: number): IParticleSystem;
  75094. /**
  75095. * Adds a new limit velocity gradient
  75096. * @param gradient defines the gradient to use (between 0 and 1)
  75097. * @param factor defines the limit velocity value to affect to the specified gradient
  75098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75099. * @returns the current particle system
  75100. */
  75101. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75102. /**
  75103. * Remove a specific limit velocity gradient
  75104. * @param gradient defines the gradient to remove
  75105. * @returns the current particle system
  75106. */
  75107. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75108. /**
  75109. * Adds a new drag gradient
  75110. * @param gradient defines the gradient to use (between 0 and 1)
  75111. * @param factor defines the drag value to affect to the specified gradient
  75112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75113. * @returns the current particle system
  75114. */
  75115. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75116. /**
  75117. * Remove a specific drag gradient
  75118. * @param gradient defines the gradient to remove
  75119. * @returns the current particle system
  75120. */
  75121. removeDragGradient(gradient: number): IParticleSystem;
  75122. /**
  75123. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75124. * @param gradient defines the gradient to use (between 0 and 1)
  75125. * @param factor defines the emit rate value to affect to the specified gradient
  75126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75127. * @returns the current particle system
  75128. */
  75129. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75130. /**
  75131. * Remove a specific emit rate gradient
  75132. * @param gradient defines the gradient to remove
  75133. * @returns the current particle system
  75134. */
  75135. removeEmitRateGradient(gradient: number): IParticleSystem;
  75136. /**
  75137. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75138. * @param gradient defines the gradient to use (between 0 and 1)
  75139. * @param factor defines the start size value to affect to the specified gradient
  75140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75141. * @returns the current particle system
  75142. */
  75143. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75144. /**
  75145. * Remove a specific start size gradient
  75146. * @param gradient defines the gradient to remove
  75147. * @returns the current particle system
  75148. */
  75149. removeStartSizeGradient(gradient: number): IParticleSystem;
  75150. private _createRampGradientTexture;
  75151. /**
  75152. * Gets the current list of ramp gradients.
  75153. * You must use addRampGradient and removeRampGradient to udpate this list
  75154. * @returns the list of ramp gradients
  75155. */
  75156. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75157. /**
  75158. * Adds a new ramp gradient used to remap particle colors
  75159. * @param gradient defines the gradient to use (between 0 and 1)
  75160. * @param color defines the color to affect to the specified gradient
  75161. * @returns the current particle system
  75162. */
  75163. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75164. /**
  75165. * Remove a specific ramp gradient
  75166. * @param gradient defines the gradient to remove
  75167. * @returns the current particle system
  75168. */
  75169. removeRampGradient(gradient: number): ParticleSystem;
  75170. /**
  75171. * Adds a new color gradient
  75172. * @param gradient defines the gradient to use (between 0 and 1)
  75173. * @param color1 defines the color to affect to the specified gradient
  75174. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75175. * @returns this particle system
  75176. */
  75177. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75178. /**
  75179. * Remove a specific color gradient
  75180. * @param gradient defines the gradient to remove
  75181. * @returns this particle system
  75182. */
  75183. removeColorGradient(gradient: number): IParticleSystem;
  75184. private _fetchR;
  75185. protected _reset(): void;
  75186. private _resetEffect;
  75187. private _createVertexBuffers;
  75188. private _createIndexBuffer;
  75189. /**
  75190. * Gets the maximum number of particles active at the same time.
  75191. * @returns The max number of active particles.
  75192. */
  75193. getCapacity(): number;
  75194. /**
  75195. * Gets whether there are still active particles in the system.
  75196. * @returns True if it is alive, otherwise false.
  75197. */
  75198. isAlive(): boolean;
  75199. /**
  75200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75201. * @returns True if it has been started, otherwise false.
  75202. */
  75203. isStarted(): boolean;
  75204. private _prepareSubEmitterInternalArray;
  75205. /**
  75206. * Starts the particle system and begins to emit
  75207. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75208. */
  75209. start(delay?: number): void;
  75210. /**
  75211. * Stops the particle system.
  75212. * @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.
  75213. */
  75214. stop(stopSubEmitters?: boolean): void;
  75215. /**
  75216. * Remove all active particles
  75217. */
  75218. reset(): void;
  75219. /**
  75220. * @hidden (for internal use only)
  75221. */
  75222. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75223. /**
  75224. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75225. * Its lifetime will start back at 0.
  75226. */
  75227. recycleParticle: (particle: Particle) => void;
  75228. private _stopSubEmitters;
  75229. private _createParticle;
  75230. private _removeFromRoot;
  75231. private _emitFromParticle;
  75232. private _update;
  75233. /** @hidden */
  75234. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75235. /** @hidden */
  75236. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75237. /** @hidden */
  75238. private _getEffect;
  75239. /**
  75240. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75241. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75242. */
  75243. animate(preWarmOnly?: boolean): void;
  75244. private _appendParticleVertices;
  75245. /**
  75246. * Rebuilds the particle system.
  75247. */
  75248. rebuild(): void;
  75249. /**
  75250. * Is this system ready to be used/rendered
  75251. * @return true if the system is ready
  75252. */
  75253. isReady(): boolean;
  75254. private _render;
  75255. /**
  75256. * Renders the particle system in its current state.
  75257. * @returns the current number of particles
  75258. */
  75259. render(): number;
  75260. /**
  75261. * Disposes the particle system and free the associated resources
  75262. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75263. */
  75264. dispose(disposeTexture?: boolean): void;
  75265. /**
  75266. * Clones the particle system.
  75267. * @param name The name of the cloned object
  75268. * @param newEmitter The new emitter to use
  75269. * @returns the cloned particle system
  75270. */
  75271. clone(name: string, newEmitter: any): ParticleSystem;
  75272. /**
  75273. * Serializes the particle system to a JSON object.
  75274. * @returns the JSON object
  75275. */
  75276. serialize(): any;
  75277. /** @hidden */
  75278. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75279. /** @hidden */
  75280. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75281. /**
  75282. * Parses a JSON object to create a particle system.
  75283. * @param parsedParticleSystem The JSON object to parse
  75284. * @param scene The scene to create the particle system in
  75285. * @param rootUrl The root url to use to load external dependencies like texture
  75286. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75287. * @returns the Parsed particle system
  75288. */
  75289. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75290. }
  75291. }
  75292. declare module BABYLON {
  75293. /**
  75294. * A particle represents one of the element emitted by a particle system.
  75295. * This is mainly define by its coordinates, direction, velocity and age.
  75296. */
  75297. export class Particle {
  75298. /**
  75299. * The particle system the particle belongs to.
  75300. */
  75301. particleSystem: ParticleSystem;
  75302. private static _Count;
  75303. /**
  75304. * Unique ID of the particle
  75305. */
  75306. id: number;
  75307. /**
  75308. * The world position of the particle in the scene.
  75309. */
  75310. position: Vector3;
  75311. /**
  75312. * The world direction of the particle in the scene.
  75313. */
  75314. direction: Vector3;
  75315. /**
  75316. * The color of the particle.
  75317. */
  75318. color: Color4;
  75319. /**
  75320. * The color change of the particle per step.
  75321. */
  75322. colorStep: Color4;
  75323. /**
  75324. * Defines how long will the life of the particle be.
  75325. */
  75326. lifeTime: number;
  75327. /**
  75328. * The current age of the particle.
  75329. */
  75330. age: number;
  75331. /**
  75332. * The current size of the particle.
  75333. */
  75334. size: number;
  75335. /**
  75336. * The current scale of the particle.
  75337. */
  75338. scale: Vector2;
  75339. /**
  75340. * The current angle of the particle.
  75341. */
  75342. angle: number;
  75343. /**
  75344. * Defines how fast is the angle changing.
  75345. */
  75346. angularSpeed: number;
  75347. /**
  75348. * Defines the cell index used by the particle to be rendered from a sprite.
  75349. */
  75350. cellIndex: number;
  75351. /**
  75352. * The information required to support color remapping
  75353. */
  75354. remapData: Vector4;
  75355. /** @hidden */
  75356. _randomCellOffset?: number;
  75357. /** @hidden */
  75358. _initialDirection: Nullable<Vector3>;
  75359. /** @hidden */
  75360. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75361. /** @hidden */
  75362. _initialStartSpriteCellID: number;
  75363. /** @hidden */
  75364. _initialEndSpriteCellID: number;
  75365. /** @hidden */
  75366. _currentColorGradient: Nullable<ColorGradient>;
  75367. /** @hidden */
  75368. _currentColor1: Color4;
  75369. /** @hidden */
  75370. _currentColor2: Color4;
  75371. /** @hidden */
  75372. _currentSizeGradient: Nullable<FactorGradient>;
  75373. /** @hidden */
  75374. _currentSize1: number;
  75375. /** @hidden */
  75376. _currentSize2: number;
  75377. /** @hidden */
  75378. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75379. /** @hidden */
  75380. _currentAngularSpeed1: number;
  75381. /** @hidden */
  75382. _currentAngularSpeed2: number;
  75383. /** @hidden */
  75384. _currentVelocityGradient: Nullable<FactorGradient>;
  75385. /** @hidden */
  75386. _currentVelocity1: number;
  75387. /** @hidden */
  75388. _currentVelocity2: number;
  75389. /** @hidden */
  75390. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75391. /** @hidden */
  75392. _currentLimitVelocity1: number;
  75393. /** @hidden */
  75394. _currentLimitVelocity2: number;
  75395. /** @hidden */
  75396. _currentDragGradient: Nullable<FactorGradient>;
  75397. /** @hidden */
  75398. _currentDrag1: number;
  75399. /** @hidden */
  75400. _currentDrag2: number;
  75401. /** @hidden */
  75402. _randomNoiseCoordinates1: Vector3;
  75403. /** @hidden */
  75404. _randomNoiseCoordinates2: Vector3;
  75405. /**
  75406. * Creates a new instance Particle
  75407. * @param particleSystem the particle system the particle belongs to
  75408. */
  75409. constructor(
  75410. /**
  75411. * The particle system the particle belongs to.
  75412. */
  75413. particleSystem: ParticleSystem);
  75414. private updateCellInfoFromSystem;
  75415. /**
  75416. * Defines how the sprite cell index is updated for the particle
  75417. */
  75418. updateCellIndex(): void;
  75419. /** @hidden */
  75420. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75421. /** @hidden */
  75422. _inheritParticleInfoToSubEmitters(): void;
  75423. /** @hidden */
  75424. _reset(): void;
  75425. /**
  75426. * Copy the properties of particle to another one.
  75427. * @param other the particle to copy the information to.
  75428. */
  75429. copyTo(other: Particle): void;
  75430. }
  75431. }
  75432. declare module BABYLON {
  75433. /**
  75434. * Particle emitter represents a volume emitting particles.
  75435. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75436. */
  75437. export interface IParticleEmitterType {
  75438. /**
  75439. * Called by the particle System when the direction is computed for the created particle.
  75440. * @param worldMatrix is the world matrix of the particle system
  75441. * @param directionToUpdate is the direction vector to update with the result
  75442. * @param particle is the particle we are computed the direction for
  75443. */
  75444. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75445. /**
  75446. * Called by the particle System when the position is computed for the created particle.
  75447. * @param worldMatrix is the world matrix of the particle system
  75448. * @param positionToUpdate is the position vector to update with the result
  75449. * @param particle is the particle we are computed the position for
  75450. */
  75451. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75452. /**
  75453. * Clones the current emitter and returns a copy of it
  75454. * @returns the new emitter
  75455. */
  75456. clone(): IParticleEmitterType;
  75457. /**
  75458. * Called by the GPUParticleSystem to setup the update shader
  75459. * @param effect defines the update shader
  75460. */
  75461. applyToShader(effect: Effect): void;
  75462. /**
  75463. * Returns a string to use to update the GPU particles update shader
  75464. * @returns the effect defines string
  75465. */
  75466. getEffectDefines(): string;
  75467. /**
  75468. * Returns a string representing the class name
  75469. * @returns a string containing the class name
  75470. */
  75471. getClassName(): string;
  75472. /**
  75473. * Serializes the particle system to a JSON object.
  75474. * @returns the JSON object
  75475. */
  75476. serialize(): any;
  75477. /**
  75478. * Parse properties from a JSON object
  75479. * @param serializationObject defines the JSON object
  75480. */
  75481. parse(serializationObject: any): void;
  75482. }
  75483. }
  75484. declare module BABYLON {
  75485. /**
  75486. * Particle emitter emitting particles from the inside of a box.
  75487. * It emits the particles randomly between 2 given directions.
  75488. */
  75489. export class BoxParticleEmitter implements IParticleEmitterType {
  75490. /**
  75491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75492. */
  75493. direction1: Vector3;
  75494. /**
  75495. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75496. */
  75497. direction2: Vector3;
  75498. /**
  75499. * 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.
  75500. */
  75501. minEmitBox: Vector3;
  75502. /**
  75503. * 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.
  75504. */
  75505. maxEmitBox: Vector3;
  75506. /**
  75507. * Creates a new instance BoxParticleEmitter
  75508. */
  75509. constructor();
  75510. /**
  75511. * Called by the particle System when the direction is computed for the created particle.
  75512. * @param worldMatrix is the world matrix of the particle system
  75513. * @param directionToUpdate is the direction vector to update with the result
  75514. * @param particle is the particle we are computed the direction for
  75515. */
  75516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75517. /**
  75518. * Called by the particle System when the position is computed for the created particle.
  75519. * @param worldMatrix is the world matrix of the particle system
  75520. * @param positionToUpdate is the position vector to update with the result
  75521. * @param particle is the particle we are computed the position for
  75522. */
  75523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75524. /**
  75525. * Clones the current emitter and returns a copy of it
  75526. * @returns the new emitter
  75527. */
  75528. clone(): BoxParticleEmitter;
  75529. /**
  75530. * Called by the GPUParticleSystem to setup the update shader
  75531. * @param effect defines the update shader
  75532. */
  75533. applyToShader(effect: Effect): void;
  75534. /**
  75535. * Returns a string to use to update the GPU particles update shader
  75536. * @returns a string containng the defines string
  75537. */
  75538. getEffectDefines(): string;
  75539. /**
  75540. * Returns the string "BoxParticleEmitter"
  75541. * @returns a string containing the class name
  75542. */
  75543. getClassName(): string;
  75544. /**
  75545. * Serializes the particle system to a JSON object.
  75546. * @returns the JSON object
  75547. */
  75548. serialize(): any;
  75549. /**
  75550. * Parse properties from a JSON object
  75551. * @param serializationObject defines the JSON object
  75552. */
  75553. parse(serializationObject: any): void;
  75554. }
  75555. }
  75556. declare module BABYLON {
  75557. /**
  75558. * Particle emitter emitting particles from the inside of a cone.
  75559. * It emits the particles alongside the cone volume from the base to the particle.
  75560. * The emission direction might be randomized.
  75561. */
  75562. export class ConeParticleEmitter implements IParticleEmitterType {
  75563. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75564. directionRandomizer: number;
  75565. private _radius;
  75566. private _angle;
  75567. private _height;
  75568. /**
  75569. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75570. */
  75571. radiusRange: number;
  75572. /**
  75573. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75574. */
  75575. heightRange: number;
  75576. /**
  75577. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75578. */
  75579. emitFromSpawnPointOnly: boolean;
  75580. /**
  75581. * Gets or sets the radius of the emission cone
  75582. */
  75583. radius: number;
  75584. /**
  75585. * Gets or sets the angle of the emission cone
  75586. */
  75587. angle: number;
  75588. private _buildHeight;
  75589. /**
  75590. * Creates a new instance ConeParticleEmitter
  75591. * @param radius the radius of the emission cone (1 by default)
  75592. * @param angle the cone base angle (PI by default)
  75593. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75594. */
  75595. constructor(radius?: number, angle?: number,
  75596. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75597. directionRandomizer?: number);
  75598. /**
  75599. * Called by the particle System when the direction is computed for the created particle.
  75600. * @param worldMatrix is the world matrix of the particle system
  75601. * @param directionToUpdate is the direction vector to update with the result
  75602. * @param particle is the particle we are computed the direction for
  75603. */
  75604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75605. /**
  75606. * Called by the particle System when the position is computed for the created particle.
  75607. * @param worldMatrix is the world matrix of the particle system
  75608. * @param positionToUpdate is the position vector to update with the result
  75609. * @param particle is the particle we are computed the position for
  75610. */
  75611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75612. /**
  75613. * Clones the current emitter and returns a copy of it
  75614. * @returns the new emitter
  75615. */
  75616. clone(): ConeParticleEmitter;
  75617. /**
  75618. * Called by the GPUParticleSystem to setup the update shader
  75619. * @param effect defines the update shader
  75620. */
  75621. applyToShader(effect: Effect): void;
  75622. /**
  75623. * Returns a string to use to update the GPU particles update shader
  75624. * @returns a string containng the defines string
  75625. */
  75626. getEffectDefines(): string;
  75627. /**
  75628. * Returns the string "ConeParticleEmitter"
  75629. * @returns a string containing the class name
  75630. */
  75631. getClassName(): string;
  75632. /**
  75633. * Serializes the particle system to a JSON object.
  75634. * @returns the JSON object
  75635. */
  75636. serialize(): any;
  75637. /**
  75638. * Parse properties from a JSON object
  75639. * @param serializationObject defines the JSON object
  75640. */
  75641. parse(serializationObject: any): void;
  75642. }
  75643. }
  75644. declare module BABYLON {
  75645. /**
  75646. * Particle emitter emitting particles from the inside of a cylinder.
  75647. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75648. */
  75649. export class CylinderParticleEmitter implements IParticleEmitterType {
  75650. /**
  75651. * The radius of the emission cylinder.
  75652. */
  75653. radius: number;
  75654. /**
  75655. * The height of the emission cylinder.
  75656. */
  75657. height: number;
  75658. /**
  75659. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75660. */
  75661. radiusRange: number;
  75662. /**
  75663. * How much to randomize the particle direction [0-1].
  75664. */
  75665. directionRandomizer: number;
  75666. /**
  75667. * Creates a new instance CylinderParticleEmitter
  75668. * @param radius the radius of the emission cylinder (1 by default)
  75669. * @param height the height of the emission cylinder (1 by default)
  75670. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75671. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75672. */
  75673. constructor(
  75674. /**
  75675. * The radius of the emission cylinder.
  75676. */
  75677. radius?: number,
  75678. /**
  75679. * The height of the emission cylinder.
  75680. */
  75681. height?: number,
  75682. /**
  75683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75684. */
  75685. radiusRange?: number,
  75686. /**
  75687. * How much to randomize the particle direction [0-1].
  75688. */
  75689. directionRandomizer?: number);
  75690. /**
  75691. * Called by the particle System when the direction is computed for the created particle.
  75692. * @param worldMatrix is the world matrix of the particle system
  75693. * @param directionToUpdate is the direction vector to update with the result
  75694. * @param particle is the particle we are computed the direction for
  75695. */
  75696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75697. /**
  75698. * Called by the particle System when the position is computed for the created particle.
  75699. * @param worldMatrix is the world matrix of the particle system
  75700. * @param positionToUpdate is the position vector to update with the result
  75701. * @param particle is the particle we are computed the position for
  75702. */
  75703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75704. /**
  75705. * Clones the current emitter and returns a copy of it
  75706. * @returns the new emitter
  75707. */
  75708. clone(): CylinderParticleEmitter;
  75709. /**
  75710. * Called by the GPUParticleSystem to setup the update shader
  75711. * @param effect defines the update shader
  75712. */
  75713. applyToShader(effect: Effect): void;
  75714. /**
  75715. * Returns a string to use to update the GPU particles update shader
  75716. * @returns a string containng the defines string
  75717. */
  75718. getEffectDefines(): string;
  75719. /**
  75720. * Returns the string "CylinderParticleEmitter"
  75721. * @returns a string containing the class name
  75722. */
  75723. getClassName(): string;
  75724. /**
  75725. * Serializes the particle system to a JSON object.
  75726. * @returns the JSON object
  75727. */
  75728. serialize(): any;
  75729. /**
  75730. * Parse properties from a JSON object
  75731. * @param serializationObject defines the JSON object
  75732. */
  75733. parse(serializationObject: any): void;
  75734. }
  75735. /**
  75736. * Particle emitter emitting particles from the inside of a cylinder.
  75737. * It emits the particles randomly between two vectors.
  75738. */
  75739. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75740. /**
  75741. * The min limit of the emission direction.
  75742. */
  75743. direction1: Vector3;
  75744. /**
  75745. * The max limit of the emission direction.
  75746. */
  75747. direction2: Vector3;
  75748. /**
  75749. * Creates a new instance CylinderDirectedParticleEmitter
  75750. * @param radius the radius of the emission cylinder (1 by default)
  75751. * @param height the height of the emission cylinder (1 by default)
  75752. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75753. * @param direction1 the min limit of the emission direction (up vector by default)
  75754. * @param direction2 the max limit of the emission direction (up vector by default)
  75755. */
  75756. constructor(radius?: number, height?: number, radiusRange?: number,
  75757. /**
  75758. * The min limit of the emission direction.
  75759. */
  75760. direction1?: Vector3,
  75761. /**
  75762. * The max limit of the emission direction.
  75763. */
  75764. direction2?: Vector3);
  75765. /**
  75766. * Called by the particle System when the direction is computed for the created particle.
  75767. * @param worldMatrix is the world matrix of the particle system
  75768. * @param directionToUpdate is the direction vector to update with the result
  75769. * @param particle is the particle we are computed the direction for
  75770. */
  75771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75772. /**
  75773. * Clones the current emitter and returns a copy of it
  75774. * @returns the new emitter
  75775. */
  75776. clone(): CylinderDirectedParticleEmitter;
  75777. /**
  75778. * Called by the GPUParticleSystem to setup the update shader
  75779. * @param effect defines the update shader
  75780. */
  75781. applyToShader(effect: Effect): void;
  75782. /**
  75783. * Returns a string to use to update the GPU particles update shader
  75784. * @returns a string containng the defines string
  75785. */
  75786. getEffectDefines(): string;
  75787. /**
  75788. * Returns the string "CylinderDirectedParticleEmitter"
  75789. * @returns a string containing the class name
  75790. */
  75791. getClassName(): string;
  75792. /**
  75793. * Serializes the particle system to a JSON object.
  75794. * @returns the JSON object
  75795. */
  75796. serialize(): any;
  75797. /**
  75798. * Parse properties from a JSON object
  75799. * @param serializationObject defines the JSON object
  75800. */
  75801. parse(serializationObject: any): void;
  75802. }
  75803. }
  75804. declare module BABYLON {
  75805. /**
  75806. * Particle emitter emitting particles from the inside of a hemisphere.
  75807. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75808. */
  75809. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75810. /**
  75811. * The radius of the emission hemisphere.
  75812. */
  75813. radius: number;
  75814. /**
  75815. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75816. */
  75817. radiusRange: number;
  75818. /**
  75819. * How much to randomize the particle direction [0-1].
  75820. */
  75821. directionRandomizer: number;
  75822. /**
  75823. * Creates a new instance HemisphericParticleEmitter
  75824. * @param radius the radius of the emission hemisphere (1 by default)
  75825. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75826. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75827. */
  75828. constructor(
  75829. /**
  75830. * The radius of the emission hemisphere.
  75831. */
  75832. radius?: number,
  75833. /**
  75834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75835. */
  75836. radiusRange?: number,
  75837. /**
  75838. * How much to randomize the particle direction [0-1].
  75839. */
  75840. directionRandomizer?: number);
  75841. /**
  75842. * Called by the particle System when the direction is computed for the created particle.
  75843. * @param worldMatrix is the world matrix of the particle system
  75844. * @param directionToUpdate is the direction vector to update with the result
  75845. * @param particle is the particle we are computed the direction for
  75846. */
  75847. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75848. /**
  75849. * Called by the particle System when the position is computed for the created particle.
  75850. * @param worldMatrix is the world matrix of the particle system
  75851. * @param positionToUpdate is the position vector to update with the result
  75852. * @param particle is the particle we are computed the position for
  75853. */
  75854. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75855. /**
  75856. * Clones the current emitter and returns a copy of it
  75857. * @returns the new emitter
  75858. */
  75859. clone(): HemisphericParticleEmitter;
  75860. /**
  75861. * Called by the GPUParticleSystem to setup the update shader
  75862. * @param effect defines the update shader
  75863. */
  75864. applyToShader(effect: Effect): void;
  75865. /**
  75866. * Returns a string to use to update the GPU particles update shader
  75867. * @returns a string containng the defines string
  75868. */
  75869. getEffectDefines(): string;
  75870. /**
  75871. * Returns the string "HemisphericParticleEmitter"
  75872. * @returns a string containing the class name
  75873. */
  75874. getClassName(): string;
  75875. /**
  75876. * Serializes the particle system to a JSON object.
  75877. * @returns the JSON object
  75878. */
  75879. serialize(): any;
  75880. /**
  75881. * Parse properties from a JSON object
  75882. * @param serializationObject defines the JSON object
  75883. */
  75884. parse(serializationObject: any): void;
  75885. }
  75886. }
  75887. declare module BABYLON {
  75888. /**
  75889. * Particle emitter emitting particles from a point.
  75890. * It emits the particles randomly between 2 given directions.
  75891. */
  75892. export class PointParticleEmitter implements IParticleEmitterType {
  75893. /**
  75894. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75895. */
  75896. direction1: Vector3;
  75897. /**
  75898. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75899. */
  75900. direction2: Vector3;
  75901. /**
  75902. * Creates a new instance PointParticleEmitter
  75903. */
  75904. constructor();
  75905. /**
  75906. * Called by the particle System when the direction is computed for the created particle.
  75907. * @param worldMatrix is the world matrix of the particle system
  75908. * @param directionToUpdate is the direction vector to update with the result
  75909. * @param particle is the particle we are computed the direction for
  75910. */
  75911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75912. /**
  75913. * Called by the particle System when the position is computed for the created particle.
  75914. * @param worldMatrix is the world matrix of the particle system
  75915. * @param positionToUpdate is the position vector to update with the result
  75916. * @param particle is the particle we are computed the position for
  75917. */
  75918. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75919. /**
  75920. * Clones the current emitter and returns a copy of it
  75921. * @returns the new emitter
  75922. */
  75923. clone(): PointParticleEmitter;
  75924. /**
  75925. * Called by the GPUParticleSystem to setup the update shader
  75926. * @param effect defines the update shader
  75927. */
  75928. applyToShader(effect: Effect): void;
  75929. /**
  75930. * Returns a string to use to update the GPU particles update shader
  75931. * @returns a string containng the defines string
  75932. */
  75933. getEffectDefines(): string;
  75934. /**
  75935. * Returns the string "PointParticleEmitter"
  75936. * @returns a string containing the class name
  75937. */
  75938. getClassName(): string;
  75939. /**
  75940. * Serializes the particle system to a JSON object.
  75941. * @returns the JSON object
  75942. */
  75943. serialize(): any;
  75944. /**
  75945. * Parse properties from a JSON object
  75946. * @param serializationObject defines the JSON object
  75947. */
  75948. parse(serializationObject: any): void;
  75949. }
  75950. }
  75951. declare module BABYLON {
  75952. /**
  75953. * Particle emitter emitting particles from the inside of a sphere.
  75954. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75955. */
  75956. export class SphereParticleEmitter implements IParticleEmitterType {
  75957. /**
  75958. * The radius of the emission sphere.
  75959. */
  75960. radius: number;
  75961. /**
  75962. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75963. */
  75964. radiusRange: number;
  75965. /**
  75966. * How much to randomize the particle direction [0-1].
  75967. */
  75968. directionRandomizer: number;
  75969. /**
  75970. * Creates a new instance SphereParticleEmitter
  75971. * @param radius the radius of the emission sphere (1 by default)
  75972. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75973. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75974. */
  75975. constructor(
  75976. /**
  75977. * The radius of the emission sphere.
  75978. */
  75979. radius?: number,
  75980. /**
  75981. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75982. */
  75983. radiusRange?: number,
  75984. /**
  75985. * How much to randomize the particle direction [0-1].
  75986. */
  75987. directionRandomizer?: number);
  75988. /**
  75989. * Called by the particle System when the direction is computed for the created particle.
  75990. * @param worldMatrix is the world matrix of the particle system
  75991. * @param directionToUpdate is the direction vector to update with the result
  75992. * @param particle is the particle we are computed the direction for
  75993. */
  75994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75995. /**
  75996. * Called by the particle System when the position is computed for the created particle.
  75997. * @param worldMatrix is the world matrix of the particle system
  75998. * @param positionToUpdate is the position vector to update with the result
  75999. * @param particle is the particle we are computed the position for
  76000. */
  76001. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76002. /**
  76003. * Clones the current emitter and returns a copy of it
  76004. * @returns the new emitter
  76005. */
  76006. clone(): SphereParticleEmitter;
  76007. /**
  76008. * Called by the GPUParticleSystem to setup the update shader
  76009. * @param effect defines the update shader
  76010. */
  76011. applyToShader(effect: Effect): void;
  76012. /**
  76013. * Returns a string to use to update the GPU particles update shader
  76014. * @returns a string containng the defines string
  76015. */
  76016. getEffectDefines(): string;
  76017. /**
  76018. * Returns the string "SphereParticleEmitter"
  76019. * @returns a string containing the class name
  76020. */
  76021. getClassName(): string;
  76022. /**
  76023. * Serializes the particle system to a JSON object.
  76024. * @returns the JSON object
  76025. */
  76026. serialize(): any;
  76027. /**
  76028. * Parse properties from a JSON object
  76029. * @param serializationObject defines the JSON object
  76030. */
  76031. parse(serializationObject: any): void;
  76032. }
  76033. /**
  76034. * Particle emitter emitting particles from the inside of a sphere.
  76035. * It emits the particles randomly between two vectors.
  76036. */
  76037. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76038. /**
  76039. * The min limit of the emission direction.
  76040. */
  76041. direction1: Vector3;
  76042. /**
  76043. * The max limit of the emission direction.
  76044. */
  76045. direction2: Vector3;
  76046. /**
  76047. * Creates a new instance SphereDirectedParticleEmitter
  76048. * @param radius the radius of the emission sphere (1 by default)
  76049. * @param direction1 the min limit of the emission direction (up vector by default)
  76050. * @param direction2 the max limit of the emission direction (up vector by default)
  76051. */
  76052. constructor(radius?: number,
  76053. /**
  76054. * The min limit of the emission direction.
  76055. */
  76056. direction1?: Vector3,
  76057. /**
  76058. * The max limit of the emission direction.
  76059. */
  76060. direction2?: Vector3);
  76061. /**
  76062. * Called by the particle System when the direction is computed for the created particle.
  76063. * @param worldMatrix is the world matrix of the particle system
  76064. * @param directionToUpdate is the direction vector to update with the result
  76065. * @param particle is the particle we are computed the direction for
  76066. */
  76067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76068. /**
  76069. * Clones the current emitter and returns a copy of it
  76070. * @returns the new emitter
  76071. */
  76072. clone(): SphereDirectedParticleEmitter;
  76073. /**
  76074. * Called by the GPUParticleSystem to setup the update shader
  76075. * @param effect defines the update shader
  76076. */
  76077. applyToShader(effect: Effect): void;
  76078. /**
  76079. * Returns a string to use to update the GPU particles update shader
  76080. * @returns a string containng the defines string
  76081. */
  76082. getEffectDefines(): string;
  76083. /**
  76084. * Returns the string "SphereDirectedParticleEmitter"
  76085. * @returns a string containing the class name
  76086. */
  76087. getClassName(): string;
  76088. /**
  76089. * Serializes the particle system to a JSON object.
  76090. * @returns the JSON object
  76091. */
  76092. serialize(): any;
  76093. /**
  76094. * Parse properties from a JSON object
  76095. * @param serializationObject defines the JSON object
  76096. */
  76097. parse(serializationObject: any): void;
  76098. }
  76099. }
  76100. declare module BABYLON {
  76101. /**
  76102. * Interface representing a particle system in Babylon.js.
  76103. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76104. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76105. */
  76106. export interface IParticleSystem {
  76107. /**
  76108. * List of animations used by the particle system.
  76109. */
  76110. animations: Animation[];
  76111. /**
  76112. * The id of the Particle system.
  76113. */
  76114. id: string;
  76115. /**
  76116. * The name of the Particle system.
  76117. */
  76118. name: string;
  76119. /**
  76120. * The emitter represents the Mesh or position we are attaching the particle system to.
  76121. */
  76122. emitter: Nullable<AbstractMesh | Vector3>;
  76123. /**
  76124. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76125. */
  76126. isBillboardBased: boolean;
  76127. /**
  76128. * The rendering group used by the Particle system to chose when to render.
  76129. */
  76130. renderingGroupId: number;
  76131. /**
  76132. * The layer mask we are rendering the particles through.
  76133. */
  76134. layerMask: number;
  76135. /**
  76136. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76137. */
  76138. updateSpeed: number;
  76139. /**
  76140. * The amount of time the particle system is running (depends of the overall update speed).
  76141. */
  76142. targetStopDuration: number;
  76143. /**
  76144. * The texture used to render each particle. (this can be a spritesheet)
  76145. */
  76146. particleTexture: Nullable<Texture>;
  76147. /**
  76148. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76149. */
  76150. blendMode: number;
  76151. /**
  76152. * Minimum life time of emitting particles.
  76153. */
  76154. minLifeTime: number;
  76155. /**
  76156. * Maximum life time of emitting particles.
  76157. */
  76158. maxLifeTime: number;
  76159. /**
  76160. * Minimum Size of emitting particles.
  76161. */
  76162. minSize: number;
  76163. /**
  76164. * Maximum Size of emitting particles.
  76165. */
  76166. maxSize: number;
  76167. /**
  76168. * Minimum scale of emitting particles on X axis.
  76169. */
  76170. minScaleX: number;
  76171. /**
  76172. * Maximum scale of emitting particles on X axis.
  76173. */
  76174. maxScaleX: number;
  76175. /**
  76176. * Minimum scale of emitting particles on Y axis.
  76177. */
  76178. minScaleY: number;
  76179. /**
  76180. * Maximum scale of emitting particles on Y axis.
  76181. */
  76182. maxScaleY: number;
  76183. /**
  76184. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76185. */
  76186. color1: Color4;
  76187. /**
  76188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76189. */
  76190. color2: Color4;
  76191. /**
  76192. * Color the particle will have at the end of its lifetime.
  76193. */
  76194. colorDead: Color4;
  76195. /**
  76196. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76197. */
  76198. emitRate: number;
  76199. /**
  76200. * You can use gravity if you want to give an orientation to your particles.
  76201. */
  76202. gravity: Vector3;
  76203. /**
  76204. * Minimum power of emitting particles.
  76205. */
  76206. minEmitPower: number;
  76207. /**
  76208. * Maximum power of emitting particles.
  76209. */
  76210. maxEmitPower: number;
  76211. /**
  76212. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76213. */
  76214. minAngularSpeed: number;
  76215. /**
  76216. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76217. */
  76218. maxAngularSpeed: number;
  76219. /**
  76220. * Gets or sets the minimal initial rotation in radians.
  76221. */
  76222. minInitialRotation: number;
  76223. /**
  76224. * Gets or sets the maximal initial rotation in radians.
  76225. */
  76226. maxInitialRotation: number;
  76227. /**
  76228. * The particle emitter type defines the emitter used by the particle system.
  76229. * It can be for example box, sphere, or cone...
  76230. */
  76231. particleEmitterType: Nullable<IParticleEmitterType>;
  76232. /**
  76233. * Defines the delay in milliseconds before starting the system (0 by default)
  76234. */
  76235. startDelay: number;
  76236. /**
  76237. * 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
  76238. */
  76239. preWarmCycles: number;
  76240. /**
  76241. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76242. */
  76243. preWarmStepOffset: number;
  76244. /**
  76245. * 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)
  76246. */
  76247. spriteCellChangeSpeed: number;
  76248. /**
  76249. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76250. */
  76251. startSpriteCellID: number;
  76252. /**
  76253. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76254. */
  76255. endSpriteCellID: number;
  76256. /**
  76257. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76258. */
  76259. spriteCellWidth: number;
  76260. /**
  76261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76262. */
  76263. spriteCellHeight: number;
  76264. /**
  76265. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76266. */
  76267. spriteRandomStartCell: boolean;
  76268. /**
  76269. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76270. */
  76271. isAnimationSheetEnabled: boolean;
  76272. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76273. translationPivot: Vector2;
  76274. /**
  76275. * Gets or sets a texture used to add random noise to particle positions
  76276. */
  76277. noiseTexture: Nullable<BaseTexture>;
  76278. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76279. noiseStrength: Vector3;
  76280. /**
  76281. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76282. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76283. */
  76284. billboardMode: number;
  76285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76286. limitVelocityDamping: number;
  76287. /**
  76288. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76289. */
  76290. beginAnimationOnStart: boolean;
  76291. /**
  76292. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76293. */
  76294. beginAnimationFrom: number;
  76295. /**
  76296. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76297. */
  76298. beginAnimationTo: number;
  76299. /**
  76300. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76301. */
  76302. beginAnimationLoop: boolean;
  76303. /**
  76304. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76305. */
  76306. disposeOnStop: boolean;
  76307. /**
  76308. * Gets the maximum number of particles active at the same time.
  76309. * @returns The max number of active particles.
  76310. */
  76311. getCapacity(): number;
  76312. /**
  76313. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76314. * @returns True if it has been started, otherwise false.
  76315. */
  76316. isStarted(): boolean;
  76317. /**
  76318. * Animates the particle system for this frame.
  76319. */
  76320. animate(): void;
  76321. /**
  76322. * Renders the particle system in its current state.
  76323. * @returns the current number of particles
  76324. */
  76325. render(): number;
  76326. /**
  76327. * Dispose the particle system and frees its associated resources.
  76328. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76329. */
  76330. dispose(disposeTexture?: boolean): void;
  76331. /**
  76332. * Clones the particle system.
  76333. * @param name The name of the cloned object
  76334. * @param newEmitter The new emitter to use
  76335. * @returns the cloned particle system
  76336. */
  76337. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76338. /**
  76339. * Serializes the particle system to a JSON object.
  76340. * @returns the JSON object
  76341. */
  76342. serialize(): any;
  76343. /**
  76344. * Rebuild the particle system
  76345. */
  76346. rebuild(): void;
  76347. /**
  76348. * Starts the particle system and begins to emit
  76349. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76350. */
  76351. start(delay?: number): void;
  76352. /**
  76353. * Stops the particle system.
  76354. */
  76355. stop(): void;
  76356. /**
  76357. * Remove all active particles
  76358. */
  76359. reset(): void;
  76360. /**
  76361. * Is this system ready to be used/rendered
  76362. * @return true if the system is ready
  76363. */
  76364. isReady(): boolean;
  76365. /**
  76366. * Adds a new color gradient
  76367. * @param gradient defines the gradient to use (between 0 and 1)
  76368. * @param color1 defines the color to affect to the specified gradient
  76369. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76370. * @returns the current particle system
  76371. */
  76372. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76373. /**
  76374. * Remove a specific color gradient
  76375. * @param gradient defines the gradient to remove
  76376. * @returns the current particle system
  76377. */
  76378. removeColorGradient(gradient: number): IParticleSystem;
  76379. /**
  76380. * Adds a new size gradient
  76381. * @param gradient defines the gradient to use (between 0 and 1)
  76382. * @param factor defines the size factor to affect to the specified gradient
  76383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76384. * @returns the current particle system
  76385. */
  76386. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76387. /**
  76388. * Remove a specific size gradient
  76389. * @param gradient defines the gradient to remove
  76390. * @returns the current particle system
  76391. */
  76392. removeSizeGradient(gradient: number): IParticleSystem;
  76393. /**
  76394. * Gets the current list of color gradients.
  76395. * You must use addColorGradient and removeColorGradient to udpate this list
  76396. * @returns the list of color gradients
  76397. */
  76398. getColorGradients(): Nullable<Array<ColorGradient>>;
  76399. /**
  76400. * Gets the current list of size gradients.
  76401. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76402. * @returns the list of size gradients
  76403. */
  76404. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76405. /**
  76406. * Gets the current list of angular speed gradients.
  76407. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76408. * @returns the list of angular speed gradients
  76409. */
  76410. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76411. /**
  76412. * Adds a new angular speed gradient
  76413. * @param gradient defines the gradient to use (between 0 and 1)
  76414. * @param factor defines the angular speed to affect to the specified gradient
  76415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76416. * @returns the current particle system
  76417. */
  76418. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76419. /**
  76420. * Remove a specific angular speed gradient
  76421. * @param gradient defines the gradient to remove
  76422. * @returns the current particle system
  76423. */
  76424. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76425. /**
  76426. * Gets the current list of velocity gradients.
  76427. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76428. * @returns the list of velocity gradients
  76429. */
  76430. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76431. /**
  76432. * Adds a new velocity gradient
  76433. * @param gradient defines the gradient to use (between 0 and 1)
  76434. * @param factor defines the velocity to affect to the specified gradient
  76435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76436. * @returns the current particle system
  76437. */
  76438. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76439. /**
  76440. * Remove a specific velocity gradient
  76441. * @param gradient defines the gradient to remove
  76442. * @returns the current particle system
  76443. */
  76444. removeVelocityGradient(gradient: number): IParticleSystem;
  76445. /**
  76446. * Gets the current list of limit velocity gradients.
  76447. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76448. * @returns the list of limit velocity gradients
  76449. */
  76450. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76451. /**
  76452. * Adds a new limit velocity gradient
  76453. * @param gradient defines the gradient to use (between 0 and 1)
  76454. * @param factor defines the limit velocity to affect to the specified gradient
  76455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76456. * @returns the current particle system
  76457. */
  76458. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76459. /**
  76460. * Remove a specific limit velocity gradient
  76461. * @param gradient defines the gradient to remove
  76462. * @returns the current particle system
  76463. */
  76464. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76465. /**
  76466. * Adds a new drag gradient
  76467. * @param gradient defines the gradient to use (between 0 and 1)
  76468. * @param factor defines the drag to affect to the specified gradient
  76469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76470. * @returns the current particle system
  76471. */
  76472. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76473. /**
  76474. * Remove a specific drag gradient
  76475. * @param gradient defines the gradient to remove
  76476. * @returns the current particle system
  76477. */
  76478. removeDragGradient(gradient: number): IParticleSystem;
  76479. /**
  76480. * Gets the current list of drag gradients.
  76481. * You must use addDragGradient and removeDragGradient to udpate this list
  76482. * @returns the list of drag gradients
  76483. */
  76484. getDragGradients(): Nullable<Array<FactorGradient>>;
  76485. /**
  76486. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76487. * @param gradient defines the gradient to use (between 0 and 1)
  76488. * @param factor defines the emit rate to affect to the specified gradient
  76489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76490. * @returns the current particle system
  76491. */
  76492. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76493. /**
  76494. * Remove a specific emit rate gradient
  76495. * @param gradient defines the gradient to remove
  76496. * @returns the current particle system
  76497. */
  76498. removeEmitRateGradient(gradient: number): IParticleSystem;
  76499. /**
  76500. * Gets the current list of emit rate gradients.
  76501. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76502. * @returns the list of emit rate gradients
  76503. */
  76504. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76505. /**
  76506. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76507. * @param gradient defines the gradient to use (between 0 and 1)
  76508. * @param factor defines the start size to affect to the specified gradient
  76509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76510. * @returns the current particle system
  76511. */
  76512. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76513. /**
  76514. * Remove a specific start size gradient
  76515. * @param gradient defines the gradient to remove
  76516. * @returns the current particle system
  76517. */
  76518. removeStartSizeGradient(gradient: number): IParticleSystem;
  76519. /**
  76520. * Gets the current list of start size gradients.
  76521. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76522. * @returns the list of start size gradients
  76523. */
  76524. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76525. /**
  76526. * Adds a new life time gradient
  76527. * @param gradient defines the gradient to use (between 0 and 1)
  76528. * @param factor defines the life time factor to affect to the specified gradient
  76529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76530. * @returns the current particle system
  76531. */
  76532. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76533. /**
  76534. * Remove a specific life time gradient
  76535. * @param gradient defines the gradient to remove
  76536. * @returns the current particle system
  76537. */
  76538. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76539. /**
  76540. * Gets the current list of life time gradients.
  76541. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76542. * @returns the list of life time gradients
  76543. */
  76544. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76545. /**
  76546. * Gets the current list of color gradients.
  76547. * You must use addColorGradient and removeColorGradient to udpate this list
  76548. * @returns the list of color gradients
  76549. */
  76550. getColorGradients(): Nullable<Array<ColorGradient>>;
  76551. /**
  76552. * Adds a new ramp gradient used to remap particle colors
  76553. * @param gradient defines the gradient to use (between 0 and 1)
  76554. * @param color defines the color to affect to the specified gradient
  76555. * @returns the current particle system
  76556. */
  76557. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76558. /**
  76559. * Gets the current list of ramp gradients.
  76560. * You must use addRampGradient and removeRampGradient to udpate this list
  76561. * @returns the list of ramp gradients
  76562. */
  76563. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76564. /** Gets or sets a boolean indicating that ramp gradients must be used
  76565. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76566. */
  76567. useRampGradients: boolean;
  76568. /**
  76569. * Adds a new color remap gradient
  76570. * @param gradient defines the gradient to use (between 0 and 1)
  76571. * @param min defines the color remap minimal range
  76572. * @param max defines the color remap maximal range
  76573. * @returns the current particle system
  76574. */
  76575. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76576. /**
  76577. * Gets the current list of color remap gradients.
  76578. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76579. * @returns the list of color remap gradients
  76580. */
  76581. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76582. /**
  76583. * Adds a new alpha remap gradient
  76584. * @param gradient defines the gradient to use (between 0 and 1)
  76585. * @param min defines the alpha remap minimal range
  76586. * @param max defines the alpha remap maximal range
  76587. * @returns the current particle system
  76588. */
  76589. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76590. /**
  76591. * Gets the current list of alpha remap gradients.
  76592. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76593. * @returns the list of alpha remap gradients
  76594. */
  76595. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76596. /**
  76597. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76600. * @returns the emitter
  76601. */
  76602. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76603. /**
  76604. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76605. * @param radius The radius of the hemisphere to emit from
  76606. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76607. * @returns the emitter
  76608. */
  76609. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76610. /**
  76611. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76612. * @param radius The radius of the sphere to emit from
  76613. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76614. * @returns the emitter
  76615. */
  76616. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76617. /**
  76618. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76619. * @param radius The radius of the sphere to emit from
  76620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76622. * @returns the emitter
  76623. */
  76624. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76625. /**
  76626. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76627. * @param radius The radius of the emission cylinder
  76628. * @param height The height of the emission cylinder
  76629. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76630. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76631. * @returns the emitter
  76632. */
  76633. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76634. /**
  76635. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76636. * @param radius The radius of the cylinder to emit from
  76637. * @param height The height of the emission cylinder
  76638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76641. * @returns the emitter
  76642. */
  76643. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76644. /**
  76645. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76646. * @param radius The radius of the cone to emit from
  76647. * @param angle The base angle of the cone
  76648. * @returns the emitter
  76649. */
  76650. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76651. /**
  76652. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76655. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76656. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76657. * @returns the emitter
  76658. */
  76659. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76660. /**
  76661. * Get hosting scene
  76662. * @returns the scene
  76663. */
  76664. getScene(): Scene;
  76665. }
  76666. }
  76667. declare module BABYLON {
  76668. /**
  76669. * Creates an instance based on a source mesh.
  76670. */
  76671. export class InstancedMesh extends AbstractMesh {
  76672. private _sourceMesh;
  76673. private _currentLOD;
  76674. /** @hidden */
  76675. _indexInSourceMeshInstanceArray: number;
  76676. constructor(name: string, source: Mesh);
  76677. /**
  76678. * Returns the string "InstancedMesh".
  76679. */
  76680. getClassName(): string;
  76681. /** Gets the list of lights affecting that mesh */
  76682. readonly lightSources: Light[];
  76683. _resyncLightSources(): void;
  76684. _resyncLighSource(light: Light): void;
  76685. _removeLightSource(light: Light): void;
  76686. /**
  76687. * If the source mesh receives shadows
  76688. */
  76689. readonly receiveShadows: boolean;
  76690. /**
  76691. * The material of the source mesh
  76692. */
  76693. readonly material: Nullable<Material>;
  76694. /**
  76695. * Visibility of the source mesh
  76696. */
  76697. readonly visibility: number;
  76698. /**
  76699. * Skeleton of the source mesh
  76700. */
  76701. readonly skeleton: Nullable<Skeleton>;
  76702. /**
  76703. * Rendering ground id of the source mesh
  76704. */
  76705. renderingGroupId: number;
  76706. /**
  76707. * Returns the total number of vertices (integer).
  76708. */
  76709. getTotalVertices(): number;
  76710. /**
  76711. * Returns a positive integer : the total number of indices in this mesh geometry.
  76712. * @returns the numner of indices or zero if the mesh has no geometry.
  76713. */
  76714. getTotalIndices(): number;
  76715. /**
  76716. * The source mesh of the instance
  76717. */
  76718. readonly sourceMesh: Mesh;
  76719. /**
  76720. * Is this node ready to be used/rendered
  76721. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76722. * @return {boolean} is it ready
  76723. */
  76724. isReady(completeCheck?: boolean): boolean;
  76725. /**
  76726. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76727. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76728. * @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.
  76729. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76730. */
  76731. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76732. /**
  76733. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76734. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76735. * The `data` are either a numeric array either a Float32Array.
  76736. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76737. * 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).
  76738. * Note that a new underlying VertexBuffer object is created each call.
  76739. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76740. *
  76741. * Possible `kind` values :
  76742. * - VertexBuffer.PositionKind
  76743. * - VertexBuffer.UVKind
  76744. * - VertexBuffer.UV2Kind
  76745. * - VertexBuffer.UV3Kind
  76746. * - VertexBuffer.UV4Kind
  76747. * - VertexBuffer.UV5Kind
  76748. * - VertexBuffer.UV6Kind
  76749. * - VertexBuffer.ColorKind
  76750. * - VertexBuffer.MatricesIndicesKind
  76751. * - VertexBuffer.MatricesIndicesExtraKind
  76752. * - VertexBuffer.MatricesWeightsKind
  76753. * - VertexBuffer.MatricesWeightsExtraKind
  76754. *
  76755. * Returns the Mesh.
  76756. */
  76757. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76758. /**
  76759. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76760. * If the mesh has no geometry, it is simply returned as it is.
  76761. * The `data` are either a numeric array either a Float32Array.
  76762. * No new underlying VertexBuffer object is created.
  76763. * 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.
  76764. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76765. *
  76766. * Possible `kind` values :
  76767. * - VertexBuffer.PositionKind
  76768. * - VertexBuffer.UVKind
  76769. * - VertexBuffer.UV2Kind
  76770. * - VertexBuffer.UV3Kind
  76771. * - VertexBuffer.UV4Kind
  76772. * - VertexBuffer.UV5Kind
  76773. * - VertexBuffer.UV6Kind
  76774. * - VertexBuffer.ColorKind
  76775. * - VertexBuffer.MatricesIndicesKind
  76776. * - VertexBuffer.MatricesIndicesExtraKind
  76777. * - VertexBuffer.MatricesWeightsKind
  76778. * - VertexBuffer.MatricesWeightsExtraKind
  76779. *
  76780. * Returns the Mesh.
  76781. */
  76782. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76783. /**
  76784. * Sets the mesh indices.
  76785. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76786. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76787. * This method creates a new index buffer each call.
  76788. * Returns the Mesh.
  76789. */
  76790. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76791. /**
  76792. * Boolean : True if the mesh owns the requested kind of data.
  76793. */
  76794. isVerticesDataPresent(kind: string): boolean;
  76795. /**
  76796. * Returns an array of indices (IndicesArray).
  76797. */
  76798. getIndices(): Nullable<IndicesArray>;
  76799. readonly _positions: Nullable<Vector3[]>;
  76800. /**
  76801. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76802. * This means the mesh underlying bounding box and sphere are recomputed.
  76803. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76804. * @returns the current mesh
  76805. */
  76806. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76807. /** @hidden */
  76808. _preActivate(): InstancedMesh;
  76809. /** @hidden */
  76810. _activate(renderId: number): boolean;
  76811. /** @hidden */
  76812. _postActivate(): void;
  76813. getWorldMatrix(): Matrix;
  76814. readonly isAnInstance: boolean;
  76815. /**
  76816. * Returns the current associated LOD AbstractMesh.
  76817. */
  76818. getLOD(camera: Camera): AbstractMesh;
  76819. /** @hidden */
  76820. _syncSubMeshes(): InstancedMesh;
  76821. /** @hidden */
  76822. _generatePointsArray(): boolean;
  76823. /**
  76824. * Creates a new InstancedMesh from the current mesh.
  76825. * - name (string) : the cloned mesh name
  76826. * - newParent (optional Node) : the optional Node to parent the clone to.
  76827. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76828. *
  76829. * Returns the clone.
  76830. */
  76831. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76832. /**
  76833. * Disposes the InstancedMesh.
  76834. * Returns nothing.
  76835. */
  76836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76837. }
  76838. }
  76839. declare module BABYLON {
  76840. /**
  76841. * Defines the options associated with the creation of a shader material.
  76842. */
  76843. export interface IShaderMaterialOptions {
  76844. /**
  76845. * Does the material work in alpha blend mode
  76846. */
  76847. needAlphaBlending: boolean;
  76848. /**
  76849. * Does the material work in alpha test mode
  76850. */
  76851. needAlphaTesting: boolean;
  76852. /**
  76853. * The list of attribute names used in the shader
  76854. */
  76855. attributes: string[];
  76856. /**
  76857. * The list of unifrom names used in the shader
  76858. */
  76859. uniforms: string[];
  76860. /**
  76861. * The list of UBO names used in the shader
  76862. */
  76863. uniformBuffers: string[];
  76864. /**
  76865. * The list of sampler names used in the shader
  76866. */
  76867. samplers: string[];
  76868. /**
  76869. * The list of defines used in the shader
  76870. */
  76871. defines: string[];
  76872. }
  76873. /**
  76874. * 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.
  76875. *
  76876. * This returned material effects how the mesh will look based on the code in the shaders.
  76877. *
  76878. * @see http://doc.babylonjs.com/how_to/shader_material
  76879. */
  76880. export class ShaderMaterial extends Material {
  76881. private _shaderPath;
  76882. private _options;
  76883. private _textures;
  76884. private _textureArrays;
  76885. private _floats;
  76886. private _ints;
  76887. private _floatsArrays;
  76888. private _colors3;
  76889. private _colors3Arrays;
  76890. private _colors4;
  76891. private _vectors2;
  76892. private _vectors3;
  76893. private _vectors4;
  76894. private _matrices;
  76895. private _matrices3x3;
  76896. private _matrices2x2;
  76897. private _vectors2Arrays;
  76898. private _vectors3Arrays;
  76899. private _cachedWorldViewMatrix;
  76900. private _renderId;
  76901. /**
  76902. * Instantiate a new shader material.
  76903. * 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.
  76904. * This returned material effects how the mesh will look based on the code in the shaders.
  76905. * @see http://doc.babylonjs.com/how_to/shader_material
  76906. * @param name Define the name of the material in the scene
  76907. * @param scene Define the scene the material belongs to
  76908. * @param shaderPath Defines the route to the shader code in one of three ways:
  76909. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76910. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76911. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76912. * @param options Define the options used to create the shader
  76913. */
  76914. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76915. /**
  76916. * Gets the options used to compile the shader.
  76917. * They can be modified to trigger a new compilation
  76918. */
  76919. readonly options: IShaderMaterialOptions;
  76920. /**
  76921. * Gets the current class name of the material e.g. "ShaderMaterial"
  76922. * Mainly use in serialization.
  76923. * @returns the class name
  76924. */
  76925. getClassName(): string;
  76926. /**
  76927. * Specifies if the material will require alpha blending
  76928. * @returns a boolean specifying if alpha blending is needed
  76929. */
  76930. needAlphaBlending(): boolean;
  76931. /**
  76932. * Specifies if this material should be rendered in alpha test mode
  76933. * @returns a boolean specifying if an alpha test is needed.
  76934. */
  76935. needAlphaTesting(): boolean;
  76936. private _checkUniform;
  76937. /**
  76938. * Set a texture in the shader.
  76939. * @param name Define the name of the uniform samplers as defined in the shader
  76940. * @param texture Define the texture to bind to this sampler
  76941. * @return the material itself allowing "fluent" like uniform updates
  76942. */
  76943. setTexture(name: string, texture: Texture): ShaderMaterial;
  76944. /**
  76945. * Set a texture array in the shader.
  76946. * @param name Define the name of the uniform sampler array as defined in the shader
  76947. * @param textures Define the list of textures to bind to this sampler
  76948. * @return the material itself allowing "fluent" like uniform updates
  76949. */
  76950. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76951. /**
  76952. * Set a float in the shader.
  76953. * @param name Define the name of the uniform as defined in the shader
  76954. * @param value Define the value to give to the uniform
  76955. * @return the material itself allowing "fluent" like uniform updates
  76956. */
  76957. setFloat(name: string, value: number): ShaderMaterial;
  76958. /**
  76959. * Set a int in the shader.
  76960. * @param name Define the name of the uniform as defined in the shader
  76961. * @param value Define the value to give to the uniform
  76962. * @return the material itself allowing "fluent" like uniform updates
  76963. */
  76964. setInt(name: string, value: number): ShaderMaterial;
  76965. /**
  76966. * Set an array of floats in the shader.
  76967. * @param name Define the name of the uniform as defined in the shader
  76968. * @param value Define the value to give to the uniform
  76969. * @return the material itself allowing "fluent" like uniform updates
  76970. */
  76971. setFloats(name: string, value: number[]): ShaderMaterial;
  76972. /**
  76973. * Set a vec3 in the shader from a Color3.
  76974. * @param name Define the name of the uniform as defined in the shader
  76975. * @param value Define the value to give to the uniform
  76976. * @return the material itself allowing "fluent" like uniform updates
  76977. */
  76978. setColor3(name: string, value: Color3): ShaderMaterial;
  76979. /**
  76980. * Set a vec3 array in the shader from a Color3 array.
  76981. * @param name Define the name of the uniform as defined in the shader
  76982. * @param value Define the value to give to the uniform
  76983. * @return the material itself allowing "fluent" like uniform updates
  76984. */
  76985. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76986. /**
  76987. * Set a vec4 in the shader from a Color4.
  76988. * @param name Define the name of the uniform as defined in the shader
  76989. * @param value Define the value to give to the uniform
  76990. * @return the material itself allowing "fluent" like uniform updates
  76991. */
  76992. setColor4(name: string, value: Color4): ShaderMaterial;
  76993. /**
  76994. * Set a vec2 in the shader from a Vector2.
  76995. * @param name Define the name of the uniform as defined in the shader
  76996. * @param value Define the value to give to the uniform
  76997. * @return the material itself allowing "fluent" like uniform updates
  76998. */
  76999. setVector2(name: string, value: Vector2): ShaderMaterial;
  77000. /**
  77001. * Set a vec3 in the shader from a Vector3.
  77002. * @param name Define the name of the uniform as defined in the shader
  77003. * @param value Define the value to give to the uniform
  77004. * @return the material itself allowing "fluent" like uniform updates
  77005. */
  77006. setVector3(name: string, value: Vector3): ShaderMaterial;
  77007. /**
  77008. * Set a vec4 in the shader from a Vector4.
  77009. * @param name Define the name of the uniform as defined in the shader
  77010. * @param value Define the value to give to the uniform
  77011. * @return the material itself allowing "fluent" like uniform updates
  77012. */
  77013. setVector4(name: string, value: Vector4): ShaderMaterial;
  77014. /**
  77015. * Set a mat4 in the shader from a Matrix.
  77016. * @param name Define the name of the uniform as defined in the shader
  77017. * @param value Define the value to give to the uniform
  77018. * @return the material itself allowing "fluent" like uniform updates
  77019. */
  77020. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77021. /**
  77022. * Set a mat3 in the shader from a Float32Array.
  77023. * @param name Define the name of the uniform as defined in the shader
  77024. * @param value Define the value to give to the uniform
  77025. * @return the material itself allowing "fluent" like uniform updates
  77026. */
  77027. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77028. /**
  77029. * Set a mat2 in the shader from a Float32Array.
  77030. * @param name Define the name of the uniform as defined in the shader
  77031. * @param value Define the value to give to the uniform
  77032. * @return the material itself allowing "fluent" like uniform updates
  77033. */
  77034. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77035. /**
  77036. * Set a vec2 array in the shader from a number array.
  77037. * @param name Define the name of the uniform as defined in the shader
  77038. * @param value Define the value to give to the uniform
  77039. * @return the material itself allowing "fluent" like uniform updates
  77040. */
  77041. setArray2(name: string, value: number[]): ShaderMaterial;
  77042. /**
  77043. * Set a vec3 array in the shader from a number array.
  77044. * @param name Define the name of the uniform as defined in the shader
  77045. * @param value Define the value to give to the uniform
  77046. * @return the material itself allowing "fluent" like uniform updates
  77047. */
  77048. setArray3(name: string, value: number[]): ShaderMaterial;
  77049. private _checkCache;
  77050. /**
  77051. * Specifies that the submesh is ready to be used
  77052. * @param mesh defines the mesh to check
  77053. * @param subMesh defines which submesh to check
  77054. * @param useInstances specifies that instances should be used
  77055. * @returns a boolean indicating that the submesh is ready or not
  77056. */
  77057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77058. /**
  77059. * Checks if the material is ready to render the requested mesh
  77060. * @param mesh Define the mesh to render
  77061. * @param useInstances Define whether or not the material is used with instances
  77062. * @returns true if ready, otherwise false
  77063. */
  77064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77065. /**
  77066. * Binds the world matrix to the material
  77067. * @param world defines the world transformation matrix
  77068. */
  77069. bindOnlyWorldMatrix(world: Matrix): void;
  77070. /**
  77071. * Binds the material to the mesh
  77072. * @param world defines the world transformation matrix
  77073. * @param mesh defines the mesh to bind the material to
  77074. */
  77075. bind(world: Matrix, mesh?: Mesh): void;
  77076. /**
  77077. * Gets the active textures from the material
  77078. * @returns an array of textures
  77079. */
  77080. getActiveTextures(): BaseTexture[];
  77081. /**
  77082. * Specifies if the material uses a texture
  77083. * @param texture defines the texture to check against the material
  77084. * @returns a boolean specifying if the material uses the texture
  77085. */
  77086. hasTexture(texture: BaseTexture): boolean;
  77087. /**
  77088. * Makes a duplicate of the material, and gives it a new name
  77089. * @param name defines the new name for the duplicated material
  77090. * @returns the cloned material
  77091. */
  77092. clone(name: string): ShaderMaterial;
  77093. /**
  77094. * Disposes the material
  77095. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77096. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77097. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77098. */
  77099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77100. /**
  77101. * Serializes this material in a JSON representation
  77102. * @returns the serialized material object
  77103. */
  77104. serialize(): any;
  77105. /**
  77106. * Creates a shader material from parsed shader material data
  77107. * @param source defines the JSON represnetation of the material
  77108. * @param scene defines the hosting scene
  77109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77110. * @returns a new material
  77111. */
  77112. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77113. }
  77114. }
  77115. declare module BABYLON {
  77116. /** @hidden */
  77117. export var colorPixelShader: {
  77118. name: string;
  77119. shader: string;
  77120. };
  77121. }
  77122. declare module BABYLON {
  77123. /** @hidden */
  77124. export var colorVertexShader: {
  77125. name: string;
  77126. shader: string;
  77127. };
  77128. }
  77129. declare module BABYLON {
  77130. /**
  77131. * Line mesh
  77132. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77133. */
  77134. export class LinesMesh extends Mesh {
  77135. /**
  77136. * If vertex color should be applied to the mesh
  77137. */
  77138. useVertexColor?: boolean | undefined;
  77139. /**
  77140. * If vertex alpha should be applied to the mesh
  77141. */
  77142. useVertexAlpha?: boolean | undefined;
  77143. /**
  77144. * Color of the line (Default: White)
  77145. */
  77146. color: Color3;
  77147. /**
  77148. * Alpha of the line (Default: 1)
  77149. */
  77150. alpha: number;
  77151. /**
  77152. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77153. * This margin is expressed in world space coordinates, so its value may vary.
  77154. * Default value is 0.1
  77155. */
  77156. intersectionThreshold: number;
  77157. private _colorShader;
  77158. /**
  77159. * Creates a new LinesMesh
  77160. * @param name defines the name
  77161. * @param scene defines the hosting scene
  77162. * @param parent defines the parent mesh if any
  77163. * @param source defines the optional source LinesMesh used to clone data from
  77164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77165. * When false, achieved by calling a clone(), also passing False.
  77166. * This will make creation of children, recursive.
  77167. * @param useVertexColor defines if this LinesMesh supports vertex color
  77168. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77169. */
  77170. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77171. /**
  77172. * If vertex color should be applied to the mesh
  77173. */
  77174. useVertexColor?: boolean | undefined,
  77175. /**
  77176. * If vertex alpha should be applied to the mesh
  77177. */
  77178. useVertexAlpha?: boolean | undefined);
  77179. private _addClipPlaneDefine;
  77180. private _removeClipPlaneDefine;
  77181. isReady(): boolean;
  77182. /**
  77183. * Returns the string "LineMesh"
  77184. */
  77185. getClassName(): string;
  77186. /**
  77187. * @hidden
  77188. */
  77189. /**
  77190. * @hidden
  77191. */
  77192. material: Material;
  77193. /**
  77194. * @hidden
  77195. */
  77196. readonly checkCollisions: boolean;
  77197. /** @hidden */
  77198. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77199. /** @hidden */
  77200. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77201. /**
  77202. * Disposes of the line mesh
  77203. * @param doNotRecurse If children should be disposed
  77204. */
  77205. dispose(doNotRecurse?: boolean): void;
  77206. /**
  77207. * Returns a new LineMesh object cloned from the current one.
  77208. */
  77209. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77210. /**
  77211. * Creates a new InstancedLinesMesh object from the mesh model.
  77212. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77213. * @param name defines the name of the new instance
  77214. * @returns a new InstancedLinesMesh
  77215. */
  77216. createInstance(name: string): InstancedLinesMesh;
  77217. }
  77218. /**
  77219. * Creates an instance based on a source LinesMesh
  77220. */
  77221. export class InstancedLinesMesh extends InstancedMesh {
  77222. /**
  77223. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77224. * This margin is expressed in world space coordinates, so its value may vary.
  77225. * Initilized with the intersectionThreshold value of the source LinesMesh
  77226. */
  77227. intersectionThreshold: number;
  77228. constructor(name: string, source: LinesMesh);
  77229. /**
  77230. * Returns the string "InstancedLinesMesh".
  77231. */
  77232. getClassName(): string;
  77233. }
  77234. }
  77235. declare module BABYLON {
  77236. /** @hidden */
  77237. export var linePixelShader: {
  77238. name: string;
  77239. shader: string;
  77240. };
  77241. }
  77242. declare module BABYLON {
  77243. /** @hidden */
  77244. export var lineVertexShader: {
  77245. name: string;
  77246. shader: string;
  77247. };
  77248. }
  77249. declare module BABYLON {
  77250. interface AbstractMesh {
  77251. /**
  77252. * Disables the mesh edge rendering mode
  77253. * @returns the currentAbstractMesh
  77254. */
  77255. disableEdgesRendering(): AbstractMesh;
  77256. /**
  77257. * Enables the edge rendering mode on the mesh.
  77258. * This mode makes the mesh edges visible
  77259. * @param epsilon defines the maximal distance between two angles to detect a face
  77260. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77261. * @returns the currentAbstractMesh
  77262. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77263. */
  77264. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77265. /**
  77266. * Gets the edgesRenderer associated with the mesh
  77267. */
  77268. edgesRenderer: Nullable<EdgesRenderer>;
  77269. }
  77270. interface LinesMesh {
  77271. /**
  77272. * Enables the edge rendering mode on the mesh.
  77273. * This mode makes the mesh edges visible
  77274. * @param epsilon defines the maximal distance between two angles to detect a face
  77275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77276. * @returns the currentAbstractMesh
  77277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77278. */
  77279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77280. }
  77281. interface InstancedLinesMesh {
  77282. /**
  77283. * Enables the edge rendering mode on the mesh.
  77284. * This mode makes the mesh edges visible
  77285. * @param epsilon defines the maximal distance between two angles to detect a face
  77286. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77287. * @returns the current InstancedLinesMesh
  77288. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77289. */
  77290. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77291. }
  77292. /**
  77293. * Defines the minimum contract an Edges renderer should follow.
  77294. */
  77295. export interface IEdgesRenderer extends IDisposable {
  77296. /**
  77297. * Gets or sets a boolean indicating if the edgesRenderer is active
  77298. */
  77299. isEnabled: boolean;
  77300. /**
  77301. * Renders the edges of the attached mesh,
  77302. */
  77303. render(): void;
  77304. /**
  77305. * Checks wether or not the edges renderer is ready to render.
  77306. * @return true if ready, otherwise false.
  77307. */
  77308. isReady(): boolean;
  77309. }
  77310. /**
  77311. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77312. */
  77313. export class EdgesRenderer implements IEdgesRenderer {
  77314. /**
  77315. * Define the size of the edges with an orthographic camera
  77316. */
  77317. edgesWidthScalerForOrthographic: number;
  77318. /**
  77319. * Define the size of the edges with a perspective camera
  77320. */
  77321. edgesWidthScalerForPerspective: number;
  77322. protected _source: AbstractMesh;
  77323. protected _linesPositions: number[];
  77324. protected _linesNormals: number[];
  77325. protected _linesIndices: number[];
  77326. protected _epsilon: number;
  77327. protected _indicesCount: number;
  77328. protected _lineShader: ShaderMaterial;
  77329. protected _ib: DataBuffer;
  77330. protected _buffers: {
  77331. [key: string]: Nullable<VertexBuffer>;
  77332. };
  77333. protected _checkVerticesInsteadOfIndices: boolean;
  77334. private _meshRebuildObserver;
  77335. private _meshDisposeObserver;
  77336. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77337. isEnabled: boolean;
  77338. /**
  77339. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77340. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77341. * @param source Mesh used to create edges
  77342. * @param epsilon sum of angles in adjacency to check for edge
  77343. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77344. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77345. */
  77346. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77347. protected _prepareRessources(): void;
  77348. /** @hidden */
  77349. _rebuild(): void;
  77350. /**
  77351. * Releases the required resources for the edges renderer
  77352. */
  77353. dispose(): void;
  77354. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77355. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77356. /**
  77357. * Checks if the pair of p0 and p1 is en edge
  77358. * @param faceIndex
  77359. * @param edge
  77360. * @param faceNormals
  77361. * @param p0
  77362. * @param p1
  77363. * @private
  77364. */
  77365. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77366. /**
  77367. * push line into the position, normal and index buffer
  77368. * @protected
  77369. */
  77370. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77371. /**
  77372. * Generates lines edges from adjacencjes
  77373. * @private
  77374. */
  77375. _generateEdgesLines(): void;
  77376. /**
  77377. * Checks wether or not the edges renderer is ready to render.
  77378. * @return true if ready, otherwise false.
  77379. */
  77380. isReady(): boolean;
  77381. /**
  77382. * Renders the edges of the attached mesh,
  77383. */
  77384. render(): void;
  77385. }
  77386. /**
  77387. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77388. */
  77389. export class LineEdgesRenderer extends EdgesRenderer {
  77390. /**
  77391. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77392. * @param source LineMesh used to generate edges
  77393. * @param epsilon not important (specified angle for edge detection)
  77394. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77395. */
  77396. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77397. /**
  77398. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77399. */
  77400. _generateEdgesLines(): void;
  77401. }
  77402. }
  77403. declare module BABYLON {
  77404. /**
  77405. * This represents the object necessary to create a rendering group.
  77406. * This is exclusively used and created by the rendering manager.
  77407. * To modify the behavior, you use the available helpers in your scene or meshes.
  77408. * @hidden
  77409. */
  77410. export class RenderingGroup {
  77411. index: number;
  77412. private _scene;
  77413. private _opaqueSubMeshes;
  77414. private _transparentSubMeshes;
  77415. private _alphaTestSubMeshes;
  77416. private _depthOnlySubMeshes;
  77417. private _particleSystems;
  77418. private _spriteManagers;
  77419. private _opaqueSortCompareFn;
  77420. private _alphaTestSortCompareFn;
  77421. private _transparentSortCompareFn;
  77422. private _renderOpaque;
  77423. private _renderAlphaTest;
  77424. private _renderTransparent;
  77425. /** @hidden */
  77426. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77427. onBeforeTransparentRendering: () => void;
  77428. /**
  77429. * Set the opaque sort comparison function.
  77430. * If null the sub meshes will be render in the order they were created
  77431. */
  77432. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77433. /**
  77434. * Set the alpha test sort comparison function.
  77435. * If null the sub meshes will be render in the order they were created
  77436. */
  77437. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77438. /**
  77439. * Set the transparent sort comparison function.
  77440. * If null the sub meshes will be render in the order they were created
  77441. */
  77442. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77443. /**
  77444. * Creates a new rendering group.
  77445. * @param index The rendering group index
  77446. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77447. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77448. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77449. */
  77450. 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>);
  77451. /**
  77452. * Render all the sub meshes contained in the group.
  77453. * @param customRenderFunction Used to override the default render behaviour of the group.
  77454. * @returns true if rendered some submeshes.
  77455. */
  77456. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77457. /**
  77458. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77459. * @param subMeshes The submeshes to render
  77460. */
  77461. private renderOpaqueSorted;
  77462. /**
  77463. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77464. * @param subMeshes The submeshes to render
  77465. */
  77466. private renderAlphaTestSorted;
  77467. /**
  77468. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77469. * @param subMeshes The submeshes to render
  77470. */
  77471. private renderTransparentSorted;
  77472. /**
  77473. * Renders the submeshes in a specified order.
  77474. * @param subMeshes The submeshes to sort before render
  77475. * @param sortCompareFn The comparison function use to sort
  77476. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77477. * @param transparent Specifies to activate blending if true
  77478. */
  77479. private static renderSorted;
  77480. /**
  77481. * Renders the submeshes in the order they were dispatched (no sort applied).
  77482. * @param subMeshes The submeshes to render
  77483. */
  77484. private static renderUnsorted;
  77485. /**
  77486. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77487. * are rendered back to front if in the same alpha index.
  77488. *
  77489. * @param a The first submesh
  77490. * @param b The second submesh
  77491. * @returns The result of the comparison
  77492. */
  77493. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77494. /**
  77495. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77496. * are rendered back to front.
  77497. *
  77498. * @param a The first submesh
  77499. * @param b The second submesh
  77500. * @returns The result of the comparison
  77501. */
  77502. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77503. /**
  77504. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77505. * are rendered front to back (prevent overdraw).
  77506. *
  77507. * @param a The first submesh
  77508. * @param b The second submesh
  77509. * @returns The result of the comparison
  77510. */
  77511. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77512. /**
  77513. * Resets the different lists of submeshes to prepare a new frame.
  77514. */
  77515. prepare(): void;
  77516. dispose(): void;
  77517. /**
  77518. * Inserts the submesh in its correct queue depending on its material.
  77519. * @param subMesh The submesh to dispatch
  77520. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77521. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77522. */
  77523. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77524. dispatchSprites(spriteManager: ISpriteManager): void;
  77525. dispatchParticles(particleSystem: IParticleSystem): void;
  77526. private _renderParticles;
  77527. private _renderSprites;
  77528. }
  77529. }
  77530. declare module BABYLON {
  77531. /**
  77532. * Interface describing the different options available in the rendering manager
  77533. * regarding Auto Clear between groups.
  77534. */
  77535. export interface IRenderingManagerAutoClearSetup {
  77536. /**
  77537. * Defines whether or not autoclear is enable.
  77538. */
  77539. autoClear: boolean;
  77540. /**
  77541. * Defines whether or not to autoclear the depth buffer.
  77542. */
  77543. depth: boolean;
  77544. /**
  77545. * Defines whether or not to autoclear the stencil buffer.
  77546. */
  77547. stencil: boolean;
  77548. }
  77549. /**
  77550. * This class is used by the onRenderingGroupObservable
  77551. */
  77552. export class RenderingGroupInfo {
  77553. /**
  77554. * The Scene that being rendered
  77555. */
  77556. scene: Scene;
  77557. /**
  77558. * The camera currently used for the rendering pass
  77559. */
  77560. camera: Nullable<Camera>;
  77561. /**
  77562. * The ID of the renderingGroup being processed
  77563. */
  77564. renderingGroupId: number;
  77565. }
  77566. /**
  77567. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77568. * It is enable to manage the different groups as well as the different necessary sort functions.
  77569. * This should not be used directly aside of the few static configurations
  77570. */
  77571. export class RenderingManager {
  77572. /**
  77573. * The max id used for rendering groups (not included)
  77574. */
  77575. static MAX_RENDERINGGROUPS: number;
  77576. /**
  77577. * The min id used for rendering groups (included)
  77578. */
  77579. static MIN_RENDERINGGROUPS: number;
  77580. /**
  77581. * Used to globally prevent autoclearing scenes.
  77582. */
  77583. static AUTOCLEAR: boolean;
  77584. /**
  77585. * @hidden
  77586. */
  77587. _useSceneAutoClearSetup: boolean;
  77588. private _scene;
  77589. private _renderingGroups;
  77590. private _depthStencilBufferAlreadyCleaned;
  77591. private _autoClearDepthStencil;
  77592. private _customOpaqueSortCompareFn;
  77593. private _customAlphaTestSortCompareFn;
  77594. private _customTransparentSortCompareFn;
  77595. private _renderingGroupInfo;
  77596. /**
  77597. * Instantiates a new rendering group for a particular scene
  77598. * @param scene Defines the scene the groups belongs to
  77599. */
  77600. constructor(scene: Scene);
  77601. private _clearDepthStencilBuffer;
  77602. /**
  77603. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77604. * @hidden
  77605. */
  77606. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77607. /**
  77608. * Resets the different information of the group to prepare a new frame
  77609. * @hidden
  77610. */
  77611. reset(): void;
  77612. /**
  77613. * Dispose and release the group and its associated resources.
  77614. * @hidden
  77615. */
  77616. dispose(): void;
  77617. /**
  77618. * Clear the info related to rendering groups preventing retention points during dispose.
  77619. */
  77620. freeRenderingGroups(): void;
  77621. private _prepareRenderingGroup;
  77622. /**
  77623. * Add a sprite manager to the rendering manager in order to render it this frame.
  77624. * @param spriteManager Define the sprite manager to render
  77625. */
  77626. dispatchSprites(spriteManager: ISpriteManager): void;
  77627. /**
  77628. * Add a particle system to the rendering manager in order to render it this frame.
  77629. * @param particleSystem Define the particle system to render
  77630. */
  77631. dispatchParticles(particleSystem: IParticleSystem): void;
  77632. /**
  77633. * Add a submesh to the manager in order to render it this frame
  77634. * @param subMesh The submesh to dispatch
  77635. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77636. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77637. */
  77638. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77639. /**
  77640. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77641. * This allowed control for front to back rendering or reversly depending of the special needs.
  77642. *
  77643. * @param renderingGroupId The rendering group id corresponding to its index
  77644. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77645. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77646. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77647. */
  77648. 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;
  77649. /**
  77650. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77651. *
  77652. * @param renderingGroupId The rendering group id corresponding to its index
  77653. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77654. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77655. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77656. */
  77657. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77658. /**
  77659. * Gets the current auto clear configuration for one rendering group of the rendering
  77660. * manager.
  77661. * @param index the rendering group index to get the information for
  77662. * @returns The auto clear setup for the requested rendering group
  77663. */
  77664. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77665. }
  77666. }
  77667. declare module BABYLON {
  77668. /**
  77669. * This Helps creating a texture that will be created from a camera in your scene.
  77670. * It is basically a dynamic texture that could be used to create special effects for instance.
  77671. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77672. */
  77673. export class RenderTargetTexture extends Texture {
  77674. isCube: boolean;
  77675. /**
  77676. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77677. */
  77678. static readonly REFRESHRATE_RENDER_ONCE: number;
  77679. /**
  77680. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77681. */
  77682. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77683. /**
  77684. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77685. * the central point of your effect and can save a lot of performances.
  77686. */
  77687. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77688. /**
  77689. * Use this predicate to dynamically define the list of mesh you want to render.
  77690. * If set, the renderList property will be overwritten.
  77691. */
  77692. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77693. private _renderList;
  77694. /**
  77695. * Use this list to define the list of mesh you want to render.
  77696. */
  77697. renderList: Nullable<Array<AbstractMesh>>;
  77698. private _hookArray;
  77699. /**
  77700. * Define if particles should be rendered in your texture.
  77701. */
  77702. renderParticles: boolean;
  77703. /**
  77704. * Define if sprites should be rendered in your texture.
  77705. */
  77706. renderSprites: boolean;
  77707. /**
  77708. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77709. */
  77710. coordinatesMode: number;
  77711. /**
  77712. * Define the camera used to render the texture.
  77713. */
  77714. activeCamera: Nullable<Camera>;
  77715. /**
  77716. * Override the render function of the texture with your own one.
  77717. */
  77718. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77719. /**
  77720. * Define if camera post processes should be use while rendering the texture.
  77721. */
  77722. useCameraPostProcesses: boolean;
  77723. /**
  77724. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77725. */
  77726. ignoreCameraViewport: boolean;
  77727. private _postProcessManager;
  77728. private _postProcesses;
  77729. private _resizeObserver;
  77730. /**
  77731. * An event triggered when the texture is unbind.
  77732. */
  77733. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77734. /**
  77735. * An event triggered when the texture is unbind.
  77736. */
  77737. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77738. private _onAfterUnbindObserver;
  77739. /**
  77740. * Set a after unbind callback in the texture.
  77741. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77742. */
  77743. onAfterUnbind: () => void;
  77744. /**
  77745. * An event triggered before rendering the texture
  77746. */
  77747. onBeforeRenderObservable: Observable<number>;
  77748. private _onBeforeRenderObserver;
  77749. /**
  77750. * Set a before render callback in the texture.
  77751. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77752. */
  77753. onBeforeRender: (faceIndex: number) => void;
  77754. /**
  77755. * An event triggered after rendering the texture
  77756. */
  77757. onAfterRenderObservable: Observable<number>;
  77758. private _onAfterRenderObserver;
  77759. /**
  77760. * Set a after render callback in the texture.
  77761. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77762. */
  77763. onAfterRender: (faceIndex: number) => void;
  77764. /**
  77765. * An event triggered after the texture clear
  77766. */
  77767. onClearObservable: Observable<Engine>;
  77768. private _onClearObserver;
  77769. /**
  77770. * Set a clear callback in the texture.
  77771. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77772. */
  77773. onClear: (Engine: Engine) => void;
  77774. /**
  77775. * Define the clear color of the Render Target if it should be different from the scene.
  77776. */
  77777. clearColor: Color4;
  77778. protected _size: number | {
  77779. width: number;
  77780. height: number;
  77781. };
  77782. protected _initialSizeParameter: number | {
  77783. width: number;
  77784. height: number;
  77785. } | {
  77786. ratio: number;
  77787. };
  77788. protected _sizeRatio: Nullable<number>;
  77789. /** @hidden */
  77790. _generateMipMaps: boolean;
  77791. protected _renderingManager: RenderingManager;
  77792. /** @hidden */
  77793. _waitingRenderList: string[];
  77794. protected _doNotChangeAspectRatio: boolean;
  77795. protected _currentRefreshId: number;
  77796. protected _refreshRate: number;
  77797. protected _textureMatrix: Matrix;
  77798. protected _samples: number;
  77799. protected _renderTargetOptions: RenderTargetCreationOptions;
  77800. /**
  77801. * Gets render target creation options that were used.
  77802. */
  77803. readonly renderTargetOptions: RenderTargetCreationOptions;
  77804. protected _engine: Engine;
  77805. protected _onRatioRescale(): void;
  77806. /**
  77807. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77808. * It must define where the camera used to render the texture is set
  77809. */
  77810. boundingBoxPosition: Vector3;
  77811. private _boundingBoxSize;
  77812. /**
  77813. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77814. * When defined, the cubemap will switch to local mode
  77815. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77816. * @example https://www.babylonjs-playground.com/#RNASML
  77817. */
  77818. boundingBoxSize: Vector3;
  77819. /**
  77820. * In case the RTT has been created with a depth texture, get the associated
  77821. * depth texture.
  77822. * Otherwise, return null.
  77823. */
  77824. depthStencilTexture: Nullable<InternalTexture>;
  77825. /**
  77826. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77827. * or used a shadow, depth texture...
  77828. * @param name The friendly name of the texture
  77829. * @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)
  77830. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77831. * @param generateMipMaps True if mip maps need to be generated after render.
  77832. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77833. * @param type The type of the buffer in the RTT (int, half float, float...)
  77834. * @param isCube True if a cube texture needs to be created
  77835. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77836. * @param generateDepthBuffer True to generate a depth buffer
  77837. * @param generateStencilBuffer True to generate a stencil buffer
  77838. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77839. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77840. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77841. */
  77842. constructor(name: string, size: number | {
  77843. width: number;
  77844. height: number;
  77845. } | {
  77846. ratio: number;
  77847. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77848. /**
  77849. * Creates a depth stencil texture.
  77850. * This is only available in WebGL 2 or with the depth texture extension available.
  77851. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77852. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77853. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77854. */
  77855. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77856. private _processSizeParameter;
  77857. /**
  77858. * Define the number of samples to use in case of MSAA.
  77859. * It defaults to one meaning no MSAA has been enabled.
  77860. */
  77861. samples: number;
  77862. /**
  77863. * Resets the refresh counter of the texture and start bak from scratch.
  77864. * Could be useful to regenerate the texture if it is setup to render only once.
  77865. */
  77866. resetRefreshCounter(): void;
  77867. /**
  77868. * Define the refresh rate of the texture or the rendering frequency.
  77869. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77870. */
  77871. refreshRate: number;
  77872. /**
  77873. * Adds a post process to the render target rendering passes.
  77874. * @param postProcess define the post process to add
  77875. */
  77876. addPostProcess(postProcess: PostProcess): void;
  77877. /**
  77878. * Clear all the post processes attached to the render target
  77879. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77880. */
  77881. clearPostProcesses(dispose?: boolean): void;
  77882. /**
  77883. * Remove one of the post process from the list of attached post processes to the texture
  77884. * @param postProcess define the post process to remove from the list
  77885. */
  77886. removePostProcess(postProcess: PostProcess): void;
  77887. /** @hidden */
  77888. _shouldRender(): boolean;
  77889. /**
  77890. * Gets the actual render size of the texture.
  77891. * @returns the width of the render size
  77892. */
  77893. getRenderSize(): number;
  77894. /**
  77895. * Gets the actual render width of the texture.
  77896. * @returns the width of the render size
  77897. */
  77898. getRenderWidth(): number;
  77899. /**
  77900. * Gets the actual render height of the texture.
  77901. * @returns the height of the render size
  77902. */
  77903. getRenderHeight(): number;
  77904. /**
  77905. * Get if the texture can be rescaled or not.
  77906. */
  77907. readonly canRescale: boolean;
  77908. /**
  77909. * Resize the texture using a ratio.
  77910. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77911. */
  77912. scale(ratio: number): void;
  77913. /**
  77914. * Get the texture reflection matrix used to rotate/transform the reflection.
  77915. * @returns the reflection matrix
  77916. */
  77917. getReflectionTextureMatrix(): Matrix;
  77918. /**
  77919. * Resize the texture to a new desired size.
  77920. * Be carrefull as it will recreate all the data in the new texture.
  77921. * @param size Define the new size. It can be:
  77922. * - a number for squared texture,
  77923. * - an object containing { width: number, height: number }
  77924. * - or an object containing a ratio { ratio: number }
  77925. */
  77926. resize(size: number | {
  77927. width: number;
  77928. height: number;
  77929. } | {
  77930. ratio: number;
  77931. }): void;
  77932. /**
  77933. * Renders all the objects from the render list into the texture.
  77934. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77935. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77936. */
  77937. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77938. private _bestReflectionRenderTargetDimension;
  77939. /**
  77940. * @hidden
  77941. * @param faceIndex face index to bind to if this is a cubetexture
  77942. */
  77943. _bindFrameBuffer(faceIndex?: number): void;
  77944. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77945. private renderToTarget;
  77946. /**
  77947. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77948. * This allowed control for front to back rendering or reversly depending of the special needs.
  77949. *
  77950. * @param renderingGroupId The rendering group id corresponding to its index
  77951. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77952. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77953. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77954. */
  77955. 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;
  77956. /**
  77957. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77958. *
  77959. * @param renderingGroupId The rendering group id corresponding to its index
  77960. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77961. */
  77962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77963. /**
  77964. * Clones the texture.
  77965. * @returns the cloned texture
  77966. */
  77967. clone(): RenderTargetTexture;
  77968. /**
  77969. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77970. * @returns The JSON representation of the texture
  77971. */
  77972. serialize(): any;
  77973. /**
  77974. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77975. */
  77976. disposeFramebufferObjects(): void;
  77977. /**
  77978. * Dispose the texture and release its associated resources.
  77979. */
  77980. dispose(): void;
  77981. /** @hidden */
  77982. _rebuild(): void;
  77983. /**
  77984. * Clear the info related to rendering groups preventing retention point in material dispose.
  77985. */
  77986. freeRenderingGroups(): void;
  77987. /**
  77988. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77989. * @returns the view count
  77990. */
  77991. getViewCount(): number;
  77992. }
  77993. }
  77994. declare module BABYLON {
  77995. /**
  77996. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77997. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77998. * You can then easily use it as a reflectionTexture on a flat surface.
  77999. * In case the surface is not a plane, please consider relying on reflection probes.
  78000. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78001. */
  78002. export class MirrorTexture extends RenderTargetTexture {
  78003. private scene;
  78004. /**
  78005. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78006. * 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.
  78007. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78008. */
  78009. mirrorPlane: Plane;
  78010. /**
  78011. * Define the blur ratio used to blur the reflection if needed.
  78012. */
  78013. blurRatio: number;
  78014. /**
  78015. * Define the adaptive blur kernel used to blur the reflection if needed.
  78016. * This will autocompute the closest best match for the `blurKernel`
  78017. */
  78018. adaptiveBlurKernel: number;
  78019. /**
  78020. * Define the blur kernel used to blur the reflection if needed.
  78021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78022. */
  78023. blurKernel: number;
  78024. /**
  78025. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78027. */
  78028. blurKernelX: number;
  78029. /**
  78030. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78031. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78032. */
  78033. blurKernelY: number;
  78034. private _autoComputeBlurKernel;
  78035. protected _onRatioRescale(): void;
  78036. private _updateGammaSpace;
  78037. private _imageProcessingConfigChangeObserver;
  78038. private _transformMatrix;
  78039. private _mirrorMatrix;
  78040. private _savedViewMatrix;
  78041. private _blurX;
  78042. private _blurY;
  78043. private _adaptiveBlurKernel;
  78044. private _blurKernelX;
  78045. private _blurKernelY;
  78046. private _blurRatio;
  78047. /**
  78048. * Instantiates a Mirror Texture.
  78049. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78050. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78051. * You can then easily use it as a reflectionTexture on a flat surface.
  78052. * In case the surface is not a plane, please consider relying on reflection probes.
  78053. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78054. * @param name
  78055. * @param size
  78056. * @param scene
  78057. * @param generateMipMaps
  78058. * @param type
  78059. * @param samplingMode
  78060. * @param generateDepthBuffer
  78061. */
  78062. constructor(name: string, size: number | {
  78063. width: number;
  78064. height: number;
  78065. } | {
  78066. ratio: number;
  78067. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78068. private _preparePostProcesses;
  78069. /**
  78070. * Clone the mirror texture.
  78071. * @returns the cloned texture
  78072. */
  78073. clone(): MirrorTexture;
  78074. /**
  78075. * Serialize the texture to a JSON representation you could use in Parse later on
  78076. * @returns the serialized JSON representation
  78077. */
  78078. serialize(): any;
  78079. /**
  78080. * Dispose the texture and release its associated resources.
  78081. */
  78082. dispose(): void;
  78083. }
  78084. }
  78085. declare module BABYLON {
  78086. /**
  78087. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78088. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78089. */
  78090. export class Texture extends BaseTexture {
  78091. /** @hidden */
  78092. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78093. /** @hidden */
  78094. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78095. /** @hidden */
  78096. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78097. /** nearest is mag = nearest and min = nearest and mip = linear */
  78098. static readonly NEAREST_SAMPLINGMODE: number;
  78099. /** nearest is mag = nearest and min = nearest and mip = linear */
  78100. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78101. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78102. static readonly BILINEAR_SAMPLINGMODE: number;
  78103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78104. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78105. /** Trilinear is mag = linear and min = linear and mip = linear */
  78106. static readonly TRILINEAR_SAMPLINGMODE: number;
  78107. /** Trilinear is mag = linear and min = linear and mip = linear */
  78108. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78109. /** mag = nearest and min = nearest and mip = nearest */
  78110. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78111. /** mag = nearest and min = linear and mip = nearest */
  78112. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78113. /** mag = nearest and min = linear and mip = linear */
  78114. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78115. /** mag = nearest and min = linear and mip = none */
  78116. static readonly NEAREST_LINEAR: number;
  78117. /** mag = nearest and min = nearest and mip = none */
  78118. static readonly NEAREST_NEAREST: number;
  78119. /** mag = linear and min = nearest and mip = nearest */
  78120. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78121. /** mag = linear and min = nearest and mip = linear */
  78122. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78123. /** mag = linear and min = linear and mip = none */
  78124. static readonly LINEAR_LINEAR: number;
  78125. /** mag = linear and min = nearest and mip = none */
  78126. static readonly LINEAR_NEAREST: number;
  78127. /** Explicit coordinates mode */
  78128. static readonly EXPLICIT_MODE: number;
  78129. /** Spherical coordinates mode */
  78130. static readonly SPHERICAL_MODE: number;
  78131. /** Planar coordinates mode */
  78132. static readonly PLANAR_MODE: number;
  78133. /** Cubic coordinates mode */
  78134. static readonly CUBIC_MODE: number;
  78135. /** Projection coordinates mode */
  78136. static readonly PROJECTION_MODE: number;
  78137. /** Inverse Cubic coordinates mode */
  78138. static readonly SKYBOX_MODE: number;
  78139. /** Inverse Cubic coordinates mode */
  78140. static readonly INVCUBIC_MODE: number;
  78141. /** Equirectangular coordinates mode */
  78142. static readonly EQUIRECTANGULAR_MODE: number;
  78143. /** Equirectangular Fixed coordinates mode */
  78144. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78145. /** Equirectangular Fixed Mirrored coordinates mode */
  78146. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78147. /** Texture is not repeating outside of 0..1 UVs */
  78148. static readonly CLAMP_ADDRESSMODE: number;
  78149. /** Texture is repeating outside of 0..1 UVs */
  78150. static readonly WRAP_ADDRESSMODE: number;
  78151. /** Texture is repeating and mirrored */
  78152. static readonly MIRROR_ADDRESSMODE: number;
  78153. /**
  78154. * 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
  78155. */
  78156. static UseSerializedUrlIfAny: boolean;
  78157. /**
  78158. * Define the url of the texture.
  78159. */
  78160. url: Nullable<string>;
  78161. /**
  78162. * Define an offset on the texture to offset the u coordinates of the UVs
  78163. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78164. */
  78165. uOffset: number;
  78166. /**
  78167. * Define an offset on the texture to offset the v coordinates of the UVs
  78168. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78169. */
  78170. vOffset: number;
  78171. /**
  78172. * Define an offset on the texture to scale the u coordinates of the UVs
  78173. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78174. */
  78175. uScale: number;
  78176. /**
  78177. * Define an offset on the texture to scale the v coordinates of the UVs
  78178. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78179. */
  78180. vScale: number;
  78181. /**
  78182. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78183. * @see http://doc.babylonjs.com/how_to/more_materials
  78184. */
  78185. uAng: number;
  78186. /**
  78187. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78188. * @see http://doc.babylonjs.com/how_to/more_materials
  78189. */
  78190. vAng: number;
  78191. /**
  78192. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78193. * @see http://doc.babylonjs.com/how_to/more_materials
  78194. */
  78195. wAng: number;
  78196. /**
  78197. * Defines the center of rotation (U)
  78198. */
  78199. uRotationCenter: number;
  78200. /**
  78201. * Defines the center of rotation (V)
  78202. */
  78203. vRotationCenter: number;
  78204. /**
  78205. * Defines the center of rotation (W)
  78206. */
  78207. wRotationCenter: number;
  78208. /**
  78209. * Are mip maps generated for this texture or not.
  78210. */
  78211. readonly noMipmap: boolean;
  78212. /**
  78213. * List of inspectable custom properties (used by the Inspector)
  78214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78215. */
  78216. inspectableCustomProperties: Nullable<IInspectable[]>;
  78217. private _noMipmap;
  78218. /** @hidden */
  78219. _invertY: boolean;
  78220. private _rowGenerationMatrix;
  78221. private _cachedTextureMatrix;
  78222. private _projectionModeMatrix;
  78223. private _t0;
  78224. private _t1;
  78225. private _t2;
  78226. private _cachedUOffset;
  78227. private _cachedVOffset;
  78228. private _cachedUScale;
  78229. private _cachedVScale;
  78230. private _cachedUAng;
  78231. private _cachedVAng;
  78232. private _cachedWAng;
  78233. private _cachedProjectionMatrixId;
  78234. private _cachedCoordinatesMode;
  78235. /** @hidden */
  78236. protected _initialSamplingMode: number;
  78237. /** @hidden */
  78238. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78239. private _deleteBuffer;
  78240. protected _format: Nullable<number>;
  78241. private _delayedOnLoad;
  78242. private _delayedOnError;
  78243. /**
  78244. * Observable triggered once the texture has been loaded.
  78245. */
  78246. onLoadObservable: Observable<Texture>;
  78247. protected _isBlocking: boolean;
  78248. /**
  78249. * Is the texture preventing material to render while loading.
  78250. * If false, a default texture will be used instead of the loading one during the preparation step.
  78251. */
  78252. isBlocking: boolean;
  78253. /**
  78254. * Get the current sampling mode associated with the texture.
  78255. */
  78256. readonly samplingMode: number;
  78257. /**
  78258. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78259. */
  78260. readonly invertY: boolean;
  78261. /**
  78262. * Instantiates a new texture.
  78263. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78264. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78265. * @param url define the url of the picture to load as a texture
  78266. * @param scene define the scene the texture will belong to
  78267. * @param noMipmap define if the texture will require mip maps or not
  78268. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78269. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78270. * @param onLoad define a callback triggered when the texture has been loaded
  78271. * @param onError define a callback triggered when an error occurred during the loading session
  78272. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78273. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78274. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78275. */
  78276. 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);
  78277. /**
  78278. * Update the url (and optional buffer) of this texture if url was null during construction.
  78279. * @param url the url of the texture
  78280. * @param buffer the buffer of the texture (defaults to null)
  78281. * @param onLoad callback called when the texture is loaded (defaults to null)
  78282. */
  78283. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78284. /**
  78285. * Finish the loading sequence of a texture flagged as delayed load.
  78286. * @hidden
  78287. */
  78288. delayLoad(): void;
  78289. private _prepareRowForTextureGeneration;
  78290. /**
  78291. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78292. * @returns the transform matrix of the texture.
  78293. */
  78294. getTextureMatrix(): Matrix;
  78295. /**
  78296. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78297. * @returns The reflection texture transform
  78298. */
  78299. getReflectionTextureMatrix(): Matrix;
  78300. /**
  78301. * Clones the texture.
  78302. * @returns the cloned texture
  78303. */
  78304. clone(): Texture;
  78305. /**
  78306. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78307. * @returns The JSON representation of the texture
  78308. */
  78309. serialize(): any;
  78310. /**
  78311. * Get the current class name of the texture useful for serialization or dynamic coding.
  78312. * @returns "Texture"
  78313. */
  78314. getClassName(): string;
  78315. /**
  78316. * Dispose the texture and release its associated resources.
  78317. */
  78318. dispose(): void;
  78319. /**
  78320. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78321. * @param parsedTexture Define the JSON representation of the texture
  78322. * @param scene Define the scene the parsed texture should be instantiated in
  78323. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78324. * @returns The parsed texture if successful
  78325. */
  78326. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78327. /**
  78328. * Creates a texture from its base 64 representation.
  78329. * @param data Define the base64 payload without the data: prefix
  78330. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78331. * @param scene Define the scene the texture should belong to
  78332. * @param noMipmap Forces the texture to not create mip map information if true
  78333. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78334. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78335. * @param onLoad define a callback triggered when the texture has been loaded
  78336. * @param onError define a callback triggered when an error occurred during the loading session
  78337. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78338. * @returns the created texture
  78339. */
  78340. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78341. /**
  78342. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78343. * @param data Define the base64 payload without the data: prefix
  78344. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78345. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78346. * @param scene Define the scene the texture should belong to
  78347. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78348. * @param noMipmap Forces the texture to not create mip map information if true
  78349. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78350. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78351. * @param onLoad define a callback triggered when the texture has been loaded
  78352. * @param onError define a callback triggered when an error occurred during the loading session
  78353. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78354. * @returns the created texture
  78355. */
  78356. 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;
  78357. }
  78358. }
  78359. declare module BABYLON {
  78360. interface Engine {
  78361. /**
  78362. * Creates a raw texture
  78363. * @param data defines the data to store in the texture
  78364. * @param width defines the width of the texture
  78365. * @param height defines the height of the texture
  78366. * @param format defines the format of the data
  78367. * @param generateMipMaps defines if the engine should generate the mip levels
  78368. * @param invertY defines if data must be stored with Y axis inverted
  78369. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78370. * @param compression defines the compression used (null by default)
  78371. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78372. * @returns the raw texture inside an InternalTexture
  78373. */
  78374. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78375. /**
  78376. * Update a raw texture
  78377. * @param texture defines the texture to update
  78378. * @param data defines the data to store in the texture
  78379. * @param format defines the format of the data
  78380. * @param invertY defines if data must be stored with Y axis inverted
  78381. */
  78382. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78383. /**
  78384. * Update a raw texture
  78385. * @param texture defines the texture to update
  78386. * @param data defines the data to store in the texture
  78387. * @param format defines the format of the data
  78388. * @param invertY defines if data must be stored with Y axis inverted
  78389. * @param compression defines the compression used (null by default)
  78390. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78391. */
  78392. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78393. /**
  78394. * Creates a new raw cube texture
  78395. * @param data defines the array of data to use to create each face
  78396. * @param size defines the size of the textures
  78397. * @param format defines the format of the data
  78398. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78399. * @param generateMipMaps defines if the engine should generate the mip levels
  78400. * @param invertY defines if data must be stored with Y axis inverted
  78401. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78402. * @param compression defines the compression used (null by default)
  78403. * @returns the cube texture as an InternalTexture
  78404. */
  78405. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78406. /**
  78407. * Update a raw cube texture
  78408. * @param texture defines the texture to udpdate
  78409. * @param data defines the data to store
  78410. * @param format defines the data format
  78411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78412. * @param invertY defines if data must be stored with Y axis inverted
  78413. */
  78414. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78415. /**
  78416. * Update a raw cube texture
  78417. * @param texture defines the texture to udpdate
  78418. * @param data defines the data to store
  78419. * @param format defines the data format
  78420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78421. * @param invertY defines if data must be stored with Y axis inverted
  78422. * @param compression defines the compression used (null by default)
  78423. */
  78424. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78425. /**
  78426. * Update a raw cube texture
  78427. * @param texture defines the texture to udpdate
  78428. * @param data defines the data to store
  78429. * @param format defines the data format
  78430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78431. * @param invertY defines if data must be stored with Y axis inverted
  78432. * @param compression defines the compression used (null by default)
  78433. * @param level defines which level of the texture to update
  78434. */
  78435. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78436. /**
  78437. * Creates a new raw cube texture from a specified url
  78438. * @param url defines the url where the data is located
  78439. * @param scene defines the current scene
  78440. * @param size defines the size of the textures
  78441. * @param format defines the format of the data
  78442. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78443. * @param noMipmap defines if the engine should avoid generating the mip levels
  78444. * @param callback defines a callback used to extract texture data from loaded data
  78445. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78446. * @param onLoad defines a callback called when texture is loaded
  78447. * @param onError defines a callback called if there is an error
  78448. * @returns the cube texture as an InternalTexture
  78449. */
  78450. 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;
  78451. /**
  78452. * Creates a new raw cube texture from a specified url
  78453. * @param url defines the url where the data is located
  78454. * @param scene defines the current scene
  78455. * @param size defines the size of the textures
  78456. * @param format defines the format of the data
  78457. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78458. * @param noMipmap defines if the engine should avoid generating the mip levels
  78459. * @param callback defines a callback used to extract texture data from loaded data
  78460. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78461. * @param onLoad defines a callback called when texture is loaded
  78462. * @param onError defines a callback called if there is an error
  78463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78464. * @param invertY defines if data must be stored with Y axis inverted
  78465. * @returns the cube texture as an InternalTexture
  78466. */
  78467. 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;
  78468. /**
  78469. * Creates a new raw 3D texture
  78470. * @param data defines the data used to create the texture
  78471. * @param width defines the width of the texture
  78472. * @param height defines the height of the texture
  78473. * @param depth defines the depth of the texture
  78474. * @param format defines the format of the texture
  78475. * @param generateMipMaps defines if the engine must generate mip levels
  78476. * @param invertY defines if data must be stored with Y axis inverted
  78477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78478. * @param compression defines the compressed used (can be null)
  78479. * @param textureType defines the compressed used (can be null)
  78480. * @returns a new raw 3D texture (stored in an InternalTexture)
  78481. */
  78482. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78483. /**
  78484. * Update a raw 3D texture
  78485. * @param texture defines the texture to update
  78486. * @param data defines the data to store
  78487. * @param format defines the data format
  78488. * @param invertY defines if data must be stored with Y axis inverted
  78489. */
  78490. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78491. /**
  78492. * Update a raw 3D texture
  78493. * @param texture defines the texture to update
  78494. * @param data defines the data to store
  78495. * @param format defines the data format
  78496. * @param invertY defines if data must be stored with Y axis inverted
  78497. * @param compression defines the used compression (can be null)
  78498. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78499. */
  78500. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78501. }
  78502. }
  78503. declare module BABYLON {
  78504. /**
  78505. * Raw texture can help creating a texture directly from an array of data.
  78506. * This can be super useful if you either get the data from an uncompressed source or
  78507. * if you wish to create your texture pixel by pixel.
  78508. */
  78509. export class RawTexture extends Texture {
  78510. /**
  78511. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78512. */
  78513. format: number;
  78514. private _engine;
  78515. /**
  78516. * Instantiates a new RawTexture.
  78517. * Raw texture can help creating a texture directly from an array of data.
  78518. * This can be super useful if you either get the data from an uncompressed source or
  78519. * if you wish to create your texture pixel by pixel.
  78520. * @param data define the array of data to use to create the texture
  78521. * @param width define the width of the texture
  78522. * @param height define the height of the texture
  78523. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78524. * @param scene define the scene the texture belongs to
  78525. * @param generateMipMaps define whether mip maps should be generated or not
  78526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78528. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78529. */
  78530. constructor(data: ArrayBufferView, width: number, height: number,
  78531. /**
  78532. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78533. */
  78534. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78535. /**
  78536. * Updates the texture underlying data.
  78537. * @param data Define the new data of the texture
  78538. */
  78539. update(data: ArrayBufferView): void;
  78540. /**
  78541. * Creates a luminance texture from some data.
  78542. * @param data Define the texture data
  78543. * @param width Define the width of the texture
  78544. * @param height Define the height of the texture
  78545. * @param scene Define the scene the texture belongs to
  78546. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78549. * @returns the luminance texture
  78550. */
  78551. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78552. /**
  78553. * Creates a luminance alpha texture from some data.
  78554. * @param data Define the texture data
  78555. * @param width Define the width of the texture
  78556. * @param height Define the height of the texture
  78557. * @param scene Define the scene the texture belongs to
  78558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78561. * @returns the luminance alpha texture
  78562. */
  78563. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78564. /**
  78565. * Creates an alpha texture from some data.
  78566. * @param data Define the texture data
  78567. * @param width Define the width of the texture
  78568. * @param height Define the height of the texture
  78569. * @param scene Define the scene the texture belongs to
  78570. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78571. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78572. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78573. * @returns the alpha texture
  78574. */
  78575. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78576. /**
  78577. * Creates a RGB texture from some data.
  78578. * @param data Define the texture data
  78579. * @param width Define the width of the texture
  78580. * @param height Define the height of the texture
  78581. * @param scene Define the scene the texture belongs to
  78582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78586. * @returns the RGB alpha texture
  78587. */
  78588. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78589. /**
  78590. * Creates a RGBA texture from some data.
  78591. * @param data Define the texture data
  78592. * @param width Define the width of the texture
  78593. * @param height Define the height of the texture
  78594. * @param scene Define the scene the texture belongs to
  78595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78599. * @returns the RGBA texture
  78600. */
  78601. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78602. /**
  78603. * Creates a R texture from some data.
  78604. * @param data Define the texture data
  78605. * @param width Define the width of the texture
  78606. * @param height Define the height of the texture
  78607. * @param scene Define the scene the texture belongs to
  78608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78611. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78612. * @returns the R texture
  78613. */
  78614. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78615. }
  78616. }
  78617. declare module BABYLON {
  78618. /**
  78619. * Defines a runtime animation
  78620. */
  78621. export class RuntimeAnimation {
  78622. private _events;
  78623. /**
  78624. * The current frame of the runtime animation
  78625. */
  78626. private _currentFrame;
  78627. /**
  78628. * The animation used by the runtime animation
  78629. */
  78630. private _animation;
  78631. /**
  78632. * The target of the runtime animation
  78633. */
  78634. private _target;
  78635. /**
  78636. * The initiating animatable
  78637. */
  78638. private _host;
  78639. /**
  78640. * The original value of the runtime animation
  78641. */
  78642. private _originalValue;
  78643. /**
  78644. * The original blend value of the runtime animation
  78645. */
  78646. private _originalBlendValue;
  78647. /**
  78648. * The offsets cache of the runtime animation
  78649. */
  78650. private _offsetsCache;
  78651. /**
  78652. * The high limits cache of the runtime animation
  78653. */
  78654. private _highLimitsCache;
  78655. /**
  78656. * Specifies if the runtime animation has been stopped
  78657. */
  78658. private _stopped;
  78659. /**
  78660. * The blending factor of the runtime animation
  78661. */
  78662. private _blendingFactor;
  78663. /**
  78664. * The BabylonJS scene
  78665. */
  78666. private _scene;
  78667. /**
  78668. * The current value of the runtime animation
  78669. */
  78670. private _currentValue;
  78671. /** @hidden */
  78672. _animationState: _IAnimationState;
  78673. /**
  78674. * The active target of the runtime animation
  78675. */
  78676. private _activeTargets;
  78677. private _currentActiveTarget;
  78678. private _directTarget;
  78679. /**
  78680. * The target path of the runtime animation
  78681. */
  78682. private _targetPath;
  78683. /**
  78684. * The weight of the runtime animation
  78685. */
  78686. private _weight;
  78687. /**
  78688. * The ratio offset of the runtime animation
  78689. */
  78690. private _ratioOffset;
  78691. /**
  78692. * The previous delay of the runtime animation
  78693. */
  78694. private _previousDelay;
  78695. /**
  78696. * The previous ratio of the runtime animation
  78697. */
  78698. private _previousRatio;
  78699. private _enableBlending;
  78700. private _keys;
  78701. private _minFrame;
  78702. private _maxFrame;
  78703. private _minValue;
  78704. private _maxValue;
  78705. private _targetIsArray;
  78706. /**
  78707. * Gets the current frame of the runtime animation
  78708. */
  78709. readonly currentFrame: number;
  78710. /**
  78711. * Gets the weight of the runtime animation
  78712. */
  78713. readonly weight: number;
  78714. /**
  78715. * Gets the current value of the runtime animation
  78716. */
  78717. readonly currentValue: any;
  78718. /**
  78719. * Gets the target path of the runtime animation
  78720. */
  78721. readonly targetPath: string;
  78722. /**
  78723. * Gets the actual target of the runtime animation
  78724. */
  78725. readonly target: any;
  78726. /** @hidden */
  78727. _onLoop: () => void;
  78728. /**
  78729. * Create a new RuntimeAnimation object
  78730. * @param target defines the target of the animation
  78731. * @param animation defines the source animation object
  78732. * @param scene defines the hosting scene
  78733. * @param host defines the initiating Animatable
  78734. */
  78735. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78736. private _preparePath;
  78737. /**
  78738. * Gets the animation from the runtime animation
  78739. */
  78740. readonly animation: Animation;
  78741. /**
  78742. * Resets the runtime animation to the beginning
  78743. * @param restoreOriginal defines whether to restore the target property to the original value
  78744. */
  78745. reset(restoreOriginal?: boolean): void;
  78746. /**
  78747. * Specifies if the runtime animation is stopped
  78748. * @returns Boolean specifying if the runtime animation is stopped
  78749. */
  78750. isStopped(): boolean;
  78751. /**
  78752. * Disposes of the runtime animation
  78753. */
  78754. dispose(): void;
  78755. /**
  78756. * Apply the interpolated value to the target
  78757. * @param currentValue defines the value computed by the animation
  78758. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78759. */
  78760. setValue(currentValue: any, weight: number): void;
  78761. private _getOriginalValues;
  78762. private _setValue;
  78763. /**
  78764. * Gets the loop pmode of the runtime animation
  78765. * @returns Loop Mode
  78766. */
  78767. private _getCorrectLoopMode;
  78768. /**
  78769. * Move the current animation to a given frame
  78770. * @param frame defines the frame to move to
  78771. */
  78772. goToFrame(frame: number): void;
  78773. /**
  78774. * @hidden Internal use only
  78775. */
  78776. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78777. /**
  78778. * Execute the current animation
  78779. * @param delay defines the delay to add to the current frame
  78780. * @param from defines the lower bound of the animation range
  78781. * @param to defines the upper bound of the animation range
  78782. * @param loop defines if the current animation must loop
  78783. * @param speedRatio defines the current speed ratio
  78784. * @param weight defines the weight of the animation (default is -1 so no weight)
  78785. * @param onLoop optional callback called when animation loops
  78786. * @returns a boolean indicating if the animation is running
  78787. */
  78788. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78789. }
  78790. }
  78791. declare module BABYLON {
  78792. /**
  78793. * Class used to store an actual running animation
  78794. */
  78795. export class Animatable {
  78796. /** defines the target object */
  78797. target: any;
  78798. /** defines the starting frame number (default is 0) */
  78799. fromFrame: number;
  78800. /** defines the ending frame number (default is 100) */
  78801. toFrame: number;
  78802. /** defines if the animation must loop (default is false) */
  78803. loopAnimation: boolean;
  78804. /** defines a callback to call when animation ends if it is not looping */
  78805. onAnimationEnd?: (() => void) | null | undefined;
  78806. /** defines a callback to call when animation loops */
  78807. onAnimationLoop?: (() => void) | null | undefined;
  78808. private _localDelayOffset;
  78809. private _pausedDelay;
  78810. private _runtimeAnimations;
  78811. private _paused;
  78812. private _scene;
  78813. private _speedRatio;
  78814. private _weight;
  78815. private _syncRoot;
  78816. /**
  78817. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78818. * This will only apply for non looping animation (default is true)
  78819. */
  78820. disposeOnEnd: boolean;
  78821. /**
  78822. * Gets a boolean indicating if the animation has started
  78823. */
  78824. animationStarted: boolean;
  78825. /**
  78826. * Observer raised when the animation ends
  78827. */
  78828. onAnimationEndObservable: Observable<Animatable>;
  78829. /**
  78830. * Observer raised when the animation loops
  78831. */
  78832. onAnimationLoopObservable: Observable<Animatable>;
  78833. /**
  78834. * Gets the root Animatable used to synchronize and normalize animations
  78835. */
  78836. readonly syncRoot: Nullable<Animatable>;
  78837. /**
  78838. * Gets the current frame of the first RuntimeAnimation
  78839. * Used to synchronize Animatables
  78840. */
  78841. readonly masterFrame: number;
  78842. /**
  78843. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78844. */
  78845. weight: number;
  78846. /**
  78847. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78848. */
  78849. speedRatio: number;
  78850. /**
  78851. * Creates a new Animatable
  78852. * @param scene defines the hosting scene
  78853. * @param target defines the target object
  78854. * @param fromFrame defines the starting frame number (default is 0)
  78855. * @param toFrame defines the ending frame number (default is 100)
  78856. * @param loopAnimation defines if the animation must loop (default is false)
  78857. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78858. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78859. * @param animations defines a group of animation to add to the new Animatable
  78860. * @param onAnimationLoop defines a callback to call when animation loops
  78861. */
  78862. constructor(scene: Scene,
  78863. /** defines the target object */
  78864. target: any,
  78865. /** defines the starting frame number (default is 0) */
  78866. fromFrame?: number,
  78867. /** defines the ending frame number (default is 100) */
  78868. toFrame?: number,
  78869. /** defines if the animation must loop (default is false) */
  78870. loopAnimation?: boolean, speedRatio?: number,
  78871. /** defines a callback to call when animation ends if it is not looping */
  78872. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78873. /** defines a callback to call when animation loops */
  78874. onAnimationLoop?: (() => void) | null | undefined);
  78875. /**
  78876. * Synchronize and normalize current Animatable with a source Animatable
  78877. * This is useful when using animation weights and when animations are not of the same length
  78878. * @param root defines the root Animatable to synchronize with
  78879. * @returns the current Animatable
  78880. */
  78881. syncWith(root: Animatable): Animatable;
  78882. /**
  78883. * Gets the list of runtime animations
  78884. * @returns an array of RuntimeAnimation
  78885. */
  78886. getAnimations(): RuntimeAnimation[];
  78887. /**
  78888. * Adds more animations to the current animatable
  78889. * @param target defines the target of the animations
  78890. * @param animations defines the new animations to add
  78891. */
  78892. appendAnimations(target: any, animations: Animation[]): void;
  78893. /**
  78894. * Gets the source animation for a specific property
  78895. * @param property defines the propertyu to look for
  78896. * @returns null or the source animation for the given property
  78897. */
  78898. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78899. /**
  78900. * Gets the runtime animation for a specific property
  78901. * @param property defines the propertyu to look for
  78902. * @returns null or the runtime animation for the given property
  78903. */
  78904. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78905. /**
  78906. * Resets the animatable to its original state
  78907. */
  78908. reset(): void;
  78909. /**
  78910. * Allows the animatable to blend with current running animations
  78911. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78912. * @param blendingSpeed defines the blending speed to use
  78913. */
  78914. enableBlending(blendingSpeed: number): void;
  78915. /**
  78916. * Disable animation blending
  78917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78918. */
  78919. disableBlending(): void;
  78920. /**
  78921. * Jump directly to a given frame
  78922. * @param frame defines the frame to jump to
  78923. */
  78924. goToFrame(frame: number): void;
  78925. /**
  78926. * Pause the animation
  78927. */
  78928. pause(): void;
  78929. /**
  78930. * Restart the animation
  78931. */
  78932. restart(): void;
  78933. private _raiseOnAnimationEnd;
  78934. /**
  78935. * Stop and delete the current animation
  78936. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78937. * @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)
  78938. */
  78939. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78940. /**
  78941. * Wait asynchronously for the animation to end
  78942. * @returns a promise which will be fullfilled when the animation ends
  78943. */
  78944. waitAsync(): Promise<Animatable>;
  78945. /** @hidden */
  78946. _animate(delay: number): boolean;
  78947. }
  78948. interface Scene {
  78949. /** @hidden */
  78950. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78951. /** @hidden */
  78952. _processLateAnimationBindingsForMatrices(holder: {
  78953. totalWeight: number;
  78954. animations: RuntimeAnimation[];
  78955. originalValue: Matrix;
  78956. }): any;
  78957. /** @hidden */
  78958. _processLateAnimationBindingsForQuaternions(holder: {
  78959. totalWeight: number;
  78960. animations: RuntimeAnimation[];
  78961. originalValue: Quaternion;
  78962. }, refQuaternion: Quaternion): Quaternion;
  78963. /** @hidden */
  78964. _processLateAnimationBindings(): void;
  78965. /**
  78966. * Will start the animation sequence of a given target
  78967. * @param target defines the target
  78968. * @param from defines from which frame should animation start
  78969. * @param to defines until which frame should animation run.
  78970. * @param weight defines the weight to apply to the animation (1.0 by default)
  78971. * @param loop defines if the animation loops
  78972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78973. * @param onAnimationEnd defines the function to be executed when the animation ends
  78974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78976. * @param onAnimationLoop defines the callback to call when an animation loops
  78977. * @returns the animatable object created for this animation
  78978. */
  78979. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78980. /**
  78981. * Will start the animation sequence of a given target
  78982. * @param target defines the target
  78983. * @param from defines from which frame should animation start
  78984. * @param to defines until which frame should animation run.
  78985. * @param loop defines if the animation loops
  78986. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78987. * @param onAnimationEnd defines the function to be executed when the animation ends
  78988. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78989. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78990. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78991. * @param onAnimationLoop defines the callback to call when an animation loops
  78992. * @returns the animatable object created for this animation
  78993. */
  78994. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78995. /**
  78996. * Will start the animation sequence of a given target and its hierarchy
  78997. * @param target defines the target
  78998. * @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.
  78999. * @param from defines from which frame should animation start
  79000. * @param to defines until which frame should animation run.
  79001. * @param loop defines if the animation loops
  79002. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79003. * @param onAnimationEnd defines the function to be executed when the animation ends
  79004. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79005. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79006. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79007. * @param onAnimationLoop defines the callback to call when an animation loops
  79008. * @returns the list of created animatables
  79009. */
  79010. 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[];
  79011. /**
  79012. * Begin a new animation on a given node
  79013. * @param target defines the target where the animation will take place
  79014. * @param animations defines the list of animations to start
  79015. * @param from defines the initial value
  79016. * @param to defines the final value
  79017. * @param loop defines if you want animation to loop (off by default)
  79018. * @param speedRatio defines the speed ratio to apply to all animations
  79019. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79020. * @param onAnimationLoop defines the callback to call when an animation loops
  79021. * @returns the list of created animatables
  79022. */
  79023. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79024. /**
  79025. * Begin a new animation on a given node and its hierarchy
  79026. * @param target defines the root node where the animation will take place
  79027. * @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.
  79028. * @param animations defines the list of animations to start
  79029. * @param from defines the initial value
  79030. * @param to defines the final value
  79031. * @param loop defines if you want animation to loop (off by default)
  79032. * @param speedRatio defines the speed ratio to apply to all animations
  79033. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79034. * @param onAnimationLoop defines the callback to call when an animation loops
  79035. * @returns the list of animatables created for all nodes
  79036. */
  79037. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79038. /**
  79039. * Gets the animatable associated with a specific target
  79040. * @param target defines the target of the animatable
  79041. * @returns the required animatable if found
  79042. */
  79043. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79044. /**
  79045. * Gets all animatables associated with a given target
  79046. * @param target defines the target to look animatables for
  79047. * @returns an array of Animatables
  79048. */
  79049. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79050. /**
  79051. * Stops and removes all animations that have been applied to the scene
  79052. */
  79053. stopAllAnimations(): void;
  79054. }
  79055. interface Bone {
  79056. /**
  79057. * Copy an animation range from another bone
  79058. * @param source defines the source bone
  79059. * @param rangeName defines the range name to copy
  79060. * @param frameOffset defines the frame offset
  79061. * @param rescaleAsRequired defines if rescaling must be applied if required
  79062. * @param skelDimensionsRatio defines the scaling ratio
  79063. * @returns true if operation was successful
  79064. */
  79065. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79066. }
  79067. }
  79068. declare module BABYLON {
  79069. /**
  79070. * Class used to handle skinning animations
  79071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79072. */
  79073. export class Skeleton implements IAnimatable {
  79074. /** defines the skeleton name */
  79075. name: string;
  79076. /** defines the skeleton Id */
  79077. id: string;
  79078. /**
  79079. * Defines the list of child bones
  79080. */
  79081. bones: Bone[];
  79082. /**
  79083. * Defines an estimate of the dimension of the skeleton at rest
  79084. */
  79085. dimensionsAtRest: Vector3;
  79086. /**
  79087. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79088. */
  79089. needInitialSkinMatrix: boolean;
  79090. /**
  79091. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79092. */
  79093. overrideMesh: Nullable<AbstractMesh>;
  79094. /**
  79095. * Gets the list of animations attached to this skeleton
  79096. */
  79097. animations: Array<Animation>;
  79098. private _scene;
  79099. private _isDirty;
  79100. private _transformMatrices;
  79101. private _transformMatrixTexture;
  79102. private _meshesWithPoseMatrix;
  79103. private _animatables;
  79104. private _identity;
  79105. private _synchronizedWithMesh;
  79106. private _ranges;
  79107. private _lastAbsoluteTransformsUpdateId;
  79108. private _canUseTextureForBones;
  79109. private _uniqueId;
  79110. /** @hidden */
  79111. _numBonesWithLinkedTransformNode: number;
  79112. /** @hidden */
  79113. _hasWaitingData: Nullable<boolean>;
  79114. /**
  79115. * Specifies if the skeleton should be serialized
  79116. */
  79117. doNotSerialize: boolean;
  79118. private _useTextureToStoreBoneMatrices;
  79119. /**
  79120. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79121. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79122. */
  79123. useTextureToStoreBoneMatrices: boolean;
  79124. private _animationPropertiesOverride;
  79125. /**
  79126. * Gets or sets the animation properties override
  79127. */
  79128. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79129. /**
  79130. * List of inspectable custom properties (used by the Inspector)
  79131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79132. */
  79133. inspectableCustomProperties: IInspectable[];
  79134. /**
  79135. * An observable triggered before computing the skeleton's matrices
  79136. */
  79137. onBeforeComputeObservable: Observable<Skeleton>;
  79138. /**
  79139. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79140. */
  79141. readonly isUsingTextureForMatrices: boolean;
  79142. /**
  79143. * Gets the unique ID of this skeleton
  79144. */
  79145. readonly uniqueId: number;
  79146. /**
  79147. * Creates a new skeleton
  79148. * @param name defines the skeleton name
  79149. * @param id defines the skeleton Id
  79150. * @param scene defines the hosting scene
  79151. */
  79152. constructor(
  79153. /** defines the skeleton name */
  79154. name: string,
  79155. /** defines the skeleton Id */
  79156. id: string, scene: Scene);
  79157. /**
  79158. * Gets the current object class name.
  79159. * @return the class name
  79160. */
  79161. getClassName(): string;
  79162. /**
  79163. * Returns an array containing the root bones
  79164. * @returns an array containing the root bones
  79165. */
  79166. getChildren(): Array<Bone>;
  79167. /**
  79168. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79169. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79170. * @returns a Float32Array containing matrices data
  79171. */
  79172. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79173. /**
  79174. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79175. * @returns a raw texture containing the data
  79176. */
  79177. getTransformMatrixTexture(): Nullable<RawTexture>;
  79178. /**
  79179. * Gets the current hosting scene
  79180. * @returns a scene object
  79181. */
  79182. getScene(): Scene;
  79183. /**
  79184. * Gets a string representing the current skeleton data
  79185. * @param fullDetails defines a boolean indicating if we want a verbose version
  79186. * @returns a string representing the current skeleton data
  79187. */
  79188. toString(fullDetails?: boolean): string;
  79189. /**
  79190. * Get bone's index searching by name
  79191. * @param name defines bone's name to search for
  79192. * @return the indice of the bone. Returns -1 if not found
  79193. */
  79194. getBoneIndexByName(name: string): number;
  79195. /**
  79196. * Creater a new animation range
  79197. * @param name defines the name of the range
  79198. * @param from defines the start key
  79199. * @param to defines the end key
  79200. */
  79201. createAnimationRange(name: string, from: number, to: number): void;
  79202. /**
  79203. * Delete a specific animation range
  79204. * @param name defines the name of the range
  79205. * @param deleteFrames defines if frames must be removed as well
  79206. */
  79207. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79208. /**
  79209. * Gets a specific animation range
  79210. * @param name defines the name of the range to look for
  79211. * @returns the requested animation range or null if not found
  79212. */
  79213. getAnimationRange(name: string): Nullable<AnimationRange>;
  79214. /**
  79215. * Gets the list of all animation ranges defined on this skeleton
  79216. * @returns an array
  79217. */
  79218. getAnimationRanges(): Nullable<AnimationRange>[];
  79219. /**
  79220. * Copy animation range from a source skeleton.
  79221. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79222. * @param source defines the source skeleton
  79223. * @param name defines the name of the range to copy
  79224. * @param rescaleAsRequired defines if rescaling must be applied if required
  79225. * @returns true if operation was successful
  79226. */
  79227. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79228. /**
  79229. * Forces the skeleton to go to rest pose
  79230. */
  79231. returnToRest(): void;
  79232. private _getHighestAnimationFrame;
  79233. /**
  79234. * Begin a specific animation range
  79235. * @param name defines the name of the range to start
  79236. * @param loop defines if looping must be turned on (false by default)
  79237. * @param speedRatio defines the speed ratio to apply (1 by default)
  79238. * @param onAnimationEnd defines a callback which will be called when animation will end
  79239. * @returns a new animatable
  79240. */
  79241. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79242. /** @hidden */
  79243. _markAsDirty(): void;
  79244. /** @hidden */
  79245. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79246. /** @hidden */
  79247. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79248. private _computeTransformMatrices;
  79249. /**
  79250. * Build all resources required to render a skeleton
  79251. */
  79252. prepare(): void;
  79253. /**
  79254. * Gets the list of animatables currently running for this skeleton
  79255. * @returns an array of animatables
  79256. */
  79257. getAnimatables(): IAnimatable[];
  79258. /**
  79259. * Clone the current skeleton
  79260. * @param name defines the name of the new skeleton
  79261. * @param id defines the id of the new skeleton
  79262. * @returns the new skeleton
  79263. */
  79264. clone(name: string, id: string): Skeleton;
  79265. /**
  79266. * Enable animation blending for this skeleton
  79267. * @param blendingSpeed defines the blending speed to apply
  79268. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79269. */
  79270. enableBlending(blendingSpeed?: number): void;
  79271. /**
  79272. * Releases all resources associated with the current skeleton
  79273. */
  79274. dispose(): void;
  79275. /**
  79276. * Serialize the skeleton in a JSON object
  79277. * @returns a JSON object
  79278. */
  79279. serialize(): any;
  79280. /**
  79281. * Creates a new skeleton from serialized data
  79282. * @param parsedSkeleton defines the serialized data
  79283. * @param scene defines the hosting scene
  79284. * @returns a new skeleton
  79285. */
  79286. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79287. /**
  79288. * Compute all node absolute transforms
  79289. * @param forceUpdate defines if computation must be done even if cache is up to date
  79290. */
  79291. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79292. /**
  79293. * Gets the root pose matrix
  79294. * @returns a matrix
  79295. */
  79296. getPoseMatrix(): Nullable<Matrix>;
  79297. /**
  79298. * Sorts bones per internal index
  79299. */
  79300. sortBones(): void;
  79301. private _sortBones;
  79302. }
  79303. }
  79304. declare module BABYLON {
  79305. /**
  79306. * Defines a target to use with MorphTargetManager
  79307. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79308. */
  79309. export class MorphTarget implements IAnimatable {
  79310. /** defines the name of the target */
  79311. name: string;
  79312. /**
  79313. * Gets or sets the list of animations
  79314. */
  79315. animations: Animation[];
  79316. private _scene;
  79317. private _positions;
  79318. private _normals;
  79319. private _tangents;
  79320. private _influence;
  79321. /**
  79322. * Observable raised when the influence changes
  79323. */
  79324. onInfluenceChanged: Observable<boolean>;
  79325. /** @hidden */
  79326. _onDataLayoutChanged: Observable<void>;
  79327. /**
  79328. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79329. */
  79330. influence: number;
  79331. /**
  79332. * Gets or sets the id of the morph Target
  79333. */
  79334. id: string;
  79335. private _animationPropertiesOverride;
  79336. /**
  79337. * Gets or sets the animation properties override
  79338. */
  79339. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79340. /**
  79341. * Creates a new MorphTarget
  79342. * @param name defines the name of the target
  79343. * @param influence defines the influence to use
  79344. * @param scene defines the scene the morphtarget belongs to
  79345. */
  79346. constructor(
  79347. /** defines the name of the target */
  79348. name: string, influence?: number, scene?: Nullable<Scene>);
  79349. /**
  79350. * Gets a boolean defining if the target contains position data
  79351. */
  79352. readonly hasPositions: boolean;
  79353. /**
  79354. * Gets a boolean defining if the target contains normal data
  79355. */
  79356. readonly hasNormals: boolean;
  79357. /**
  79358. * Gets a boolean defining if the target contains tangent data
  79359. */
  79360. readonly hasTangents: boolean;
  79361. /**
  79362. * Affects position data to this target
  79363. * @param data defines the position data to use
  79364. */
  79365. setPositions(data: Nullable<FloatArray>): void;
  79366. /**
  79367. * Gets the position data stored in this target
  79368. * @returns a FloatArray containing the position data (or null if not present)
  79369. */
  79370. getPositions(): Nullable<FloatArray>;
  79371. /**
  79372. * Affects normal data to this target
  79373. * @param data defines the normal data to use
  79374. */
  79375. setNormals(data: Nullable<FloatArray>): void;
  79376. /**
  79377. * Gets the normal data stored in this target
  79378. * @returns a FloatArray containing the normal data (or null if not present)
  79379. */
  79380. getNormals(): Nullable<FloatArray>;
  79381. /**
  79382. * Affects tangent data to this target
  79383. * @param data defines the tangent data to use
  79384. */
  79385. setTangents(data: Nullable<FloatArray>): void;
  79386. /**
  79387. * Gets the tangent data stored in this target
  79388. * @returns a FloatArray containing the tangent data (or null if not present)
  79389. */
  79390. getTangents(): Nullable<FloatArray>;
  79391. /**
  79392. * Serializes the current target into a Serialization object
  79393. * @returns the serialized object
  79394. */
  79395. serialize(): any;
  79396. /**
  79397. * Returns the string "MorphTarget"
  79398. * @returns "MorphTarget"
  79399. */
  79400. getClassName(): string;
  79401. /**
  79402. * Creates a new target from serialized data
  79403. * @param serializationObject defines the serialized data to use
  79404. * @returns a new MorphTarget
  79405. */
  79406. static Parse(serializationObject: any): MorphTarget;
  79407. /**
  79408. * Creates a MorphTarget from mesh data
  79409. * @param mesh defines the source mesh
  79410. * @param name defines the name to use for the new target
  79411. * @param influence defines the influence to attach to the target
  79412. * @returns a new MorphTarget
  79413. */
  79414. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79415. }
  79416. }
  79417. declare module BABYLON {
  79418. /**
  79419. * This class is used to deform meshes using morphing between different targets
  79420. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79421. */
  79422. export class MorphTargetManager {
  79423. private _targets;
  79424. private _targetInfluenceChangedObservers;
  79425. private _targetDataLayoutChangedObservers;
  79426. private _activeTargets;
  79427. private _scene;
  79428. private _influences;
  79429. private _supportsNormals;
  79430. private _supportsTangents;
  79431. private _vertexCount;
  79432. private _uniqueId;
  79433. private _tempInfluences;
  79434. /**
  79435. * Creates a new MorphTargetManager
  79436. * @param scene defines the current scene
  79437. */
  79438. constructor(scene?: Nullable<Scene>);
  79439. /**
  79440. * Gets the unique ID of this manager
  79441. */
  79442. readonly uniqueId: number;
  79443. /**
  79444. * Gets the number of vertices handled by this manager
  79445. */
  79446. readonly vertexCount: number;
  79447. /**
  79448. * Gets a boolean indicating if this manager supports morphing of normals
  79449. */
  79450. readonly supportsNormals: boolean;
  79451. /**
  79452. * Gets a boolean indicating if this manager supports morphing of tangents
  79453. */
  79454. readonly supportsTangents: boolean;
  79455. /**
  79456. * Gets the number of targets stored in this manager
  79457. */
  79458. readonly numTargets: number;
  79459. /**
  79460. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79461. */
  79462. readonly numInfluencers: number;
  79463. /**
  79464. * Gets the list of influences (one per target)
  79465. */
  79466. readonly influences: Float32Array;
  79467. /**
  79468. * Gets the active target at specified index. An active target is a target with an influence > 0
  79469. * @param index defines the index to check
  79470. * @returns the requested target
  79471. */
  79472. getActiveTarget(index: number): MorphTarget;
  79473. /**
  79474. * Gets the target at specified index
  79475. * @param index defines the index to check
  79476. * @returns the requested target
  79477. */
  79478. getTarget(index: number): MorphTarget;
  79479. /**
  79480. * Add a new target to this manager
  79481. * @param target defines the target to add
  79482. */
  79483. addTarget(target: MorphTarget): void;
  79484. /**
  79485. * Removes a target from the manager
  79486. * @param target defines the target to remove
  79487. */
  79488. removeTarget(target: MorphTarget): void;
  79489. /**
  79490. * Serializes the current manager into a Serialization object
  79491. * @returns the serialized object
  79492. */
  79493. serialize(): any;
  79494. private _syncActiveTargets;
  79495. /**
  79496. * Syncrhonize the targets with all the meshes using this morph target manager
  79497. */
  79498. synchronize(): void;
  79499. /**
  79500. * Creates a new MorphTargetManager from serialized data
  79501. * @param serializationObject defines the serialized data
  79502. * @param scene defines the hosting scene
  79503. * @returns the new MorphTargetManager
  79504. */
  79505. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79506. }
  79507. }
  79508. declare module BABYLON {
  79509. /**
  79510. * Class used to represent a specific level of detail of a mesh
  79511. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79512. */
  79513. export class MeshLODLevel {
  79514. /** Defines the distance where this level should star being displayed */
  79515. distance: number;
  79516. /** Defines the mesh to use to render this level */
  79517. mesh: Nullable<Mesh>;
  79518. /**
  79519. * Creates a new LOD level
  79520. * @param distance defines the distance where this level should star being displayed
  79521. * @param mesh defines the mesh to use to render this level
  79522. */
  79523. constructor(
  79524. /** Defines the distance where this level should star being displayed */
  79525. distance: number,
  79526. /** Defines the mesh to use to render this level */
  79527. mesh: Nullable<Mesh>);
  79528. }
  79529. }
  79530. declare module BABYLON {
  79531. /**
  79532. * Mesh representing the gorund
  79533. */
  79534. export class GroundMesh extends Mesh {
  79535. /** If octree should be generated */
  79536. generateOctree: boolean;
  79537. private _heightQuads;
  79538. /** @hidden */
  79539. _subdivisionsX: number;
  79540. /** @hidden */
  79541. _subdivisionsY: number;
  79542. /** @hidden */
  79543. _width: number;
  79544. /** @hidden */
  79545. _height: number;
  79546. /** @hidden */
  79547. _minX: number;
  79548. /** @hidden */
  79549. _maxX: number;
  79550. /** @hidden */
  79551. _minZ: number;
  79552. /** @hidden */
  79553. _maxZ: number;
  79554. constructor(name: string, scene: Scene);
  79555. /**
  79556. * "GroundMesh"
  79557. * @returns "GroundMesh"
  79558. */
  79559. getClassName(): string;
  79560. /**
  79561. * The minimum of x and y subdivisions
  79562. */
  79563. readonly subdivisions: number;
  79564. /**
  79565. * X subdivisions
  79566. */
  79567. readonly subdivisionsX: number;
  79568. /**
  79569. * Y subdivisions
  79570. */
  79571. readonly subdivisionsY: number;
  79572. /**
  79573. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79574. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79575. * @param chunksCount the number of subdivisions for x and y
  79576. * @param octreeBlocksSize (Default: 32)
  79577. */
  79578. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79579. /**
  79580. * Returns a height (y) value in the Worl system :
  79581. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79582. * @param x x coordinate
  79583. * @param z z coordinate
  79584. * @returns the ground y position if (x, z) are outside the ground surface.
  79585. */
  79586. getHeightAtCoordinates(x: number, z: number): number;
  79587. /**
  79588. * Returns a normalized vector (Vector3) orthogonal to the ground
  79589. * at the ground coordinates (x, z) expressed in the World system.
  79590. * @param x x coordinate
  79591. * @param z z coordinate
  79592. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79593. */
  79594. getNormalAtCoordinates(x: number, z: number): Vector3;
  79595. /**
  79596. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79597. * at the ground coordinates (x, z) expressed in the World system.
  79598. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79599. * @param x x coordinate
  79600. * @param z z coordinate
  79601. * @param ref vector to store the result
  79602. * @returns the GroundMesh.
  79603. */
  79604. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79605. /**
  79606. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79607. * if the ground has been updated.
  79608. * This can be used in the render loop.
  79609. * @returns the GroundMesh.
  79610. */
  79611. updateCoordinateHeights(): GroundMesh;
  79612. private _getFacetAt;
  79613. private _initHeightQuads;
  79614. private _computeHeightQuads;
  79615. /**
  79616. * Serializes this ground mesh
  79617. * @param serializationObject object to write serialization to
  79618. */
  79619. serialize(serializationObject: any): void;
  79620. /**
  79621. * Parses a serialized ground mesh
  79622. * @param parsedMesh the serialized mesh
  79623. * @param scene the scene to create the ground mesh in
  79624. * @returns the created ground mesh
  79625. */
  79626. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79627. }
  79628. }
  79629. declare module BABYLON {
  79630. /**
  79631. * Interface for Physics-Joint data
  79632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79633. */
  79634. export interface PhysicsJointData {
  79635. /**
  79636. * The main pivot of the joint
  79637. */
  79638. mainPivot?: Vector3;
  79639. /**
  79640. * The connected pivot of the joint
  79641. */
  79642. connectedPivot?: Vector3;
  79643. /**
  79644. * The main axis of the joint
  79645. */
  79646. mainAxis?: Vector3;
  79647. /**
  79648. * The connected axis of the joint
  79649. */
  79650. connectedAxis?: Vector3;
  79651. /**
  79652. * The collision of the joint
  79653. */
  79654. collision?: boolean;
  79655. /**
  79656. * Native Oimo/Cannon/Energy data
  79657. */
  79658. nativeParams?: any;
  79659. }
  79660. /**
  79661. * This is a holder class for the physics joint created by the physics plugin
  79662. * It holds a set of functions to control the underlying joint
  79663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79664. */
  79665. export class PhysicsJoint {
  79666. /**
  79667. * The type of the physics joint
  79668. */
  79669. type: number;
  79670. /**
  79671. * The data for the physics joint
  79672. */
  79673. jointData: PhysicsJointData;
  79674. private _physicsJoint;
  79675. protected _physicsPlugin: IPhysicsEnginePlugin;
  79676. /**
  79677. * Initializes the physics joint
  79678. * @param type The type of the physics joint
  79679. * @param jointData The data for the physics joint
  79680. */
  79681. constructor(
  79682. /**
  79683. * The type of the physics joint
  79684. */
  79685. type: number,
  79686. /**
  79687. * The data for the physics joint
  79688. */
  79689. jointData: PhysicsJointData);
  79690. /**
  79691. * Gets the physics joint
  79692. */
  79693. /**
  79694. * Sets the physics joint
  79695. */
  79696. physicsJoint: any;
  79697. /**
  79698. * Sets the physics plugin
  79699. */
  79700. physicsPlugin: IPhysicsEnginePlugin;
  79701. /**
  79702. * Execute a function that is physics-plugin specific.
  79703. * @param {Function} func the function that will be executed.
  79704. * It accepts two parameters: the physics world and the physics joint
  79705. */
  79706. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79707. /**
  79708. * Distance-Joint type
  79709. */
  79710. static DistanceJoint: number;
  79711. /**
  79712. * Hinge-Joint type
  79713. */
  79714. static HingeJoint: number;
  79715. /**
  79716. * Ball-and-Socket joint type
  79717. */
  79718. static BallAndSocketJoint: number;
  79719. /**
  79720. * Wheel-Joint type
  79721. */
  79722. static WheelJoint: number;
  79723. /**
  79724. * Slider-Joint type
  79725. */
  79726. static SliderJoint: number;
  79727. /**
  79728. * Prismatic-Joint type
  79729. */
  79730. static PrismaticJoint: number;
  79731. /**
  79732. * Universal-Joint type
  79733. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79734. */
  79735. static UniversalJoint: number;
  79736. /**
  79737. * Hinge-Joint 2 type
  79738. */
  79739. static Hinge2Joint: number;
  79740. /**
  79741. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79742. */
  79743. static PointToPointJoint: number;
  79744. /**
  79745. * Spring-Joint type
  79746. */
  79747. static SpringJoint: number;
  79748. /**
  79749. * Lock-Joint type
  79750. */
  79751. static LockJoint: number;
  79752. }
  79753. /**
  79754. * A class representing a physics distance joint
  79755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79756. */
  79757. export class DistanceJoint extends PhysicsJoint {
  79758. /**
  79759. *
  79760. * @param jointData The data for the Distance-Joint
  79761. */
  79762. constructor(jointData: DistanceJointData);
  79763. /**
  79764. * Update the predefined distance.
  79765. * @param maxDistance The maximum preferred distance
  79766. * @param minDistance The minimum preferred distance
  79767. */
  79768. updateDistance(maxDistance: number, minDistance?: number): void;
  79769. }
  79770. /**
  79771. * Represents a Motor-Enabled Joint
  79772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79773. */
  79774. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79775. /**
  79776. * Initializes the Motor-Enabled Joint
  79777. * @param type The type of the joint
  79778. * @param jointData The physica joint data for the joint
  79779. */
  79780. constructor(type: number, jointData: PhysicsJointData);
  79781. /**
  79782. * Set the motor values.
  79783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79784. * @param force the force to apply
  79785. * @param maxForce max force for this motor.
  79786. */
  79787. setMotor(force?: number, maxForce?: number): void;
  79788. /**
  79789. * Set the motor's limits.
  79790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79791. * @param upperLimit The upper limit of the motor
  79792. * @param lowerLimit The lower limit of the motor
  79793. */
  79794. setLimit(upperLimit: number, lowerLimit?: number): void;
  79795. }
  79796. /**
  79797. * This class represents a single physics Hinge-Joint
  79798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79799. */
  79800. export class HingeJoint extends MotorEnabledJoint {
  79801. /**
  79802. * Initializes the Hinge-Joint
  79803. * @param jointData The joint data for the Hinge-Joint
  79804. */
  79805. constructor(jointData: PhysicsJointData);
  79806. /**
  79807. * Set the motor values.
  79808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79809. * @param {number} force the force to apply
  79810. * @param {number} maxForce max force for this motor.
  79811. */
  79812. setMotor(force?: number, maxForce?: number): void;
  79813. /**
  79814. * Set the motor's limits.
  79815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79816. * @param upperLimit The upper limit of the motor
  79817. * @param lowerLimit The lower limit of the motor
  79818. */
  79819. setLimit(upperLimit: number, lowerLimit?: number): void;
  79820. }
  79821. /**
  79822. * This class represents a dual hinge physics joint (same as wheel joint)
  79823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79824. */
  79825. export class Hinge2Joint extends MotorEnabledJoint {
  79826. /**
  79827. * Initializes the Hinge2-Joint
  79828. * @param jointData The joint data for the Hinge2-Joint
  79829. */
  79830. constructor(jointData: PhysicsJointData);
  79831. /**
  79832. * Set the motor values.
  79833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79834. * @param {number} targetSpeed the speed the motor is to reach
  79835. * @param {number} maxForce max force for this motor.
  79836. * @param {motorIndex} the motor's index, 0 or 1.
  79837. */
  79838. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79839. /**
  79840. * Set the motor limits.
  79841. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79842. * @param {number} upperLimit the upper limit
  79843. * @param {number} lowerLimit lower limit
  79844. * @param {motorIndex} the motor's index, 0 or 1.
  79845. */
  79846. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79847. }
  79848. /**
  79849. * Interface for a motor enabled joint
  79850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79851. */
  79852. export interface IMotorEnabledJoint {
  79853. /**
  79854. * Physics joint
  79855. */
  79856. physicsJoint: any;
  79857. /**
  79858. * Sets the motor of the motor-enabled joint
  79859. * @param force The force of the motor
  79860. * @param maxForce The maximum force of the motor
  79861. * @param motorIndex The index of the motor
  79862. */
  79863. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79864. /**
  79865. * Sets the limit of the motor
  79866. * @param upperLimit The upper limit of the motor
  79867. * @param lowerLimit The lower limit of the motor
  79868. * @param motorIndex The index of the motor
  79869. */
  79870. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79871. }
  79872. /**
  79873. * Joint data for a Distance-Joint
  79874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79875. */
  79876. export interface DistanceJointData extends PhysicsJointData {
  79877. /**
  79878. * Max distance the 2 joint objects can be apart
  79879. */
  79880. maxDistance: number;
  79881. }
  79882. /**
  79883. * Joint data from a spring joint
  79884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79885. */
  79886. export interface SpringJointData extends PhysicsJointData {
  79887. /**
  79888. * Length of the spring
  79889. */
  79890. length: number;
  79891. /**
  79892. * Stiffness of the spring
  79893. */
  79894. stiffness: number;
  79895. /**
  79896. * Damping of the spring
  79897. */
  79898. damping: number;
  79899. /** this callback will be called when applying the force to the impostors. */
  79900. forceApplicationCallback: () => void;
  79901. }
  79902. }
  79903. declare module BABYLON {
  79904. /**
  79905. * Holds the data for the raycast result
  79906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79907. */
  79908. export class PhysicsRaycastResult {
  79909. private _hasHit;
  79910. private _hitDistance;
  79911. private _hitNormalWorld;
  79912. private _hitPointWorld;
  79913. private _rayFromWorld;
  79914. private _rayToWorld;
  79915. /**
  79916. * Gets if there was a hit
  79917. */
  79918. readonly hasHit: boolean;
  79919. /**
  79920. * Gets the distance from the hit
  79921. */
  79922. readonly hitDistance: number;
  79923. /**
  79924. * Gets the hit normal/direction in the world
  79925. */
  79926. readonly hitNormalWorld: Vector3;
  79927. /**
  79928. * Gets the hit point in the world
  79929. */
  79930. readonly hitPointWorld: Vector3;
  79931. /**
  79932. * Gets the ray "start point" of the ray in the world
  79933. */
  79934. readonly rayFromWorld: Vector3;
  79935. /**
  79936. * Gets the ray "end point" of the ray in the world
  79937. */
  79938. readonly rayToWorld: Vector3;
  79939. /**
  79940. * Sets the hit data (normal & point in world space)
  79941. * @param hitNormalWorld defines the normal in world space
  79942. * @param hitPointWorld defines the point in world space
  79943. */
  79944. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79945. /**
  79946. * Sets the distance from the start point to the hit point
  79947. * @param distance
  79948. */
  79949. setHitDistance(distance: number): void;
  79950. /**
  79951. * Calculates the distance manually
  79952. */
  79953. calculateHitDistance(): void;
  79954. /**
  79955. * Resets all the values to default
  79956. * @param from The from point on world space
  79957. * @param to The to point on world space
  79958. */
  79959. reset(from?: Vector3, to?: Vector3): void;
  79960. }
  79961. /**
  79962. * Interface for the size containing width and height
  79963. */
  79964. interface IXYZ {
  79965. /**
  79966. * X
  79967. */
  79968. x: number;
  79969. /**
  79970. * Y
  79971. */
  79972. y: number;
  79973. /**
  79974. * Z
  79975. */
  79976. z: number;
  79977. }
  79978. }
  79979. declare module BABYLON {
  79980. /**
  79981. * Interface used to describe a physics joint
  79982. */
  79983. export interface PhysicsImpostorJoint {
  79984. /** Defines the main impostor to which the joint is linked */
  79985. mainImpostor: PhysicsImpostor;
  79986. /** Defines the impostor that is connected to the main impostor using this joint */
  79987. connectedImpostor: PhysicsImpostor;
  79988. /** Defines the joint itself */
  79989. joint: PhysicsJoint;
  79990. }
  79991. /** @hidden */
  79992. export interface IPhysicsEnginePlugin {
  79993. world: any;
  79994. name: string;
  79995. setGravity(gravity: Vector3): void;
  79996. setTimeStep(timeStep: number): void;
  79997. getTimeStep(): number;
  79998. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79999. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80000. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80001. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80002. removePhysicsBody(impostor: PhysicsImpostor): void;
  80003. generateJoint(joint: PhysicsImpostorJoint): void;
  80004. removeJoint(joint: PhysicsImpostorJoint): void;
  80005. isSupported(): boolean;
  80006. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80007. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80008. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80009. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80010. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80011. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80012. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80013. getBodyMass(impostor: PhysicsImpostor): number;
  80014. getBodyFriction(impostor: PhysicsImpostor): number;
  80015. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80016. getBodyRestitution(impostor: PhysicsImpostor): number;
  80017. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80018. getBodyPressure?(impostor: PhysicsImpostor): number;
  80019. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80020. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80021. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80022. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80023. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80024. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80025. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80026. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80027. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80028. sleepBody(impostor: PhysicsImpostor): void;
  80029. wakeUpBody(impostor: PhysicsImpostor): void;
  80030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80031. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80032. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80033. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80034. getRadius(impostor: PhysicsImpostor): number;
  80035. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80036. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80037. dispose(): void;
  80038. }
  80039. /**
  80040. * Interface used to define a physics engine
  80041. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80042. */
  80043. export interface IPhysicsEngine {
  80044. /**
  80045. * Gets the gravity vector used by the simulation
  80046. */
  80047. gravity: Vector3;
  80048. /**
  80049. * Sets the gravity vector used by the simulation
  80050. * @param gravity defines the gravity vector to use
  80051. */
  80052. setGravity(gravity: Vector3): void;
  80053. /**
  80054. * Set the time step of the physics engine.
  80055. * Default is 1/60.
  80056. * To slow it down, enter 1/600 for example.
  80057. * To speed it up, 1/30
  80058. * @param newTimeStep the new timestep to apply to this world.
  80059. */
  80060. setTimeStep(newTimeStep: number): void;
  80061. /**
  80062. * Get the time step of the physics engine.
  80063. * @returns the current time step
  80064. */
  80065. getTimeStep(): number;
  80066. /**
  80067. * Release all resources
  80068. */
  80069. dispose(): void;
  80070. /**
  80071. * Gets the name of the current physics plugin
  80072. * @returns the name of the plugin
  80073. */
  80074. getPhysicsPluginName(): string;
  80075. /**
  80076. * Adding a new impostor for the impostor tracking.
  80077. * This will be done by the impostor itself.
  80078. * @param impostor the impostor to add
  80079. */
  80080. addImpostor(impostor: PhysicsImpostor): void;
  80081. /**
  80082. * Remove an impostor from the engine.
  80083. * This impostor and its mesh will not longer be updated by the physics engine.
  80084. * @param impostor the impostor to remove
  80085. */
  80086. removeImpostor(impostor: PhysicsImpostor): void;
  80087. /**
  80088. * Add a joint to the physics engine
  80089. * @param mainImpostor defines the main impostor to which the joint is added.
  80090. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80091. * @param joint defines the joint that will connect both impostors.
  80092. */
  80093. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80094. /**
  80095. * Removes a joint from the simulation
  80096. * @param mainImpostor defines the impostor used with the joint
  80097. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80098. * @param joint defines the joint to remove
  80099. */
  80100. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80101. /**
  80102. * Gets the current plugin used to run the simulation
  80103. * @returns current plugin
  80104. */
  80105. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80106. /**
  80107. * Gets the list of physic impostors
  80108. * @returns an array of PhysicsImpostor
  80109. */
  80110. getImpostors(): Array<PhysicsImpostor>;
  80111. /**
  80112. * Gets the impostor for a physics enabled object
  80113. * @param object defines the object impersonated by the impostor
  80114. * @returns the PhysicsImpostor or null if not found
  80115. */
  80116. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80117. /**
  80118. * Gets the impostor for a physics body object
  80119. * @param body defines physics body used by the impostor
  80120. * @returns the PhysicsImpostor or null if not found
  80121. */
  80122. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80123. /**
  80124. * Does a raycast in the physics world
  80125. * @param from when should the ray start?
  80126. * @param to when should the ray end?
  80127. * @returns PhysicsRaycastResult
  80128. */
  80129. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80130. /**
  80131. * Called by the scene. No need to call it.
  80132. * @param delta defines the timespam between frames
  80133. */
  80134. _step(delta: number): void;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /**
  80139. * The interface for the physics imposter parameters
  80140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80141. */
  80142. export interface PhysicsImpostorParameters {
  80143. /**
  80144. * The mass of the physics imposter
  80145. */
  80146. mass: number;
  80147. /**
  80148. * The friction of the physics imposter
  80149. */
  80150. friction?: number;
  80151. /**
  80152. * The coefficient of restitution of the physics imposter
  80153. */
  80154. restitution?: number;
  80155. /**
  80156. * The native options of the physics imposter
  80157. */
  80158. nativeOptions?: any;
  80159. /**
  80160. * Specifies if the parent should be ignored
  80161. */
  80162. ignoreParent?: boolean;
  80163. /**
  80164. * Specifies if bi-directional transformations should be disabled
  80165. */
  80166. disableBidirectionalTransformation?: boolean;
  80167. /**
  80168. * The pressure inside the physics imposter, soft object only
  80169. */
  80170. pressure?: number;
  80171. /**
  80172. * The stiffness the physics imposter, soft object only
  80173. */
  80174. stiffness?: number;
  80175. /**
  80176. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80177. */
  80178. velocityIterations?: number;
  80179. /**
  80180. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80181. */
  80182. positionIterations?: number;
  80183. /**
  80184. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80185. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80186. * Add to fix multiple points
  80187. */
  80188. fixedPoints?: number;
  80189. /**
  80190. * The collision margin around a soft object
  80191. */
  80192. margin?: number;
  80193. /**
  80194. * The collision margin around a soft object
  80195. */
  80196. damping?: number;
  80197. /**
  80198. * The path for a rope based on an extrusion
  80199. */
  80200. path?: any;
  80201. /**
  80202. * The shape of an extrusion used for a rope based on an extrusion
  80203. */
  80204. shape?: any;
  80205. }
  80206. /**
  80207. * Interface for a physics-enabled object
  80208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80209. */
  80210. export interface IPhysicsEnabledObject {
  80211. /**
  80212. * The position of the physics-enabled object
  80213. */
  80214. position: Vector3;
  80215. /**
  80216. * The rotation of the physics-enabled object
  80217. */
  80218. rotationQuaternion: Nullable<Quaternion>;
  80219. /**
  80220. * The scale of the physics-enabled object
  80221. */
  80222. scaling: Vector3;
  80223. /**
  80224. * The rotation of the physics-enabled object
  80225. */
  80226. rotation?: Vector3;
  80227. /**
  80228. * The parent of the physics-enabled object
  80229. */
  80230. parent?: any;
  80231. /**
  80232. * The bounding info of the physics-enabled object
  80233. * @returns The bounding info of the physics-enabled object
  80234. */
  80235. getBoundingInfo(): BoundingInfo;
  80236. /**
  80237. * Computes the world matrix
  80238. * @param force Specifies if the world matrix should be computed by force
  80239. * @returns A world matrix
  80240. */
  80241. computeWorldMatrix(force: boolean): Matrix;
  80242. /**
  80243. * Gets the world matrix
  80244. * @returns A world matrix
  80245. */
  80246. getWorldMatrix?(): Matrix;
  80247. /**
  80248. * Gets the child meshes
  80249. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80250. * @returns An array of abstract meshes
  80251. */
  80252. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80253. /**
  80254. * Gets the vertex data
  80255. * @param kind The type of vertex data
  80256. * @returns A nullable array of numbers, or a float32 array
  80257. */
  80258. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80259. /**
  80260. * Gets the indices from the mesh
  80261. * @returns A nullable array of index arrays
  80262. */
  80263. getIndices?(): Nullable<IndicesArray>;
  80264. /**
  80265. * Gets the scene from the mesh
  80266. * @returns the indices array or null
  80267. */
  80268. getScene?(): Scene;
  80269. /**
  80270. * Gets the absolute position from the mesh
  80271. * @returns the absolute position
  80272. */
  80273. getAbsolutePosition(): Vector3;
  80274. /**
  80275. * Gets the absolute pivot point from the mesh
  80276. * @returns the absolute pivot point
  80277. */
  80278. getAbsolutePivotPoint(): Vector3;
  80279. /**
  80280. * Rotates the mesh
  80281. * @param axis The axis of rotation
  80282. * @param amount The amount of rotation
  80283. * @param space The space of the rotation
  80284. * @returns The rotation transform node
  80285. */
  80286. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80287. /**
  80288. * Translates the mesh
  80289. * @param axis The axis of translation
  80290. * @param distance The distance of translation
  80291. * @param space The space of the translation
  80292. * @returns The transform node
  80293. */
  80294. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80295. /**
  80296. * Sets the absolute position of the mesh
  80297. * @param absolutePosition The absolute position of the mesh
  80298. * @returns The transform node
  80299. */
  80300. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80301. /**
  80302. * Gets the class name of the mesh
  80303. * @returns The class name
  80304. */
  80305. getClassName(): string;
  80306. }
  80307. /**
  80308. * Represents a physics imposter
  80309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80310. */
  80311. export class PhysicsImpostor {
  80312. /**
  80313. * The physics-enabled object used as the physics imposter
  80314. */
  80315. object: IPhysicsEnabledObject;
  80316. /**
  80317. * The type of the physics imposter
  80318. */
  80319. type: number;
  80320. private _options;
  80321. private _scene?;
  80322. /**
  80323. * The default object size of the imposter
  80324. */
  80325. static DEFAULT_OBJECT_SIZE: Vector3;
  80326. /**
  80327. * The identity quaternion of the imposter
  80328. */
  80329. static IDENTITY_QUATERNION: Quaternion;
  80330. /** @hidden */
  80331. _pluginData: any;
  80332. private _physicsEngine;
  80333. private _physicsBody;
  80334. private _bodyUpdateRequired;
  80335. private _onBeforePhysicsStepCallbacks;
  80336. private _onAfterPhysicsStepCallbacks;
  80337. /** @hidden */
  80338. _onPhysicsCollideCallbacks: Array<{
  80339. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80340. otherImpostors: Array<PhysicsImpostor>;
  80341. }>;
  80342. private _deltaPosition;
  80343. private _deltaRotation;
  80344. private _deltaRotationConjugated;
  80345. /** hidden */
  80346. _isFromLine: boolean;
  80347. private _parent;
  80348. private _isDisposed;
  80349. private static _tmpVecs;
  80350. private static _tmpQuat;
  80351. /**
  80352. * Specifies if the physics imposter is disposed
  80353. */
  80354. readonly isDisposed: boolean;
  80355. /**
  80356. * Gets the mass of the physics imposter
  80357. */
  80358. mass: number;
  80359. /**
  80360. * Gets the coefficient of friction
  80361. */
  80362. /**
  80363. * Sets the coefficient of friction
  80364. */
  80365. friction: number;
  80366. /**
  80367. * Gets the coefficient of restitution
  80368. */
  80369. /**
  80370. * Sets the coefficient of restitution
  80371. */
  80372. restitution: number;
  80373. /**
  80374. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80375. */
  80376. /**
  80377. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80378. */
  80379. pressure: number;
  80380. /**
  80381. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80382. */
  80383. /**
  80384. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80385. */
  80386. stiffness: number;
  80387. /**
  80388. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80389. */
  80390. /**
  80391. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80392. */
  80393. velocityIterations: number;
  80394. /**
  80395. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80396. */
  80397. /**
  80398. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80399. */
  80400. positionIterations: number;
  80401. /**
  80402. * The unique id of the physics imposter
  80403. * set by the physics engine when adding this impostor to the array
  80404. */
  80405. uniqueId: number;
  80406. /**
  80407. * @hidden
  80408. */
  80409. soft: boolean;
  80410. /**
  80411. * @hidden
  80412. */
  80413. segments: number;
  80414. private _joints;
  80415. /**
  80416. * Initializes the physics imposter
  80417. * @param object The physics-enabled object used as the physics imposter
  80418. * @param type The type of the physics imposter
  80419. * @param _options The options for the physics imposter
  80420. * @param _scene The Babylon scene
  80421. */
  80422. constructor(
  80423. /**
  80424. * The physics-enabled object used as the physics imposter
  80425. */
  80426. object: IPhysicsEnabledObject,
  80427. /**
  80428. * The type of the physics imposter
  80429. */
  80430. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80431. /**
  80432. * This function will completly initialize this impostor.
  80433. * It will create a new body - but only if this mesh has no parent.
  80434. * If it has, this impostor will not be used other than to define the impostor
  80435. * of the child mesh.
  80436. * @hidden
  80437. */
  80438. _init(): void;
  80439. private _getPhysicsParent;
  80440. /**
  80441. * Should a new body be generated.
  80442. * @returns boolean specifying if body initialization is required
  80443. */
  80444. isBodyInitRequired(): boolean;
  80445. /**
  80446. * Sets the updated scaling
  80447. * @param updated Specifies if the scaling is updated
  80448. */
  80449. setScalingUpdated(): void;
  80450. /**
  80451. * Force a regeneration of this or the parent's impostor's body.
  80452. * Use under cautious - This will remove all joints already implemented.
  80453. */
  80454. forceUpdate(): void;
  80455. /**
  80456. * Gets the body that holds this impostor. Either its own, or its parent.
  80457. */
  80458. /**
  80459. * Set the physics body. Used mainly by the physics engine/plugin
  80460. */
  80461. physicsBody: any;
  80462. /**
  80463. * Get the parent of the physics imposter
  80464. * @returns Physics imposter or null
  80465. */
  80466. /**
  80467. * Sets the parent of the physics imposter
  80468. */
  80469. parent: Nullable<PhysicsImpostor>;
  80470. /**
  80471. * Resets the update flags
  80472. */
  80473. resetUpdateFlags(): void;
  80474. /**
  80475. * Gets the object extend size
  80476. * @returns the object extend size
  80477. */
  80478. getObjectExtendSize(): Vector3;
  80479. /**
  80480. * Gets the object center
  80481. * @returns The object center
  80482. */
  80483. getObjectCenter(): Vector3;
  80484. /**
  80485. * Get a specific parametes from the options parameter
  80486. * @param paramName The object parameter name
  80487. * @returns The object parameter
  80488. */
  80489. getParam(paramName: string): any;
  80490. /**
  80491. * Sets a specific parameter in the options given to the physics plugin
  80492. * @param paramName The parameter name
  80493. * @param value The value of the parameter
  80494. */
  80495. setParam(paramName: string, value: number): void;
  80496. /**
  80497. * Specifically change the body's mass option. Won't recreate the physics body object
  80498. * @param mass The mass of the physics imposter
  80499. */
  80500. setMass(mass: number): void;
  80501. /**
  80502. * Gets the linear velocity
  80503. * @returns linear velocity or null
  80504. */
  80505. getLinearVelocity(): Nullable<Vector3>;
  80506. /**
  80507. * Sets the linear velocity
  80508. * @param velocity linear velocity or null
  80509. */
  80510. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80511. /**
  80512. * Gets the angular velocity
  80513. * @returns angular velocity or null
  80514. */
  80515. getAngularVelocity(): Nullable<Vector3>;
  80516. /**
  80517. * Sets the angular velocity
  80518. * @param velocity The velocity or null
  80519. */
  80520. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80521. /**
  80522. * Execute a function with the physics plugin native code
  80523. * Provide a function the will have two variables - the world object and the physics body object
  80524. * @param func The function to execute with the physics plugin native code
  80525. */
  80526. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80527. /**
  80528. * Register a function that will be executed before the physics world is stepping forward
  80529. * @param func The function to execute before the physics world is stepped forward
  80530. */
  80531. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80532. /**
  80533. * Unregister a function that will be executed before the physics world is stepping forward
  80534. * @param func The function to execute before the physics world is stepped forward
  80535. */
  80536. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80537. /**
  80538. * Register a function that will be executed after the physics step
  80539. * @param func The function to execute after physics step
  80540. */
  80541. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80542. /**
  80543. * Unregisters a function that will be executed after the physics step
  80544. * @param func The function to execute after physics step
  80545. */
  80546. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80547. /**
  80548. * register a function that will be executed when this impostor collides against a different body
  80549. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80550. * @param func Callback that is executed on collision
  80551. */
  80552. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80553. /**
  80554. * Unregisters the physics imposter on contact
  80555. * @param collideAgainst The physics object to collide against
  80556. * @param func Callback to execute on collision
  80557. */
  80558. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80559. private _tmpQuat;
  80560. private _tmpQuat2;
  80561. /**
  80562. * Get the parent rotation
  80563. * @returns The parent rotation
  80564. */
  80565. getParentsRotation(): Quaternion;
  80566. /**
  80567. * this function is executed by the physics engine.
  80568. */
  80569. beforeStep: () => void;
  80570. /**
  80571. * this function is executed by the physics engine
  80572. */
  80573. afterStep: () => void;
  80574. /**
  80575. * Legacy collision detection event support
  80576. */
  80577. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80578. /**
  80579. * event and body object due to cannon's event-based architecture.
  80580. */
  80581. onCollide: (e: {
  80582. body: any;
  80583. }) => void;
  80584. /**
  80585. * Apply a force
  80586. * @param force The force to apply
  80587. * @param contactPoint The contact point for the force
  80588. * @returns The physics imposter
  80589. */
  80590. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80591. /**
  80592. * Apply an impulse
  80593. * @param force The impulse force
  80594. * @param contactPoint The contact point for the impulse force
  80595. * @returns The physics imposter
  80596. */
  80597. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80598. /**
  80599. * A help function to create a joint
  80600. * @param otherImpostor A physics imposter used to create a joint
  80601. * @param jointType The type of joint
  80602. * @param jointData The data for the joint
  80603. * @returns The physics imposter
  80604. */
  80605. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80606. /**
  80607. * Add a joint to this impostor with a different impostor
  80608. * @param otherImpostor A physics imposter used to add a joint
  80609. * @param joint The joint to add
  80610. * @returns The physics imposter
  80611. */
  80612. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80613. /**
  80614. * Add an anchor to a cloth impostor
  80615. * @param otherImpostor rigid impostor to anchor to
  80616. * @param width ratio across width from 0 to 1
  80617. * @param height ratio up height from 0 to 1
  80618. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80619. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80620. * @returns impostor the soft imposter
  80621. */
  80622. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80623. /**
  80624. * Add a hook to a rope impostor
  80625. * @param otherImpostor rigid impostor to anchor to
  80626. * @param length ratio across rope from 0 to 1
  80627. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80628. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80629. * @returns impostor the rope imposter
  80630. */
  80631. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80632. /**
  80633. * Will keep this body still, in a sleep mode.
  80634. * @returns the physics imposter
  80635. */
  80636. sleep(): PhysicsImpostor;
  80637. /**
  80638. * Wake the body up.
  80639. * @returns The physics imposter
  80640. */
  80641. wakeUp(): PhysicsImpostor;
  80642. /**
  80643. * Clones the physics imposter
  80644. * @param newObject The physics imposter clones to this physics-enabled object
  80645. * @returns A nullable physics imposter
  80646. */
  80647. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80648. /**
  80649. * Disposes the physics imposter
  80650. */
  80651. dispose(): void;
  80652. /**
  80653. * Sets the delta position
  80654. * @param position The delta position amount
  80655. */
  80656. setDeltaPosition(position: Vector3): void;
  80657. /**
  80658. * Sets the delta rotation
  80659. * @param rotation The delta rotation amount
  80660. */
  80661. setDeltaRotation(rotation: Quaternion): void;
  80662. /**
  80663. * Gets the box size of the physics imposter and stores the result in the input parameter
  80664. * @param result Stores the box size
  80665. * @returns The physics imposter
  80666. */
  80667. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80668. /**
  80669. * Gets the radius of the physics imposter
  80670. * @returns Radius of the physics imposter
  80671. */
  80672. getRadius(): number;
  80673. /**
  80674. * Sync a bone with this impostor
  80675. * @param bone The bone to sync to the impostor.
  80676. * @param boneMesh The mesh that the bone is influencing.
  80677. * @param jointPivot The pivot of the joint / bone in local space.
  80678. * @param distToJoint Optional distance from the impostor to the joint.
  80679. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80680. */
  80681. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80682. /**
  80683. * Sync impostor to a bone
  80684. * @param bone The bone that the impostor will be synced to.
  80685. * @param boneMesh The mesh that the bone is influencing.
  80686. * @param jointPivot The pivot of the joint / bone in local space.
  80687. * @param distToJoint Optional distance from the impostor to the joint.
  80688. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80689. * @param boneAxis Optional vector3 axis the bone is aligned with
  80690. */
  80691. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80692. /**
  80693. * No-Imposter type
  80694. */
  80695. static NoImpostor: number;
  80696. /**
  80697. * Sphere-Imposter type
  80698. */
  80699. static SphereImpostor: number;
  80700. /**
  80701. * Box-Imposter type
  80702. */
  80703. static BoxImpostor: number;
  80704. /**
  80705. * Plane-Imposter type
  80706. */
  80707. static PlaneImpostor: number;
  80708. /**
  80709. * Mesh-imposter type
  80710. */
  80711. static MeshImpostor: number;
  80712. /**
  80713. * Cylinder-Imposter type
  80714. */
  80715. static CylinderImpostor: number;
  80716. /**
  80717. * Particle-Imposter type
  80718. */
  80719. static ParticleImpostor: number;
  80720. /**
  80721. * Heightmap-Imposter type
  80722. */
  80723. static HeightmapImpostor: number;
  80724. /**
  80725. * ConvexHull-Impostor type (Ammo.js plugin only)
  80726. */
  80727. static ConvexHullImpostor: number;
  80728. /**
  80729. * Rope-Imposter type
  80730. */
  80731. static RopeImpostor: number;
  80732. /**
  80733. * Cloth-Imposter type
  80734. */
  80735. static ClothImpostor: number;
  80736. /**
  80737. * Softbody-Imposter type
  80738. */
  80739. static SoftbodyImpostor: number;
  80740. }
  80741. }
  80742. declare module BABYLON {
  80743. /**
  80744. * @hidden
  80745. **/
  80746. export class _CreationDataStorage {
  80747. closePath?: boolean;
  80748. closeArray?: boolean;
  80749. idx: number[];
  80750. dashSize: number;
  80751. gapSize: number;
  80752. path3D: Path3D;
  80753. pathArray: Vector3[][];
  80754. arc: number;
  80755. radius: number;
  80756. cap: number;
  80757. tessellation: number;
  80758. }
  80759. /**
  80760. * @hidden
  80761. **/
  80762. class _InstanceDataStorage {
  80763. visibleInstances: any;
  80764. batchCache: _InstancesBatch;
  80765. instancesBufferSize: number;
  80766. instancesBuffer: Nullable<Buffer>;
  80767. instancesData: Float32Array;
  80768. overridenInstanceCount: number;
  80769. isFrozen: boolean;
  80770. previousBatch: _InstancesBatch;
  80771. hardwareInstancedRendering: boolean;
  80772. sideOrientation: number;
  80773. }
  80774. /**
  80775. * @hidden
  80776. **/
  80777. export class _InstancesBatch {
  80778. mustReturn: boolean;
  80779. visibleInstances: Nullable<InstancedMesh[]>[];
  80780. renderSelf: boolean[];
  80781. hardwareInstancedRendering: boolean[];
  80782. }
  80783. /**
  80784. * Class used to represent renderable models
  80785. */
  80786. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80787. /**
  80788. * Mesh side orientation : usually the external or front surface
  80789. */
  80790. static readonly FRONTSIDE: number;
  80791. /**
  80792. * Mesh side orientation : usually the internal or back surface
  80793. */
  80794. static readonly BACKSIDE: number;
  80795. /**
  80796. * Mesh side orientation : both internal and external or front and back surfaces
  80797. */
  80798. static readonly DOUBLESIDE: number;
  80799. /**
  80800. * Mesh side orientation : by default, `FRONTSIDE`
  80801. */
  80802. static readonly DEFAULTSIDE: number;
  80803. /**
  80804. * Mesh cap setting : no cap
  80805. */
  80806. static readonly NO_CAP: number;
  80807. /**
  80808. * Mesh cap setting : one cap at the beginning of the mesh
  80809. */
  80810. static readonly CAP_START: number;
  80811. /**
  80812. * Mesh cap setting : one cap at the end of the mesh
  80813. */
  80814. static readonly CAP_END: number;
  80815. /**
  80816. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80817. */
  80818. static readonly CAP_ALL: number;
  80819. /**
  80820. * Gets the default side orientation.
  80821. * @param orientation the orientation to value to attempt to get
  80822. * @returns the default orientation
  80823. * @hidden
  80824. */
  80825. static _GetDefaultSideOrientation(orientation?: number): number;
  80826. private _internalMeshDataInfo;
  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. /**
  80867. * User defined function used to change how LOD level selection is done
  80868. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80869. */
  80870. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80871. /**
  80872. * Gets or sets the morph target manager
  80873. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80874. */
  80875. morphTargetManager: Nullable<MorphTargetManager>;
  80876. /** @hidden */
  80877. _creationDataStorage: Nullable<_CreationDataStorage>;
  80878. /** @hidden */
  80879. _geometry: Nullable<Geometry>;
  80880. /** @hidden */
  80881. _delayInfo: Array<string>;
  80882. /** @hidden */
  80883. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80884. /** @hidden */
  80885. _instanceDataStorage: _InstanceDataStorage;
  80886. private _effectiveMaterial;
  80887. /** @hidden */
  80888. _shouldGenerateFlatShading: boolean;
  80889. /** @hidden */
  80890. _originalBuilderSideOrientation: number;
  80891. /**
  80892. * Use this property to change the original side orientation defined at construction time
  80893. */
  80894. overrideMaterialSideOrientation: Nullable<number>;
  80895. /**
  80896. * Gets the source mesh (the one used to clone this one from)
  80897. */
  80898. readonly source: Nullable<Mesh>;
  80899. /**
  80900. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80901. */
  80902. isUnIndexed: boolean;
  80903. /**
  80904. * @constructor
  80905. * @param name The value used by scene.getMeshByName() to do a lookup.
  80906. * @param scene The scene to add this mesh to.
  80907. * @param parent The parent of this mesh, if it has one
  80908. * @param source An optional Mesh from which geometry is shared, cloned.
  80909. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80910. * When false, achieved by calling a clone(), also passing False.
  80911. * This will make creation of children, recursive.
  80912. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80913. */
  80914. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80915. /**
  80916. * Gets the class name
  80917. * @returns the string "Mesh".
  80918. */
  80919. getClassName(): string;
  80920. /** @hidden */
  80921. readonly _isMesh: boolean;
  80922. /**
  80923. * Returns a description of this mesh
  80924. * @param fullDetails define if full details about this mesh must be used
  80925. * @returns a descriptive string representing this mesh
  80926. */
  80927. toString(fullDetails?: boolean): string;
  80928. /** @hidden */
  80929. _unBindEffect(): void;
  80930. /**
  80931. * Gets a boolean indicating if this mesh has LOD
  80932. */
  80933. readonly hasLODLevels: boolean;
  80934. /**
  80935. * Gets the list of MeshLODLevel associated with the current mesh
  80936. * @returns an array of MeshLODLevel
  80937. */
  80938. getLODLevels(): MeshLODLevel[];
  80939. private _sortLODLevels;
  80940. /**
  80941. * Add a mesh as LOD level triggered at the given distance.
  80942. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80943. * @param distance The distance from the center of the object to show this level
  80944. * @param mesh The mesh to be added as LOD level (can be null)
  80945. * @return This mesh (for chaining)
  80946. */
  80947. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80948. /**
  80949. * Returns the LOD level mesh at the passed distance or null if not found.
  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. * @returns a Mesh or `null`
  80953. */
  80954. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80955. /**
  80956. * Remove a mesh from the LOD array
  80957. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80958. * @param mesh defines the mesh to be removed
  80959. * @return This mesh (for chaining)
  80960. */
  80961. removeLODLevel(mesh: Mesh): Mesh;
  80962. /**
  80963. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80964. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80965. * @param camera defines the camera to use to compute distance
  80966. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80967. * @return This mesh (for chaining)
  80968. */
  80969. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80970. /**
  80971. * Gets the mesh internal Geometry object
  80972. */
  80973. readonly geometry: Nullable<Geometry>;
  80974. /**
  80975. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80976. * @returns the total number of vertices
  80977. */
  80978. getTotalVertices(): number;
  80979. /**
  80980. * Returns the content of an associated vertex buffer
  80981. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80982. * - VertexBuffer.PositionKind
  80983. * - VertexBuffer.UVKind
  80984. * - VertexBuffer.UV2Kind
  80985. * - VertexBuffer.UV3Kind
  80986. * - VertexBuffer.UV4Kind
  80987. * - VertexBuffer.UV5Kind
  80988. * - VertexBuffer.UV6Kind
  80989. * - VertexBuffer.ColorKind
  80990. * - VertexBuffer.MatricesIndicesKind
  80991. * - VertexBuffer.MatricesIndicesExtraKind
  80992. * - VertexBuffer.MatricesWeightsKind
  80993. * - VertexBuffer.MatricesWeightsExtraKind
  80994. * @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
  80995. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80996. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80997. */
  80998. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80999. /**
  81000. * Returns the mesh VertexBuffer object from the requested `kind`
  81001. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81002. * - VertexBuffer.PositionKind
  81003. * - VertexBuffer.UVKind
  81004. * - VertexBuffer.UV2Kind
  81005. * - VertexBuffer.UV3Kind
  81006. * - VertexBuffer.UV4Kind
  81007. * - VertexBuffer.UV5Kind
  81008. * - VertexBuffer.UV6Kind
  81009. * - VertexBuffer.ColorKind
  81010. * - VertexBuffer.MatricesIndicesKind
  81011. * - VertexBuffer.MatricesIndicesExtraKind
  81012. * - VertexBuffer.MatricesWeightsKind
  81013. * - VertexBuffer.MatricesWeightsExtraKind
  81014. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81015. */
  81016. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81017. /**
  81018. * Tests if a specific vertex buffer is associated with this mesh
  81019. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81020. * - VertexBuffer.PositionKind
  81021. * - VertexBuffer.UVKind
  81022. * - VertexBuffer.UV2Kind
  81023. * - VertexBuffer.UV3Kind
  81024. * - VertexBuffer.UV4Kind
  81025. * - VertexBuffer.UV5Kind
  81026. * - VertexBuffer.UV6Kind
  81027. * - VertexBuffer.ColorKind
  81028. * - VertexBuffer.MatricesIndicesKind
  81029. * - VertexBuffer.MatricesIndicesExtraKind
  81030. * - VertexBuffer.MatricesWeightsKind
  81031. * - VertexBuffer.MatricesWeightsExtraKind
  81032. * @returns a boolean
  81033. */
  81034. isVerticesDataPresent(kind: string): boolean;
  81035. /**
  81036. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81037. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81038. * - VertexBuffer.PositionKind
  81039. * - VertexBuffer.UVKind
  81040. * - VertexBuffer.UV2Kind
  81041. * - VertexBuffer.UV3Kind
  81042. * - VertexBuffer.UV4Kind
  81043. * - VertexBuffer.UV5Kind
  81044. * - VertexBuffer.UV6Kind
  81045. * - VertexBuffer.ColorKind
  81046. * - VertexBuffer.MatricesIndicesKind
  81047. * - VertexBuffer.MatricesIndicesExtraKind
  81048. * - VertexBuffer.MatricesWeightsKind
  81049. * - VertexBuffer.MatricesWeightsExtraKind
  81050. * @returns a boolean
  81051. */
  81052. isVertexBufferUpdatable(kind: string): boolean;
  81053. /**
  81054. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81055. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81056. * - VertexBuffer.PositionKind
  81057. * - VertexBuffer.UVKind
  81058. * - VertexBuffer.UV2Kind
  81059. * - VertexBuffer.UV3Kind
  81060. * - VertexBuffer.UV4Kind
  81061. * - VertexBuffer.UV5Kind
  81062. * - VertexBuffer.UV6Kind
  81063. * - VertexBuffer.ColorKind
  81064. * - VertexBuffer.MatricesIndicesKind
  81065. * - VertexBuffer.MatricesIndicesExtraKind
  81066. * - VertexBuffer.MatricesWeightsKind
  81067. * - VertexBuffer.MatricesWeightsExtraKind
  81068. * @returns an array of strings
  81069. */
  81070. getVerticesDataKinds(): string[];
  81071. /**
  81072. * Returns a positive integer : the total number of indices in this mesh geometry.
  81073. * @returns the numner of indices or zero if the mesh has no geometry.
  81074. */
  81075. getTotalIndices(): number;
  81076. /**
  81077. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81078. * @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.
  81079. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81080. * @returns the indices array or an empty array if the mesh has no geometry
  81081. */
  81082. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81083. readonly isBlocked: boolean;
  81084. /**
  81085. * Determine if the current mesh is ready to be rendered
  81086. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81087. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81088. * @returns true if all associated assets are ready (material, textures, shaders)
  81089. */
  81090. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81091. /**
  81092. * 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.
  81093. */
  81094. readonly areNormalsFrozen: boolean;
  81095. /**
  81096. * 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.
  81097. * @returns the current mesh
  81098. */
  81099. freezeNormals(): Mesh;
  81100. /**
  81101. * 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
  81102. * @returns the current mesh
  81103. */
  81104. unfreezeNormals(): Mesh;
  81105. /**
  81106. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81107. */
  81108. overridenInstanceCount: number;
  81109. /** @hidden */
  81110. _preActivate(): Mesh;
  81111. /** @hidden */
  81112. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81113. /** @hidden */
  81114. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81115. /**
  81116. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81117. * This means the mesh underlying bounding box and sphere are recomputed.
  81118. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81119. * @returns the current mesh
  81120. */
  81121. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81122. /** @hidden */
  81123. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81124. /**
  81125. * This function will subdivide the mesh into multiple submeshes
  81126. * @param count defines the expected number of submeshes
  81127. */
  81128. subdivide(count: number): void;
  81129. /**
  81130. * Copy a FloatArray into a specific associated vertex buffer
  81131. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81132. * - VertexBuffer.PositionKind
  81133. * - VertexBuffer.UVKind
  81134. * - VertexBuffer.UV2Kind
  81135. * - VertexBuffer.UV3Kind
  81136. * - VertexBuffer.UV4Kind
  81137. * - VertexBuffer.UV5Kind
  81138. * - VertexBuffer.UV6Kind
  81139. * - VertexBuffer.ColorKind
  81140. * - VertexBuffer.MatricesIndicesKind
  81141. * - VertexBuffer.MatricesIndicesExtraKind
  81142. * - VertexBuffer.MatricesWeightsKind
  81143. * - VertexBuffer.MatricesWeightsExtraKind
  81144. * @param data defines the data source
  81145. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81146. * @param stride defines the data stride size (can be null)
  81147. * @returns the current mesh
  81148. */
  81149. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81150. /**
  81151. * Flags an associated vertex buffer as updatable
  81152. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81153. * - VertexBuffer.PositionKind
  81154. * - VertexBuffer.UVKind
  81155. * - VertexBuffer.UV2Kind
  81156. * - VertexBuffer.UV3Kind
  81157. * - VertexBuffer.UV4Kind
  81158. * - VertexBuffer.UV5Kind
  81159. * - VertexBuffer.UV6Kind
  81160. * - VertexBuffer.ColorKind
  81161. * - VertexBuffer.MatricesIndicesKind
  81162. * - VertexBuffer.MatricesIndicesExtraKind
  81163. * - VertexBuffer.MatricesWeightsKind
  81164. * - VertexBuffer.MatricesWeightsExtraKind
  81165. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81166. */
  81167. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81168. /**
  81169. * Sets the mesh global Vertex Buffer
  81170. * @param buffer defines the buffer to use
  81171. * @returns the current mesh
  81172. */
  81173. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81174. /**
  81175. * Update a specific associated vertex buffer
  81176. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81177. * - VertexBuffer.PositionKind
  81178. * - VertexBuffer.UVKind
  81179. * - VertexBuffer.UV2Kind
  81180. * - VertexBuffer.UV3Kind
  81181. * - VertexBuffer.UV4Kind
  81182. * - VertexBuffer.UV5Kind
  81183. * - VertexBuffer.UV6Kind
  81184. * - VertexBuffer.ColorKind
  81185. * - VertexBuffer.MatricesIndicesKind
  81186. * - VertexBuffer.MatricesIndicesExtraKind
  81187. * - VertexBuffer.MatricesWeightsKind
  81188. * - VertexBuffer.MatricesWeightsExtraKind
  81189. * @param data defines the data source
  81190. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81191. * @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)
  81192. * @returns the current mesh
  81193. */
  81194. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81195. /**
  81196. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81197. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81198. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81199. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81200. * @returns the current mesh
  81201. */
  81202. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81203. /**
  81204. * Creates a un-shared specific occurence of the geometry for the mesh.
  81205. * @returns the current mesh
  81206. */
  81207. makeGeometryUnique(): Mesh;
  81208. /**
  81209. * Set the index buffer of this mesh
  81210. * @param indices defines the source data
  81211. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81212. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81213. * @returns the current mesh
  81214. */
  81215. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81216. /**
  81217. * Update the current index buffer
  81218. * @param indices defines the source data
  81219. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81220. * @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)
  81221. * @returns the current mesh
  81222. */
  81223. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81224. /**
  81225. * Invert the geometry to move from a right handed system to a left handed one.
  81226. * @returns the current mesh
  81227. */
  81228. toLeftHanded(): Mesh;
  81229. /** @hidden */
  81230. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81231. /** @hidden */
  81232. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81233. /**
  81234. * Registers for this mesh a javascript function called just before the rendering process
  81235. * @param func defines the function to call before rendering this mesh
  81236. * @returns the current mesh
  81237. */
  81238. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81239. /**
  81240. * Disposes a previously registered javascript function called before the rendering
  81241. * @param func defines the function to remove
  81242. * @returns the current mesh
  81243. */
  81244. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81245. /**
  81246. * Registers for this mesh a javascript function called just after the rendering is complete
  81247. * @param func defines the function to call after rendering this mesh
  81248. * @returns the current mesh
  81249. */
  81250. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81251. /**
  81252. * Disposes a previously registered javascript function called after the rendering.
  81253. * @param func defines the function to remove
  81254. * @returns the current mesh
  81255. */
  81256. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81257. /** @hidden */
  81258. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81259. /** @hidden */
  81260. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81261. /** @hidden */
  81262. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81263. /** @hidden */
  81264. _freeze(): void;
  81265. /** @hidden */
  81266. _unFreeze(): void;
  81267. /**
  81268. * 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
  81269. * @param subMesh defines the subMesh to render
  81270. * @param enableAlphaMode defines if alpha mode can be changed
  81271. * @returns the current mesh
  81272. */
  81273. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81274. private _onBeforeDraw;
  81275. /**
  81276. * Renormalize the mesh and patch it up if there are no weights
  81277. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81278. * However in the case of zero weights then we set just a single influence to 1.
  81279. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81280. */
  81281. cleanMatrixWeights(): void;
  81282. private normalizeSkinFourWeights;
  81283. private normalizeSkinWeightsAndExtra;
  81284. /**
  81285. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81286. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81287. * the user know there was an issue with importing the mesh
  81288. * @returns a validation object with skinned, valid and report string
  81289. */
  81290. validateSkinning(): {
  81291. skinned: boolean;
  81292. valid: boolean;
  81293. report: string;
  81294. };
  81295. /** @hidden */
  81296. _checkDelayState(): Mesh;
  81297. private _queueLoad;
  81298. /**
  81299. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81300. * A mesh is in the frustum if its bounding box intersects the frustum
  81301. * @param frustumPlanes defines the frustum to test
  81302. * @returns true if the mesh is in the frustum planes
  81303. */
  81304. isInFrustum(frustumPlanes: Plane[]): boolean;
  81305. /**
  81306. * Sets the mesh material by the material or multiMaterial `id` property
  81307. * @param id is a string identifying the material or the multiMaterial
  81308. * @returns the current mesh
  81309. */
  81310. setMaterialByID(id: string): Mesh;
  81311. /**
  81312. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81313. * @returns an array of IAnimatable
  81314. */
  81315. getAnimatables(): IAnimatable[];
  81316. /**
  81317. * Modifies the mesh geometry according to the passed transformation matrix.
  81318. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81319. * The mesh normals are modified using the same transformation.
  81320. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81321. * @param transform defines the transform matrix to use
  81322. * @see http://doc.babylonjs.com/resources/baking_transformations
  81323. * @returns the current mesh
  81324. */
  81325. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81326. /**
  81327. * Modifies the mesh geometry according to its own current World Matrix.
  81328. * The mesh World Matrix is then reset.
  81329. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81330. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81331. * @see http://doc.babylonjs.com/resources/baking_transformations
  81332. * @returns the current mesh
  81333. */
  81334. bakeCurrentTransformIntoVertices(): Mesh;
  81335. /** @hidden */
  81336. readonly _positions: Nullable<Vector3[]>;
  81337. /** @hidden */
  81338. _resetPointsArrayCache(): Mesh;
  81339. /** @hidden */
  81340. _generatePointsArray(): boolean;
  81341. /**
  81342. * Returns a new Mesh object generated from the current mesh properties.
  81343. * This method must not get confused with createInstance()
  81344. * @param name is a string, the name given to the new mesh
  81345. * @param newParent can be any Node object (default `null`)
  81346. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81347. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81348. * @returns a new mesh
  81349. */
  81350. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81351. /**
  81352. * Releases resources associated with this mesh.
  81353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81355. */
  81356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81357. /**
  81358. * Modifies the mesh geometry according to a displacement map.
  81359. * 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.
  81360. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81361. * @param url is a string, the URL from the image file is to be downloaded.
  81362. * @param minHeight is the lower limit of the displacement.
  81363. * @param maxHeight is the upper limit of the displacement.
  81364. * @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.
  81365. * @param uvOffset is an optional vector2 used to offset UV.
  81366. * @param uvScale is an optional vector2 used to scale UV.
  81367. * @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.
  81368. * @returns the Mesh.
  81369. */
  81370. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81371. /**
  81372. * Modifies the mesh geometry according to a displacementMap buffer.
  81373. * 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.
  81374. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81375. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81376. * @param heightMapWidth is the width of the buffer image.
  81377. * @param heightMapHeight is the height of the buffer image.
  81378. * @param minHeight is the lower limit of the displacement.
  81379. * @param maxHeight is the upper limit of the displacement.
  81380. * @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.
  81381. * @param uvOffset is an optional vector2 used to offset UV.
  81382. * @param uvScale is an optional vector2 used to scale UV.
  81383. * @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.
  81384. * @returns the Mesh.
  81385. */
  81386. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81387. /**
  81388. * Modify the mesh to get a flat shading rendering.
  81389. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81390. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81391. * @returns current mesh
  81392. */
  81393. convertToFlatShadedMesh(): Mesh;
  81394. /**
  81395. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81396. * In other words, more vertices, no more indices and a single bigger VBO.
  81397. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81398. * @returns current mesh
  81399. */
  81400. convertToUnIndexedMesh(): Mesh;
  81401. /**
  81402. * Inverses facet orientations.
  81403. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81404. * @param flipNormals will also inverts the normals
  81405. * @returns current mesh
  81406. */
  81407. flipFaces(flipNormals?: boolean): Mesh;
  81408. /**
  81409. * Increase the number of facets and hence vertices in a mesh
  81410. * Vertex normals are interpolated from existing vertex normals
  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 numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81413. */
  81414. increaseVertices(numberPerEdge: number): void;
  81415. /**
  81416. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81417. * This will undo any application of covertToFlatShadedMesh
  81418. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81419. */
  81420. forceSharedVertices(): void;
  81421. /** @hidden */
  81422. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81423. /** @hidden */
  81424. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81425. /**
  81426. * Creates a new InstancedMesh object from the mesh model.
  81427. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81428. * @param name defines the name of the new instance
  81429. * @returns a new InstancedMesh
  81430. */
  81431. createInstance(name: string): InstancedMesh;
  81432. /**
  81433. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81434. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81435. * @returns the current mesh
  81436. */
  81437. synchronizeInstances(): Mesh;
  81438. /**
  81439. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81440. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81441. * This should be used together with the simplification to avoid disappearing triangles.
  81442. * @param successCallback an optional success callback to be called after the optimization finished.
  81443. * @returns the current mesh
  81444. */
  81445. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81446. /**
  81447. * Serialize current mesh
  81448. * @param serializationObject defines the object which will receive the serialization data
  81449. */
  81450. serialize(serializationObject: any): void;
  81451. /** @hidden */
  81452. _syncGeometryWithMorphTargetManager(): void;
  81453. /** @hidden */
  81454. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81455. /**
  81456. * Returns a new Mesh object parsed from the source provided.
  81457. * @param parsedMesh is the source
  81458. * @param scene defines the hosting scene
  81459. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81460. * @returns a new Mesh
  81461. */
  81462. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81463. /**
  81464. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81465. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81466. * @param name defines the name of the mesh to create
  81467. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81468. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81469. * @param closePath creates a seam between the first and the last points of each path of the path array
  81470. * @param offset is taken in account only if the `pathArray` is containing a single path
  81471. * @param scene defines the hosting scene
  81472. * @param updatable defines if the mesh must be flagged as updatable
  81473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81474. * @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)
  81475. * @returns a new Mesh
  81476. */
  81477. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81478. /**
  81479. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81480. * @param name defines the name of the mesh to create
  81481. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81482. * @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
  81483. * @param scene defines the hosting scene
  81484. * @param updatable defines if the mesh must be flagged as updatable
  81485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81486. * @returns a new Mesh
  81487. */
  81488. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81489. /**
  81490. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81491. * @param name defines the name of the mesh to create
  81492. * @param size sets the size (float) of each box side (default 1)
  81493. * @param scene defines the hosting scene
  81494. * @param updatable defines if the mesh must be flagged as updatable
  81495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81496. * @returns a new Mesh
  81497. */
  81498. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81499. /**
  81500. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81501. * @param name defines the name of the mesh to create
  81502. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81503. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81504. * @param scene defines the hosting scene
  81505. * @param updatable defines if the mesh must be flagged as updatable
  81506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81507. * @returns a new Mesh
  81508. */
  81509. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81510. /**
  81511. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81512. * @param name defines the name of the mesh to create
  81513. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81514. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81515. * @param scene defines the hosting scene
  81516. * @returns a new Mesh
  81517. */
  81518. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81519. /**
  81520. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81521. * @param name defines the name of the mesh to create
  81522. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81523. * @param diameterTop set the top cap diameter (floats, default 1)
  81524. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81525. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81526. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81527. * @param scene defines the hosting scene
  81528. * @param updatable defines if the mesh must be flagged as updatable
  81529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81530. * @returns a new Mesh
  81531. */
  81532. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81533. /**
  81534. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81535. * @param name defines the name of the mesh to create
  81536. * @param diameter sets the diameter size (float) of the torus (default 1)
  81537. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81538. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81539. * @param scene defines the hosting scene
  81540. * @param updatable defines if the mesh must be flagged as updatable
  81541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81542. * @returns a new Mesh
  81543. */
  81544. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81545. /**
  81546. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81547. * @param name defines the name of the mesh to create
  81548. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81549. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81550. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81551. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81552. * @param p the number of windings on X axis (positive integers, default 2)
  81553. * @param q the number of windings on Y axis (positive integers, default 3)
  81554. * @param scene defines the hosting scene
  81555. * @param updatable defines if the mesh must be flagged as updatable
  81556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81557. * @returns a new Mesh
  81558. */
  81559. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81560. /**
  81561. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81562. * @param name defines the name of the mesh to create
  81563. * @param points is an array successive Vector3
  81564. * @param scene defines the hosting scene
  81565. * @param updatable defines if the mesh must be flagged as updatable
  81566. * @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).
  81567. * @returns a new Mesh
  81568. */
  81569. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81570. /**
  81571. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81572. * @param name defines the name of the mesh to create
  81573. * @param points is an array successive Vector3
  81574. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81575. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81576. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81577. * @param scene defines the hosting scene
  81578. * @param updatable defines if the mesh must be flagged as updatable
  81579. * @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)
  81580. * @returns a new Mesh
  81581. */
  81582. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81583. /**
  81584. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81585. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81586. * 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.
  81587. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81588. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81589. * Remember you can only change the shape positions, not their number when updating a polygon.
  81590. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81591. * @param name defines the name of the mesh to create
  81592. * @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
  81593. * @param scene defines the hosting scene
  81594. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81595. * @param updatable defines if the mesh must be flagged as updatable
  81596. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81597. * @param earcutInjection can be used to inject your own earcut reference
  81598. * @returns a new Mesh
  81599. */
  81600. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81601. /**
  81602. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81603. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81604. * @param name defines the name of the mesh to create
  81605. * @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
  81606. * @param depth defines the height of extrusion
  81607. * @param scene defines the hosting scene
  81608. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81609. * @param updatable defines if the mesh must be flagged as updatable
  81610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81611. * @param earcutInjection can be used to inject your own earcut reference
  81612. * @returns a new Mesh
  81613. */
  81614. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81615. /**
  81616. * Creates an extruded shape mesh.
  81617. * 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
  81618. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81619. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81620. * @param name defines the name of the mesh to create
  81621. * @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
  81622. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81623. * @param scale is the value to scale the shape
  81624. * @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
  81625. * @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
  81626. * @param scene defines the hosting scene
  81627. * @param updatable defines if the mesh must be flagged as updatable
  81628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81629. * @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)
  81630. * @returns a new Mesh
  81631. */
  81632. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81633. /**
  81634. * Creates an custom extruded shape mesh.
  81635. * The custom extrusion is a parametric shape.
  81636. * It has no predefined shape. Its final shape will depend on the input parameters.
  81637. * Please consider using the same method from the MeshBuilder class instead
  81638. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81639. * @param name defines the name of the mesh to create
  81640. * @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
  81641. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81642. * @param scaleFunction is a custom Javascript function called on each path point
  81643. * @param rotationFunction is a custom Javascript function called on each path point
  81644. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81645. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81646. * @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
  81647. * @param scene defines the hosting scene
  81648. * @param updatable defines if the mesh must be flagged as updatable
  81649. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81650. * @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)
  81651. * @returns a new Mesh
  81652. */
  81653. 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;
  81654. /**
  81655. * Creates lathe mesh.
  81656. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81657. * Please consider using the same method from the MeshBuilder class instead
  81658. * @param name defines the name of the mesh to create
  81659. * @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
  81660. * @param radius is the radius value of the lathe
  81661. * @param tessellation is the side number of the lathe.
  81662. * @param scene defines the hosting scene
  81663. * @param updatable defines if the mesh must be flagged as updatable
  81664. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81665. * @returns a new Mesh
  81666. */
  81667. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81668. /**
  81669. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81670. * @param name defines the name of the mesh to create
  81671. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81672. * @param scene defines the hosting scene
  81673. * @param updatable defines if the mesh must be flagged as updatable
  81674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81675. * @returns a new Mesh
  81676. */
  81677. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81678. /**
  81679. * Creates a ground mesh.
  81680. * Please consider using the same method from the MeshBuilder class instead
  81681. * @param name defines the name of the mesh to create
  81682. * @param width set the width of the ground
  81683. * @param height set the height of the ground
  81684. * @param subdivisions sets the number of subdivisions per side
  81685. * @param scene defines the hosting scene
  81686. * @param updatable defines if the mesh must be flagged as updatable
  81687. * @returns a new Mesh
  81688. */
  81689. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81690. /**
  81691. * Creates a tiled ground mesh.
  81692. * Please consider using the same method from the MeshBuilder class instead
  81693. * @param name defines the name of the mesh to create
  81694. * @param xmin set the ground minimum X coordinate
  81695. * @param zmin set the ground minimum Y coordinate
  81696. * @param xmax set the ground maximum X coordinate
  81697. * @param zmax set the ground maximum Z coordinate
  81698. * @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
  81699. * @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
  81700. * @param scene defines the hosting scene
  81701. * @param updatable defines if the mesh must be flagged as updatable
  81702. * @returns a new Mesh
  81703. */
  81704. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81705. w: number;
  81706. h: number;
  81707. }, precision: {
  81708. w: number;
  81709. h: number;
  81710. }, scene: Scene, updatable?: boolean): Mesh;
  81711. /**
  81712. * Creates a ground mesh from a height map.
  81713. * Please consider using the same method from the MeshBuilder class instead
  81714. * @see http://doc.babylonjs.com/babylon101/height_map
  81715. * @param name defines the name of the mesh to create
  81716. * @param url sets the URL of the height map image resource
  81717. * @param width set the ground width size
  81718. * @param height set the ground height size
  81719. * @param subdivisions sets the number of subdivision per side
  81720. * @param minHeight is the minimum altitude on the ground
  81721. * @param maxHeight is the maximum altitude on the ground
  81722. * @param scene defines the hosting scene
  81723. * @param updatable defines if the mesh must be flagged as updatable
  81724. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81725. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81726. * @returns a new Mesh
  81727. */
  81728. 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;
  81729. /**
  81730. * Creates a tube mesh.
  81731. * The tube is a parametric shape.
  81732. * It has no predefined shape. Its final shape will depend on the input parameters.
  81733. * Please consider using the same method from the MeshBuilder class instead
  81734. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81735. * @param name defines the name of the mesh to create
  81736. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81737. * @param radius sets the tube radius size
  81738. * @param tessellation is the number of sides on the tubular surface
  81739. * @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
  81740. * @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
  81741. * @param scene defines the hosting scene
  81742. * @param updatable defines if the mesh must be flagged as updatable
  81743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81744. * @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)
  81745. * @returns a new Mesh
  81746. */
  81747. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81748. (i: number, distance: number): number;
  81749. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81750. /**
  81751. * Creates a polyhedron mesh.
  81752. * Please consider using the same method from the MeshBuilder class instead.
  81753. * * 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
  81754. * * The parameter `size` (positive float, default 1) sets the polygon size
  81755. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81756. * * 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`
  81757. * * 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
  81758. * * 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)`)
  81759. * * 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
  81760. * * 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
  81761. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81762. * * If you create a double-sided mesh, you can choose what parts of 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
  81763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81764. * @param name defines the name of the mesh to create
  81765. * @param options defines the options used to create the mesh
  81766. * @param scene defines the hosting scene
  81767. * @returns a new Mesh
  81768. */
  81769. static CreatePolyhedron(name: string, options: {
  81770. type?: number;
  81771. size?: number;
  81772. sizeX?: number;
  81773. sizeY?: number;
  81774. sizeZ?: number;
  81775. custom?: any;
  81776. faceUV?: Vector4[];
  81777. faceColors?: Color4[];
  81778. updatable?: boolean;
  81779. sideOrientation?: number;
  81780. }, scene: Scene): Mesh;
  81781. /**
  81782. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81783. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81784. * * 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`)
  81785. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81786. * * 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
  81787. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81788. * * If you create a double-sided mesh, you can choose what parts of 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
  81789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81790. * @param name defines the name of the mesh
  81791. * @param options defines the options used to create the mesh
  81792. * @param scene defines the hosting scene
  81793. * @returns a new Mesh
  81794. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81795. */
  81796. static CreateIcoSphere(name: string, options: {
  81797. radius?: number;
  81798. flat?: boolean;
  81799. subdivisions?: number;
  81800. sideOrientation?: number;
  81801. updatable?: boolean;
  81802. }, scene: Scene): Mesh;
  81803. /**
  81804. * Creates a decal mesh.
  81805. * Please consider using the same method from the MeshBuilder class instead.
  81806. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81807. * @param name defines the name of the mesh
  81808. * @param sourceMesh defines the mesh receiving the decal
  81809. * @param position sets the position of the decal in world coordinates
  81810. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81811. * @param size sets the decal scaling
  81812. * @param angle sets the angle to rotate the decal
  81813. * @returns a new Mesh
  81814. */
  81815. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81816. /**
  81817. * Prepare internal position array for software CPU skinning
  81818. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81819. */
  81820. setPositionsForCPUSkinning(): Float32Array;
  81821. /**
  81822. * Prepare internal normal array for software CPU skinning
  81823. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81824. */
  81825. setNormalsForCPUSkinning(): Float32Array;
  81826. /**
  81827. * Updates the vertex buffer by applying transformation from the bones
  81828. * @param skeleton defines the skeleton to apply to current mesh
  81829. * @returns the current mesh
  81830. */
  81831. applySkeleton(skeleton: Skeleton): Mesh;
  81832. /**
  81833. * 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
  81834. * @param meshes defines the list of meshes to scan
  81835. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81836. */
  81837. static MinMax(meshes: AbstractMesh[]): {
  81838. min: Vector3;
  81839. max: Vector3;
  81840. };
  81841. /**
  81842. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81843. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81844. * @returns a vector3
  81845. */
  81846. static Center(meshesOrMinMaxVector: {
  81847. min: Vector3;
  81848. max: Vector3;
  81849. } | AbstractMesh[]): Vector3;
  81850. /**
  81851. * Merge the array of meshes into a single mesh for performance reasons.
  81852. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81853. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81854. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81855. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81856. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81857. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81858. * @returns a new mesh
  81859. */
  81860. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81861. /** @hidden */
  81862. addInstance(instance: InstancedMesh): void;
  81863. /** @hidden */
  81864. removeInstance(instance: InstancedMesh): void;
  81865. }
  81866. }
  81867. declare module BABYLON {
  81868. /**
  81869. * Base class for the main features of a material in Babylon.js
  81870. */
  81871. export class Material implements IAnimatable {
  81872. /**
  81873. * Returns the triangle fill mode
  81874. */
  81875. static readonly TriangleFillMode: number;
  81876. /**
  81877. * Returns the wireframe mode
  81878. */
  81879. static readonly WireFrameFillMode: number;
  81880. /**
  81881. * Returns the point fill mode
  81882. */
  81883. static readonly PointFillMode: number;
  81884. /**
  81885. * Returns the point list draw mode
  81886. */
  81887. static readonly PointListDrawMode: number;
  81888. /**
  81889. * Returns the line list draw mode
  81890. */
  81891. static readonly LineListDrawMode: number;
  81892. /**
  81893. * Returns the line loop draw mode
  81894. */
  81895. static readonly LineLoopDrawMode: number;
  81896. /**
  81897. * Returns the line strip draw mode
  81898. */
  81899. static readonly LineStripDrawMode: number;
  81900. /**
  81901. * Returns the triangle strip draw mode
  81902. */
  81903. static readonly TriangleStripDrawMode: number;
  81904. /**
  81905. * Returns the triangle fan draw mode
  81906. */
  81907. static readonly TriangleFanDrawMode: number;
  81908. /**
  81909. * Stores the clock-wise side orientation
  81910. */
  81911. static readonly ClockWiseSideOrientation: number;
  81912. /**
  81913. * Stores the counter clock-wise side orientation
  81914. */
  81915. static readonly CounterClockWiseSideOrientation: number;
  81916. /**
  81917. * The dirty texture flag value
  81918. */
  81919. static readonly TextureDirtyFlag: number;
  81920. /**
  81921. * The dirty light flag value
  81922. */
  81923. static readonly LightDirtyFlag: number;
  81924. /**
  81925. * The dirty fresnel flag value
  81926. */
  81927. static readonly FresnelDirtyFlag: number;
  81928. /**
  81929. * The dirty attribute flag value
  81930. */
  81931. static readonly AttributesDirtyFlag: number;
  81932. /**
  81933. * The dirty misc flag value
  81934. */
  81935. static readonly MiscDirtyFlag: number;
  81936. /**
  81937. * The all dirty flag value
  81938. */
  81939. static readonly AllDirtyFlag: number;
  81940. /**
  81941. * The ID of the material
  81942. */
  81943. id: string;
  81944. /**
  81945. * Gets or sets the unique id of the material
  81946. */
  81947. uniqueId: number;
  81948. /**
  81949. * The name of the material
  81950. */
  81951. name: string;
  81952. /**
  81953. * Gets or sets user defined metadata
  81954. */
  81955. metadata: any;
  81956. /**
  81957. * For internal use only. Please do not use.
  81958. */
  81959. reservedDataStore: any;
  81960. /**
  81961. * Specifies if the ready state should be checked on each call
  81962. */
  81963. checkReadyOnEveryCall: boolean;
  81964. /**
  81965. * Specifies if the ready state should be checked once
  81966. */
  81967. checkReadyOnlyOnce: boolean;
  81968. /**
  81969. * The state of the material
  81970. */
  81971. state: string;
  81972. /**
  81973. * The alpha value of the material
  81974. */
  81975. protected _alpha: number;
  81976. /**
  81977. * List of inspectable custom properties (used by the Inspector)
  81978. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81979. */
  81980. inspectableCustomProperties: IInspectable[];
  81981. /**
  81982. * Sets the alpha value of the material
  81983. */
  81984. /**
  81985. * Gets the alpha value of the material
  81986. */
  81987. alpha: number;
  81988. /**
  81989. * Specifies if back face culling is enabled
  81990. */
  81991. protected _backFaceCulling: boolean;
  81992. /**
  81993. * Sets the back-face culling state
  81994. */
  81995. /**
  81996. * Gets the back-face culling state
  81997. */
  81998. backFaceCulling: boolean;
  81999. /**
  82000. * Stores the value for side orientation
  82001. */
  82002. sideOrientation: number;
  82003. /**
  82004. * Callback triggered when the material is compiled
  82005. */
  82006. onCompiled: Nullable<(effect: Effect) => void>;
  82007. /**
  82008. * Callback triggered when an error occurs
  82009. */
  82010. onError: Nullable<(effect: Effect, errors: string) => void>;
  82011. /**
  82012. * Callback triggered to get the render target textures
  82013. */
  82014. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82015. /**
  82016. * Gets a boolean indicating that current material needs to register RTT
  82017. */
  82018. readonly hasRenderTargetTextures: boolean;
  82019. /**
  82020. * Specifies if the material should be serialized
  82021. */
  82022. doNotSerialize: boolean;
  82023. /**
  82024. * @hidden
  82025. */
  82026. _storeEffectOnSubMeshes: boolean;
  82027. /**
  82028. * Stores the animations for the material
  82029. */
  82030. animations: Nullable<Array<Animation>>;
  82031. /**
  82032. * An event triggered when the material is disposed
  82033. */
  82034. onDisposeObservable: Observable<Material>;
  82035. /**
  82036. * An observer which watches for dispose events
  82037. */
  82038. private _onDisposeObserver;
  82039. private _onUnBindObservable;
  82040. /**
  82041. * Called during a dispose event
  82042. */
  82043. onDispose: () => void;
  82044. private _onBindObservable;
  82045. /**
  82046. * An event triggered when the material is bound
  82047. */
  82048. readonly onBindObservable: Observable<AbstractMesh>;
  82049. /**
  82050. * An observer which watches for bind events
  82051. */
  82052. private _onBindObserver;
  82053. /**
  82054. * Called during a bind event
  82055. */
  82056. onBind: (Mesh: AbstractMesh) => void;
  82057. /**
  82058. * An event triggered when the material is unbound
  82059. */
  82060. readonly onUnBindObservable: Observable<Material>;
  82061. /**
  82062. * Stores the value of the alpha mode
  82063. */
  82064. private _alphaMode;
  82065. /**
  82066. * Sets the value of the alpha mode.
  82067. *
  82068. * | Value | Type | Description |
  82069. * | --- | --- | --- |
  82070. * | 0 | ALPHA_DISABLE | |
  82071. * | 1 | ALPHA_ADD | |
  82072. * | 2 | ALPHA_COMBINE | |
  82073. * | 3 | ALPHA_SUBTRACT | |
  82074. * | 4 | ALPHA_MULTIPLY | |
  82075. * | 5 | ALPHA_MAXIMIZED | |
  82076. * | 6 | ALPHA_ONEONE | |
  82077. * | 7 | ALPHA_PREMULTIPLIED | |
  82078. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82079. * | 9 | ALPHA_INTERPOLATE | |
  82080. * | 10 | ALPHA_SCREENMODE | |
  82081. *
  82082. */
  82083. /**
  82084. * Gets the value of the alpha mode
  82085. */
  82086. alphaMode: number;
  82087. /**
  82088. * Stores the state of the need depth pre-pass value
  82089. */
  82090. private _needDepthPrePass;
  82091. /**
  82092. * Sets the need depth pre-pass value
  82093. */
  82094. /**
  82095. * Gets the depth pre-pass value
  82096. */
  82097. needDepthPrePass: boolean;
  82098. /**
  82099. * Specifies if depth writing should be disabled
  82100. */
  82101. disableDepthWrite: boolean;
  82102. /**
  82103. * Specifies if depth writing should be forced
  82104. */
  82105. forceDepthWrite: boolean;
  82106. /**
  82107. * Specifies if there should be a separate pass for culling
  82108. */
  82109. separateCullingPass: boolean;
  82110. /**
  82111. * Stores the state specifing if fog should be enabled
  82112. */
  82113. private _fogEnabled;
  82114. /**
  82115. * Sets the state for enabling fog
  82116. */
  82117. /**
  82118. * Gets the value of the fog enabled state
  82119. */
  82120. fogEnabled: boolean;
  82121. /**
  82122. * Stores the size of points
  82123. */
  82124. pointSize: number;
  82125. /**
  82126. * Stores the z offset value
  82127. */
  82128. zOffset: number;
  82129. /**
  82130. * Gets a value specifying if wireframe mode is enabled
  82131. */
  82132. /**
  82133. * Sets the state of wireframe mode
  82134. */
  82135. wireframe: boolean;
  82136. /**
  82137. * Gets the value specifying if point clouds are enabled
  82138. */
  82139. /**
  82140. * Sets the state of point cloud mode
  82141. */
  82142. pointsCloud: boolean;
  82143. /**
  82144. * Gets the material fill mode
  82145. */
  82146. /**
  82147. * Sets the material fill mode
  82148. */
  82149. fillMode: number;
  82150. /**
  82151. * @hidden
  82152. * Stores the effects for the material
  82153. */
  82154. _effect: Nullable<Effect>;
  82155. /**
  82156. * @hidden
  82157. * Specifies if the material was previously ready
  82158. */
  82159. _wasPreviouslyReady: boolean;
  82160. /**
  82161. * Specifies if uniform buffers should be used
  82162. */
  82163. private _useUBO;
  82164. /**
  82165. * Stores a reference to the scene
  82166. */
  82167. private _scene;
  82168. /**
  82169. * Stores the fill mode state
  82170. */
  82171. private _fillMode;
  82172. /**
  82173. * Specifies if the depth write state should be cached
  82174. */
  82175. private _cachedDepthWriteState;
  82176. /**
  82177. * Stores the uniform buffer
  82178. */
  82179. protected _uniformBuffer: UniformBuffer;
  82180. /** @hidden */
  82181. _indexInSceneMaterialArray: number;
  82182. /** @hidden */
  82183. meshMap: Nullable<{
  82184. [id: string]: AbstractMesh | undefined;
  82185. }>;
  82186. /**
  82187. * Creates a material instance
  82188. * @param name defines the name of the material
  82189. * @param scene defines the scene to reference
  82190. * @param doNotAdd specifies if the material should be added to the scene
  82191. */
  82192. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82193. /**
  82194. * Returns a string representation of the current material
  82195. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82196. * @returns a string with material information
  82197. */
  82198. toString(fullDetails?: boolean): string;
  82199. /**
  82200. * Gets the class name of the material
  82201. * @returns a string with the class name of the material
  82202. */
  82203. getClassName(): string;
  82204. /**
  82205. * Specifies if updates for the material been locked
  82206. */
  82207. readonly isFrozen: boolean;
  82208. /**
  82209. * Locks updates for the material
  82210. */
  82211. freeze(): void;
  82212. /**
  82213. * Unlocks updates for the material
  82214. */
  82215. unfreeze(): void;
  82216. /**
  82217. * Specifies if the material is ready to be used
  82218. * @param mesh defines the mesh to check
  82219. * @param useInstances specifies if instances should be used
  82220. * @returns a boolean indicating if the material is ready to be used
  82221. */
  82222. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82223. /**
  82224. * Specifies that the submesh is ready to be used
  82225. * @param mesh defines the mesh to check
  82226. * @param subMesh defines which submesh to check
  82227. * @param useInstances specifies that instances should be used
  82228. * @returns a boolean indicating that the submesh is ready or not
  82229. */
  82230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82231. /**
  82232. * Returns the material effect
  82233. * @returns the effect associated with the material
  82234. */
  82235. getEffect(): Nullable<Effect>;
  82236. /**
  82237. * Returns the current scene
  82238. * @returns a Scene
  82239. */
  82240. getScene(): Scene;
  82241. /**
  82242. * Specifies if the material will require alpha blending
  82243. * @returns a boolean specifying if alpha blending is needed
  82244. */
  82245. needAlphaBlending(): boolean;
  82246. /**
  82247. * Specifies if the mesh will require alpha blending
  82248. * @param mesh defines the mesh to check
  82249. * @returns a boolean specifying if alpha blending is needed for the mesh
  82250. */
  82251. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82252. /**
  82253. * Specifies if this material should be rendered in alpha test mode
  82254. * @returns a boolean specifying if an alpha test is needed.
  82255. */
  82256. needAlphaTesting(): boolean;
  82257. /**
  82258. * Gets the texture used for the alpha test
  82259. * @returns the texture to use for alpha testing
  82260. */
  82261. getAlphaTestTexture(): Nullable<BaseTexture>;
  82262. /**
  82263. * Marks the material to indicate that it needs to be re-calculated
  82264. */
  82265. markDirty(): void;
  82266. /** @hidden */
  82267. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82268. /**
  82269. * Binds the material to the mesh
  82270. * @param world defines the world transformation matrix
  82271. * @param mesh defines the mesh to bind the material to
  82272. */
  82273. bind(world: Matrix, mesh?: Mesh): void;
  82274. /**
  82275. * Binds the submesh to the material
  82276. * @param world defines the world transformation matrix
  82277. * @param mesh defines the mesh containing the submesh
  82278. * @param subMesh defines the submesh to bind the material to
  82279. */
  82280. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82281. /**
  82282. * Binds the world matrix to the material
  82283. * @param world defines the world transformation matrix
  82284. */
  82285. bindOnlyWorldMatrix(world: Matrix): void;
  82286. /**
  82287. * Binds the scene's uniform buffer to the effect.
  82288. * @param effect defines the effect to bind to the scene uniform buffer
  82289. * @param sceneUbo defines the uniform buffer storing scene data
  82290. */
  82291. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82292. /**
  82293. * Binds the view matrix to the effect
  82294. * @param effect defines the effect to bind the view matrix to
  82295. */
  82296. bindView(effect: Effect): void;
  82297. /**
  82298. * Binds the view projection matrix to the effect
  82299. * @param effect defines the effect to bind the view projection matrix to
  82300. */
  82301. bindViewProjection(effect: Effect): void;
  82302. /**
  82303. * Specifies if material alpha testing should be turned on for the mesh
  82304. * @param mesh defines the mesh to check
  82305. */
  82306. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82307. /**
  82308. * Processes to execute after binding the material to a mesh
  82309. * @param mesh defines the rendered mesh
  82310. */
  82311. protected _afterBind(mesh?: Mesh): void;
  82312. /**
  82313. * Unbinds the material from the mesh
  82314. */
  82315. unbind(): void;
  82316. /**
  82317. * Gets the active textures from the material
  82318. * @returns an array of textures
  82319. */
  82320. getActiveTextures(): BaseTexture[];
  82321. /**
  82322. * Specifies if the material uses a texture
  82323. * @param texture defines the texture to check against the material
  82324. * @returns a boolean specifying if the material uses the texture
  82325. */
  82326. hasTexture(texture: BaseTexture): boolean;
  82327. /**
  82328. * Makes a duplicate of the material, and gives it a new name
  82329. * @param name defines the new name for the duplicated material
  82330. * @returns the cloned material
  82331. */
  82332. clone(name: string): Nullable<Material>;
  82333. /**
  82334. * Gets the meshes bound to the material
  82335. * @returns an array of meshes bound to the material
  82336. */
  82337. getBindedMeshes(): AbstractMesh[];
  82338. /**
  82339. * Force shader compilation
  82340. * @param mesh defines the mesh associated with this material
  82341. * @param onCompiled defines a function to execute once the material is compiled
  82342. * @param options defines the options to configure the compilation
  82343. */
  82344. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82345. clipPlane: boolean;
  82346. }>): void;
  82347. /**
  82348. * Force shader compilation
  82349. * @param mesh defines the mesh that will use this material
  82350. * @param options defines additional options for compiling the shaders
  82351. * @returns a promise that resolves when the compilation completes
  82352. */
  82353. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82354. clipPlane: boolean;
  82355. }>): Promise<void>;
  82356. private static readonly _ImageProcessingDirtyCallBack;
  82357. private static readonly _TextureDirtyCallBack;
  82358. private static readonly _FresnelDirtyCallBack;
  82359. private static readonly _MiscDirtyCallBack;
  82360. private static readonly _LightsDirtyCallBack;
  82361. private static readonly _AttributeDirtyCallBack;
  82362. private static _FresnelAndMiscDirtyCallBack;
  82363. private static _TextureAndMiscDirtyCallBack;
  82364. private static readonly _DirtyCallbackArray;
  82365. private static readonly _RunDirtyCallBacks;
  82366. /**
  82367. * Marks a define in the material to indicate that it needs to be re-computed
  82368. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82369. */
  82370. markAsDirty(flag: number): void;
  82371. /**
  82372. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82373. * @param func defines a function which checks material defines against the submeshes
  82374. */
  82375. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82376. /**
  82377. * Indicates that image processing needs to be re-calculated for all submeshes
  82378. */
  82379. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82380. /**
  82381. * Indicates that textures need to be re-calculated for all submeshes
  82382. */
  82383. protected _markAllSubMeshesAsTexturesDirty(): void;
  82384. /**
  82385. * Indicates that fresnel needs to be re-calculated for all submeshes
  82386. */
  82387. protected _markAllSubMeshesAsFresnelDirty(): void;
  82388. /**
  82389. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82390. */
  82391. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82392. /**
  82393. * Indicates that lights need to be re-calculated for all submeshes
  82394. */
  82395. protected _markAllSubMeshesAsLightsDirty(): void;
  82396. /**
  82397. * Indicates that attributes need to be re-calculated for all submeshes
  82398. */
  82399. protected _markAllSubMeshesAsAttributesDirty(): void;
  82400. /**
  82401. * Indicates that misc needs to be re-calculated for all submeshes
  82402. */
  82403. protected _markAllSubMeshesAsMiscDirty(): void;
  82404. /**
  82405. * Indicates that textures and misc need to be re-calculated for all submeshes
  82406. */
  82407. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82408. /**
  82409. * Disposes the material
  82410. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82411. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82412. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82413. */
  82414. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82415. /** @hidden */
  82416. private releaseVertexArrayObject;
  82417. /**
  82418. * Serializes this material
  82419. * @returns the serialized material object
  82420. */
  82421. serialize(): any;
  82422. /**
  82423. * Creates a material from parsed material data
  82424. * @param parsedMaterial defines parsed material data
  82425. * @param scene defines the hosting scene
  82426. * @param rootUrl defines the root URL to use to load textures
  82427. * @returns a new material
  82428. */
  82429. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82430. }
  82431. }
  82432. declare module BABYLON {
  82433. /**
  82434. * Base class for submeshes
  82435. */
  82436. export class BaseSubMesh {
  82437. /** @hidden */
  82438. _materialDefines: Nullable<MaterialDefines>;
  82439. /** @hidden */
  82440. _materialEffect: Nullable<Effect>;
  82441. /**
  82442. * Gets associated effect
  82443. */
  82444. readonly effect: Nullable<Effect>;
  82445. /**
  82446. * Sets associated effect (effect used to render this submesh)
  82447. * @param effect defines the effect to associate with
  82448. * @param defines defines the set of defines used to compile this effect
  82449. */
  82450. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82451. }
  82452. /**
  82453. * Defines a subdivision inside a mesh
  82454. */
  82455. export class SubMesh extends BaseSubMesh implements ICullable {
  82456. /** the material index to use */
  82457. materialIndex: number;
  82458. /** vertex index start */
  82459. verticesStart: number;
  82460. /** vertices count */
  82461. verticesCount: number;
  82462. /** index start */
  82463. indexStart: number;
  82464. /** indices count */
  82465. indexCount: number;
  82466. /** @hidden */
  82467. _linesIndexCount: number;
  82468. private _mesh;
  82469. private _renderingMesh;
  82470. private _boundingInfo;
  82471. private _linesIndexBuffer;
  82472. /** @hidden */
  82473. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82474. /** @hidden */
  82475. _trianglePlanes: Plane[];
  82476. /** @hidden */
  82477. _lastColliderTransformMatrix: Nullable<Matrix>;
  82478. /** @hidden */
  82479. _renderId: number;
  82480. /** @hidden */
  82481. _alphaIndex: number;
  82482. /** @hidden */
  82483. _distanceToCamera: number;
  82484. /** @hidden */
  82485. _id: number;
  82486. private _currentMaterial;
  82487. /**
  82488. * Add a new submesh to a mesh
  82489. * @param materialIndex defines the material index to use
  82490. * @param verticesStart defines vertex index start
  82491. * @param verticesCount defines vertices count
  82492. * @param indexStart defines index start
  82493. * @param indexCount defines indices count
  82494. * @param mesh defines the parent mesh
  82495. * @param renderingMesh defines an optional rendering mesh
  82496. * @param createBoundingBox defines if bounding box should be created for this submesh
  82497. * @returns the new submesh
  82498. */
  82499. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82500. /**
  82501. * Creates a new submesh
  82502. * @param materialIndex defines the material index to use
  82503. * @param verticesStart defines vertex index start
  82504. * @param verticesCount defines vertices count
  82505. * @param indexStart defines index start
  82506. * @param indexCount defines indices count
  82507. * @param mesh defines the parent mesh
  82508. * @param renderingMesh defines an optional rendering mesh
  82509. * @param createBoundingBox defines if bounding box should be created for this submesh
  82510. */
  82511. constructor(
  82512. /** the material index to use */
  82513. materialIndex: number,
  82514. /** vertex index start */
  82515. verticesStart: number,
  82516. /** vertices count */
  82517. verticesCount: number,
  82518. /** index start */
  82519. indexStart: number,
  82520. /** indices count */
  82521. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82522. /**
  82523. * Returns true if this submesh covers the entire parent mesh
  82524. * @ignorenaming
  82525. */
  82526. readonly IsGlobal: boolean;
  82527. /**
  82528. * Returns the submesh BoudingInfo object
  82529. * @returns current bounding info (or mesh's one if the submesh is global)
  82530. */
  82531. getBoundingInfo(): BoundingInfo;
  82532. /**
  82533. * Sets the submesh BoundingInfo
  82534. * @param boundingInfo defines the new bounding info to use
  82535. * @returns the SubMesh
  82536. */
  82537. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82538. /**
  82539. * Returns the mesh of the current submesh
  82540. * @return the parent mesh
  82541. */
  82542. getMesh(): AbstractMesh;
  82543. /**
  82544. * Returns the rendering mesh of the submesh
  82545. * @returns the rendering mesh (could be different from parent mesh)
  82546. */
  82547. getRenderingMesh(): Mesh;
  82548. /**
  82549. * Returns the submesh material
  82550. * @returns null or the current material
  82551. */
  82552. getMaterial(): Nullable<Material>;
  82553. /**
  82554. * Sets a new updated BoundingInfo object to the submesh
  82555. * @param data defines an optional position array to use to determine the bounding info
  82556. * @returns the SubMesh
  82557. */
  82558. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82559. /** @hidden */
  82560. _checkCollision(collider: Collider): boolean;
  82561. /**
  82562. * Updates the submesh BoundingInfo
  82563. * @param world defines the world matrix to use to update the bounding info
  82564. * @returns the submesh
  82565. */
  82566. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82567. /**
  82568. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82569. * @param frustumPlanes defines the frustum planes
  82570. * @returns true if the submesh is intersecting with the frustum
  82571. */
  82572. isInFrustum(frustumPlanes: Plane[]): boolean;
  82573. /**
  82574. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82575. * @param frustumPlanes defines the frustum planes
  82576. * @returns true if the submesh is inside the frustum
  82577. */
  82578. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82579. /**
  82580. * Renders the submesh
  82581. * @param enableAlphaMode defines if alpha needs to be used
  82582. * @returns the submesh
  82583. */
  82584. render(enableAlphaMode: boolean): SubMesh;
  82585. /**
  82586. * @hidden
  82587. */
  82588. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82589. /**
  82590. * Checks if the submesh intersects with a ray
  82591. * @param ray defines the ray to test
  82592. * @returns true is the passed ray intersects the submesh bounding box
  82593. */
  82594. canIntersects(ray: Ray): boolean;
  82595. /**
  82596. * Intersects current submesh with a ray
  82597. * @param ray defines the ray to test
  82598. * @param positions defines mesh's positions array
  82599. * @param indices defines mesh's indices array
  82600. * @param fastCheck defines if only bounding info should be used
  82601. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82602. * @returns intersection info or null if no intersection
  82603. */
  82604. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82605. /** @hidden */
  82606. private _intersectLines;
  82607. /** @hidden */
  82608. private _intersectTriangles;
  82609. /** @hidden */
  82610. private _intersectUnIndexedTriangles;
  82611. /** @hidden */
  82612. _rebuild(): void;
  82613. /**
  82614. * Creates a new submesh from the passed mesh
  82615. * @param newMesh defines the new hosting mesh
  82616. * @param newRenderingMesh defines an optional rendering mesh
  82617. * @returns the new submesh
  82618. */
  82619. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82620. /**
  82621. * Release associated resources
  82622. */
  82623. dispose(): void;
  82624. /**
  82625. * Gets the class name
  82626. * @returns the string "SubMesh".
  82627. */
  82628. getClassName(): string;
  82629. /**
  82630. * Creates a new submesh from indices data
  82631. * @param materialIndex the index of the main mesh material
  82632. * @param startIndex the index where to start the copy in the mesh indices array
  82633. * @param indexCount the number of indices to copy then from the startIndex
  82634. * @param mesh the main mesh to create the submesh from
  82635. * @param renderingMesh the optional rendering mesh
  82636. * @returns a new submesh
  82637. */
  82638. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82639. }
  82640. }
  82641. declare module BABYLON {
  82642. /**
  82643. * Class used to store geometry data (vertex buffers + index buffer)
  82644. */
  82645. export class Geometry implements IGetSetVerticesData {
  82646. /**
  82647. * Gets or sets the ID of the geometry
  82648. */
  82649. id: string;
  82650. /**
  82651. * Gets or sets the unique ID of the geometry
  82652. */
  82653. uniqueId: number;
  82654. /**
  82655. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82656. */
  82657. delayLoadState: number;
  82658. /**
  82659. * Gets the file containing the data to load when running in delay load state
  82660. */
  82661. delayLoadingFile: Nullable<string>;
  82662. /**
  82663. * Callback called when the geometry is updated
  82664. */
  82665. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82666. private _scene;
  82667. private _engine;
  82668. private _meshes;
  82669. private _totalVertices;
  82670. /** @hidden */
  82671. _indices: IndicesArray;
  82672. /** @hidden */
  82673. _vertexBuffers: {
  82674. [key: string]: VertexBuffer;
  82675. };
  82676. private _isDisposed;
  82677. private _extend;
  82678. private _boundingBias;
  82679. /** @hidden */
  82680. _delayInfo: Array<string>;
  82681. private _indexBuffer;
  82682. private _indexBufferIsUpdatable;
  82683. /** @hidden */
  82684. _boundingInfo: Nullable<BoundingInfo>;
  82685. /** @hidden */
  82686. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82687. /** @hidden */
  82688. _softwareSkinningFrameId: number;
  82689. private _vertexArrayObjects;
  82690. private _updatable;
  82691. /** @hidden */
  82692. _positions: Nullable<Vector3[]>;
  82693. /**
  82694. * 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
  82695. */
  82696. /**
  82697. * 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
  82698. */
  82699. boundingBias: Vector2;
  82700. /**
  82701. * Static function used to attach a new empty geometry to a mesh
  82702. * @param mesh defines the mesh to attach the geometry to
  82703. * @returns the new Geometry
  82704. */
  82705. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82706. /**
  82707. * Creates a new geometry
  82708. * @param id defines the unique ID
  82709. * @param scene defines the hosting scene
  82710. * @param vertexData defines the VertexData used to get geometry data
  82711. * @param updatable defines if geometry must be updatable (false by default)
  82712. * @param mesh defines the mesh that will be associated with the geometry
  82713. */
  82714. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82715. /**
  82716. * Gets the current extend of the geometry
  82717. */
  82718. readonly extend: {
  82719. minimum: Vector3;
  82720. maximum: Vector3;
  82721. };
  82722. /**
  82723. * Gets the hosting scene
  82724. * @returns the hosting Scene
  82725. */
  82726. getScene(): Scene;
  82727. /**
  82728. * Gets the hosting engine
  82729. * @returns the hosting Engine
  82730. */
  82731. getEngine(): Engine;
  82732. /**
  82733. * Defines if the geometry is ready to use
  82734. * @returns true if the geometry is ready to be used
  82735. */
  82736. isReady(): boolean;
  82737. /**
  82738. * Gets a value indicating that the geometry should not be serialized
  82739. */
  82740. readonly doNotSerialize: boolean;
  82741. /** @hidden */
  82742. _rebuild(): void;
  82743. /**
  82744. * Affects all geometry data in one call
  82745. * @param vertexData defines the geometry data
  82746. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82747. */
  82748. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82749. /**
  82750. * Set specific vertex data
  82751. * @param kind defines the data kind (Position, normal, etc...)
  82752. * @param data defines the vertex data to use
  82753. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82754. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82755. */
  82756. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82757. /**
  82758. * Removes a specific vertex data
  82759. * @param kind defines the data kind (Position, normal, etc...)
  82760. */
  82761. removeVerticesData(kind: string): void;
  82762. /**
  82763. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82764. * @param buffer defines the vertex buffer to use
  82765. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82766. */
  82767. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82768. /**
  82769. * Update a specific vertex buffer
  82770. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82771. * It will do nothing if the buffer is not updatable
  82772. * @param kind defines the data kind (Position, normal, etc...)
  82773. * @param data defines the data to use
  82774. * @param offset defines the offset in the target buffer where to store the data
  82775. * @param useBytes set to true if the offset is in bytes
  82776. */
  82777. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82778. /**
  82779. * Update a specific vertex buffer
  82780. * This function will create a new buffer if the current one is not updatable
  82781. * @param kind defines the data kind (Position, normal, etc...)
  82782. * @param data defines the data to use
  82783. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82784. */
  82785. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82786. private _updateBoundingInfo;
  82787. /** @hidden */
  82788. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82789. /**
  82790. * Gets total number of vertices
  82791. * @returns the total number of vertices
  82792. */
  82793. getTotalVertices(): number;
  82794. /**
  82795. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82796. * @param kind defines the data kind (Position, normal, etc...)
  82797. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82798. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82799. * @returns a float array containing vertex data
  82800. */
  82801. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82802. /**
  82803. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82804. * @param kind defines the data kind (Position, normal, etc...)
  82805. * @returns true if the vertex buffer with the specified kind is updatable
  82806. */
  82807. isVertexBufferUpdatable(kind: string): boolean;
  82808. /**
  82809. * Gets a specific vertex buffer
  82810. * @param kind defines the data kind (Position, normal, etc...)
  82811. * @returns a VertexBuffer
  82812. */
  82813. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82814. /**
  82815. * Returns all vertex buffers
  82816. * @return an object holding all vertex buffers indexed by kind
  82817. */
  82818. getVertexBuffers(): Nullable<{
  82819. [key: string]: VertexBuffer;
  82820. }>;
  82821. /**
  82822. * Gets a boolean indicating if specific vertex buffer is present
  82823. * @param kind defines the data kind (Position, normal, etc...)
  82824. * @returns true if data is present
  82825. */
  82826. isVerticesDataPresent(kind: string): boolean;
  82827. /**
  82828. * Gets a list of all attached data kinds (Position, normal, etc...)
  82829. * @returns a list of string containing all kinds
  82830. */
  82831. getVerticesDataKinds(): string[];
  82832. /**
  82833. * Update index buffer
  82834. * @param indices defines the indices to store in the index buffer
  82835. * @param offset defines the offset in the target buffer where to store the data
  82836. * @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)
  82837. */
  82838. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82839. /**
  82840. * Creates a new index buffer
  82841. * @param indices defines the indices to store in the index buffer
  82842. * @param totalVertices defines the total number of vertices (could be null)
  82843. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82844. */
  82845. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82846. /**
  82847. * Return the total number of indices
  82848. * @returns the total number of indices
  82849. */
  82850. getTotalIndices(): number;
  82851. /**
  82852. * Gets the index buffer array
  82853. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82855. * @returns the index buffer array
  82856. */
  82857. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82858. /**
  82859. * Gets the index buffer
  82860. * @return the index buffer
  82861. */
  82862. getIndexBuffer(): Nullable<DataBuffer>;
  82863. /** @hidden */
  82864. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82865. /**
  82866. * Release the associated resources for a specific mesh
  82867. * @param mesh defines the source mesh
  82868. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82869. */
  82870. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82871. /**
  82872. * Apply current geometry to a given mesh
  82873. * @param mesh defines the mesh to apply geometry to
  82874. */
  82875. applyToMesh(mesh: Mesh): void;
  82876. private _updateExtend;
  82877. private _applyToMesh;
  82878. private notifyUpdate;
  82879. /**
  82880. * Load the geometry if it was flagged as delay loaded
  82881. * @param scene defines the hosting scene
  82882. * @param onLoaded defines a callback called when the geometry is loaded
  82883. */
  82884. load(scene: Scene, onLoaded?: () => void): void;
  82885. private _queueLoad;
  82886. /**
  82887. * Invert the geometry to move from a right handed system to a left handed one.
  82888. */
  82889. toLeftHanded(): void;
  82890. /** @hidden */
  82891. _resetPointsArrayCache(): void;
  82892. /** @hidden */
  82893. _generatePointsArray(): boolean;
  82894. /**
  82895. * Gets a value indicating if the geometry is disposed
  82896. * @returns true if the geometry was disposed
  82897. */
  82898. isDisposed(): boolean;
  82899. private _disposeVertexArrayObjects;
  82900. /**
  82901. * Free all associated resources
  82902. */
  82903. dispose(): void;
  82904. /**
  82905. * Clone the current geometry into a new geometry
  82906. * @param id defines the unique ID of the new geometry
  82907. * @returns a new geometry object
  82908. */
  82909. copy(id: string): Geometry;
  82910. /**
  82911. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82912. * @return a JSON representation of the current geometry data (without the vertices data)
  82913. */
  82914. serialize(): any;
  82915. private toNumberArray;
  82916. /**
  82917. * Serialize all vertices data into a JSON oject
  82918. * @returns a JSON representation of the current geometry data
  82919. */
  82920. serializeVerticeData(): any;
  82921. /**
  82922. * Extracts a clone of a mesh geometry
  82923. * @param mesh defines the source mesh
  82924. * @param id defines the unique ID of the new geometry object
  82925. * @returns the new geometry object
  82926. */
  82927. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82928. /**
  82929. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82930. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82931. * Be aware Math.random() could cause collisions, but:
  82932. * "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"
  82933. * @returns a string containing a new GUID
  82934. */
  82935. static RandomId(): string;
  82936. /** @hidden */
  82937. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82938. private static _CleanMatricesWeights;
  82939. /**
  82940. * Create a new geometry from persisted data (Using .babylon file format)
  82941. * @param parsedVertexData defines the persisted data
  82942. * @param scene defines the hosting scene
  82943. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82944. * @returns the new geometry object
  82945. */
  82946. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82947. }
  82948. }
  82949. declare module BABYLON {
  82950. /**
  82951. * Define an interface for all classes that will get and set the data on vertices
  82952. */
  82953. export interface IGetSetVerticesData {
  82954. /**
  82955. * Gets a boolean indicating if specific vertex data is present
  82956. * @param kind defines the vertex data kind to use
  82957. * @returns true is data kind is present
  82958. */
  82959. isVerticesDataPresent(kind: string): boolean;
  82960. /**
  82961. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82962. * @param kind defines the data kind (Position, normal, etc...)
  82963. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82964. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82965. * @returns a float array containing vertex data
  82966. */
  82967. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82968. /**
  82969. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82970. * @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.
  82971. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82972. * @returns the indices array or an empty array if the mesh has no geometry
  82973. */
  82974. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82975. /**
  82976. * Set specific vertex data
  82977. * @param kind defines the data kind (Position, normal, etc...)
  82978. * @param data defines the vertex data to use
  82979. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82980. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82981. */
  82982. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82983. /**
  82984. * Update a specific associated vertex buffer
  82985. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82986. * - VertexBuffer.PositionKind
  82987. * - VertexBuffer.UVKind
  82988. * - VertexBuffer.UV2Kind
  82989. * - VertexBuffer.UV3Kind
  82990. * - VertexBuffer.UV4Kind
  82991. * - VertexBuffer.UV5Kind
  82992. * - VertexBuffer.UV6Kind
  82993. * - VertexBuffer.ColorKind
  82994. * - VertexBuffer.MatricesIndicesKind
  82995. * - VertexBuffer.MatricesIndicesExtraKind
  82996. * - VertexBuffer.MatricesWeightsKind
  82997. * - VertexBuffer.MatricesWeightsExtraKind
  82998. * @param data defines the data source
  82999. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83000. * @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)
  83001. */
  83002. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83003. /**
  83004. * Creates a new index buffer
  83005. * @param indices defines the indices to store in the index buffer
  83006. * @param totalVertices defines the total number of vertices (could be null)
  83007. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83008. */
  83009. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83010. }
  83011. /**
  83012. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83013. */
  83014. export class VertexData {
  83015. /**
  83016. * Mesh side orientation : usually the external or front surface
  83017. */
  83018. static readonly FRONTSIDE: number;
  83019. /**
  83020. * Mesh side orientation : usually the internal or back surface
  83021. */
  83022. static readonly BACKSIDE: number;
  83023. /**
  83024. * Mesh side orientation : both internal and external or front and back surfaces
  83025. */
  83026. static readonly DOUBLESIDE: number;
  83027. /**
  83028. * Mesh side orientation : by default, `FRONTSIDE`
  83029. */
  83030. static readonly DEFAULTSIDE: number;
  83031. /**
  83032. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83033. */
  83034. positions: Nullable<FloatArray>;
  83035. /**
  83036. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83037. */
  83038. normals: Nullable<FloatArray>;
  83039. /**
  83040. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83041. */
  83042. tangents: Nullable<FloatArray>;
  83043. /**
  83044. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83045. */
  83046. uvs: Nullable<FloatArray>;
  83047. /**
  83048. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83049. */
  83050. uvs2: Nullable<FloatArray>;
  83051. /**
  83052. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83053. */
  83054. uvs3: Nullable<FloatArray>;
  83055. /**
  83056. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83057. */
  83058. uvs4: Nullable<FloatArray>;
  83059. /**
  83060. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83061. */
  83062. uvs5: Nullable<FloatArray>;
  83063. /**
  83064. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83065. */
  83066. uvs6: Nullable<FloatArray>;
  83067. /**
  83068. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83069. */
  83070. colors: Nullable<FloatArray>;
  83071. /**
  83072. * 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).
  83073. */
  83074. matricesIndices: Nullable<FloatArray>;
  83075. /**
  83076. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83077. */
  83078. matricesWeights: Nullable<FloatArray>;
  83079. /**
  83080. * An array extending the number of possible indices
  83081. */
  83082. matricesIndicesExtra: Nullable<FloatArray>;
  83083. /**
  83084. * An array extending the number of possible weights when the number of indices is extended
  83085. */
  83086. matricesWeightsExtra: Nullable<FloatArray>;
  83087. /**
  83088. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83089. */
  83090. indices: Nullable<IndicesArray>;
  83091. /**
  83092. * Uses the passed data array to set the set the values for the specified kind of data
  83093. * @param data a linear array of floating numbers
  83094. * @param kind the type of data that is being set, eg positions, colors etc
  83095. */
  83096. set(data: FloatArray, kind: string): void;
  83097. /**
  83098. * Associates the vertexData to the passed Mesh.
  83099. * Sets it as updatable or not (default `false`)
  83100. * @param mesh the mesh the vertexData is applied to
  83101. * @param updatable when used and having the value true allows new data to update the vertexData
  83102. * @returns the VertexData
  83103. */
  83104. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83105. /**
  83106. * Associates the vertexData to the passed Geometry.
  83107. * Sets it as updatable or not (default `false`)
  83108. * @param geometry the geometry the vertexData is applied to
  83109. * @param updatable when used and having the value true allows new data to update the vertexData
  83110. * @returns VertexData
  83111. */
  83112. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83113. /**
  83114. * Updates the associated mesh
  83115. * @param mesh the mesh to be updated
  83116. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83117. * @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
  83118. * @returns VertexData
  83119. */
  83120. updateMesh(mesh: Mesh): VertexData;
  83121. /**
  83122. * Updates the associated geometry
  83123. * @param geometry the geometry to be updated
  83124. * @param updateExtends when true 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. updateGeometry(geometry: Geometry): VertexData;
  83129. private _applyTo;
  83130. private _update;
  83131. /**
  83132. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83133. * @param matrix the transforming matrix
  83134. * @returns the VertexData
  83135. */
  83136. transform(matrix: Matrix): VertexData;
  83137. /**
  83138. * Merges the passed VertexData into the current one
  83139. * @param other the VertexData to be merged into the current one
  83140. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83141. * @returns the modified VertexData
  83142. */
  83143. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83144. private _mergeElement;
  83145. private _validate;
  83146. /**
  83147. * Serializes the VertexData
  83148. * @returns a serialized object
  83149. */
  83150. serialize(): any;
  83151. /**
  83152. * Extracts the vertexData from a mesh
  83153. * @param mesh the mesh from which to extract the VertexData
  83154. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83155. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83156. * @returns the object VertexData associated to the passed mesh
  83157. */
  83158. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83159. /**
  83160. * Extracts the vertexData from the geometry
  83161. * @param geometry the geometry from which to extract the VertexData
  83162. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is 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 ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83167. private static _ExtractFrom;
  83168. /**
  83169. * Creates the VertexData for a Ribbon
  83170. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83171. * * pathArray array of paths, each of which an array of successive Vector3
  83172. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83173. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83174. * * 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
  83175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83176. * * 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)
  83177. * * 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)
  83178. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83179. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83180. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83181. * @returns the VertexData of the ribbon
  83182. */
  83183. static CreateRibbon(options: {
  83184. pathArray: Vector3[][];
  83185. closeArray?: boolean;
  83186. closePath?: boolean;
  83187. offset?: number;
  83188. sideOrientation?: number;
  83189. frontUVs?: Vector4;
  83190. backUVs?: Vector4;
  83191. invertUV?: boolean;
  83192. uvs?: Vector2[];
  83193. colors?: Color4[];
  83194. }): VertexData;
  83195. /**
  83196. * Creates the VertexData for a box
  83197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83198. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83199. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83200. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83201. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83202. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83203. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83205. * * 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)
  83206. * * 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)
  83207. * @returns the VertexData of the box
  83208. */
  83209. static CreateBox(options: {
  83210. size?: number;
  83211. width?: number;
  83212. height?: number;
  83213. depth?: number;
  83214. faceUV?: Vector4[];
  83215. faceColors?: Color4[];
  83216. sideOrientation?: number;
  83217. frontUVs?: Vector4;
  83218. backUVs?: Vector4;
  83219. }): VertexData;
  83220. /**
  83221. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83223. * * segments sets the number of horizontal strips optional, default 32
  83224. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83225. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83226. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83227. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83228. * * 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
  83229. * * 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
  83230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83231. * * 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)
  83232. * * 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)
  83233. * @returns the VertexData of the ellipsoid
  83234. */
  83235. static CreateSphere(options: {
  83236. segments?: number;
  83237. diameter?: number;
  83238. diameterX?: number;
  83239. diameterY?: number;
  83240. diameterZ?: number;
  83241. arc?: number;
  83242. slice?: number;
  83243. sideOrientation?: number;
  83244. frontUVs?: Vector4;
  83245. backUVs?: Vector4;
  83246. }): VertexData;
  83247. /**
  83248. * Creates the VertexData for a cylinder, cone or prism
  83249. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83250. * * height sets the height (y direction) of the cylinder, optional, default 2
  83251. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83252. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83253. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83254. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83255. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83256. * * 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
  83257. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83258. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83259. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83260. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83262. * * 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)
  83263. * * 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)
  83264. * @returns the VertexData of the cylinder, cone or prism
  83265. */
  83266. static CreateCylinder(options: {
  83267. height?: number;
  83268. diameterTop?: number;
  83269. diameterBottom?: number;
  83270. diameter?: number;
  83271. tessellation?: number;
  83272. subdivisions?: number;
  83273. arc?: number;
  83274. faceColors?: Color4[];
  83275. faceUV?: Vector4[];
  83276. hasRings?: boolean;
  83277. enclose?: boolean;
  83278. sideOrientation?: number;
  83279. frontUVs?: Vector4;
  83280. backUVs?: Vector4;
  83281. }): VertexData;
  83282. /**
  83283. * Creates the VertexData for a torus
  83284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83285. * * diameter the diameter of the torus, optional default 1
  83286. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83287. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83289. * * 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)
  83290. * * 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)
  83291. * @returns the VertexData of the torus
  83292. */
  83293. static CreateTorus(options: {
  83294. diameter?: number;
  83295. thickness?: number;
  83296. tessellation?: number;
  83297. sideOrientation?: number;
  83298. frontUVs?: Vector4;
  83299. backUVs?: Vector4;
  83300. }): VertexData;
  83301. /**
  83302. * Creates the VertexData of the LineSystem
  83303. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83304. * - lines an array of lines, each line being an array of successive Vector3
  83305. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83306. * @returns the VertexData of the LineSystem
  83307. */
  83308. static CreateLineSystem(options: {
  83309. lines: Vector3[][];
  83310. colors?: Nullable<Color4[][]>;
  83311. }): VertexData;
  83312. /**
  83313. * Create the VertexData for a DashedLines
  83314. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83315. * - points an array successive Vector3
  83316. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83317. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83318. * - dashNb the intended total number of dashes, optional, default 200
  83319. * @returns the VertexData for the DashedLines
  83320. */
  83321. static CreateDashedLines(options: {
  83322. points: Vector3[];
  83323. dashSize?: number;
  83324. gapSize?: number;
  83325. dashNb?: number;
  83326. }): VertexData;
  83327. /**
  83328. * Creates the VertexData for a Ground
  83329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83330. * - width the width (x direction) of the ground, optional, default 1
  83331. * - height the height (z direction) of the ground, optional, default 1
  83332. * - subdivisions the number of subdivisions per side, optional, default 1
  83333. * @returns the VertexData of the Ground
  83334. */
  83335. static CreateGround(options: {
  83336. width?: number;
  83337. height?: number;
  83338. subdivisions?: number;
  83339. subdivisionsX?: number;
  83340. subdivisionsY?: number;
  83341. }): VertexData;
  83342. /**
  83343. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83344. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83345. * * xmin the ground minimum X coordinate, optional, default -1
  83346. * * zmin the ground minimum Z coordinate, optional, default -1
  83347. * * xmax the ground maximum X coordinate, optional, default 1
  83348. * * zmax the ground maximum Z coordinate, optional, default 1
  83349. * * 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}
  83350. * * 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}
  83351. * @returns the VertexData of the TiledGround
  83352. */
  83353. static CreateTiledGround(options: {
  83354. xmin: number;
  83355. zmin: number;
  83356. xmax: number;
  83357. zmax: number;
  83358. subdivisions?: {
  83359. w: number;
  83360. h: number;
  83361. };
  83362. precision?: {
  83363. w: number;
  83364. h: number;
  83365. };
  83366. }): VertexData;
  83367. /**
  83368. * Creates the VertexData of the Ground designed from a heightmap
  83369. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83370. * * width the width (x direction) of the ground
  83371. * * height the height (z direction) of the ground
  83372. * * subdivisions the number of subdivisions per side
  83373. * * minHeight the minimum altitude on the ground, optional, default 0
  83374. * * maxHeight the maximum altitude on the ground, optional default 1
  83375. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83376. * * buffer the array holding the image color data
  83377. * * bufferWidth the width of image
  83378. * * bufferHeight the height of image
  83379. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83380. * @returns the VertexData of the Ground designed from a heightmap
  83381. */
  83382. static CreateGroundFromHeightMap(options: {
  83383. width: number;
  83384. height: number;
  83385. subdivisions: number;
  83386. minHeight: number;
  83387. maxHeight: number;
  83388. colorFilter: Color3;
  83389. buffer: Uint8Array;
  83390. bufferWidth: number;
  83391. bufferHeight: number;
  83392. alphaFilter: number;
  83393. }): VertexData;
  83394. /**
  83395. * Creates the VertexData for a Plane
  83396. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83397. * * size sets the width and height of the plane to the value of size, optional default 1
  83398. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83399. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83401. * * 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)
  83402. * * 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)
  83403. * @returns the VertexData of the box
  83404. */
  83405. static CreatePlane(options: {
  83406. size?: number;
  83407. width?: number;
  83408. height?: number;
  83409. sideOrientation?: number;
  83410. frontUVs?: Vector4;
  83411. backUVs?: Vector4;
  83412. }): VertexData;
  83413. /**
  83414. * Creates the VertexData of the Disc or regular Polygon
  83415. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83416. * * radius the radius of the disc, optional default 0.5
  83417. * * tessellation the number of polygon sides, optional, default 64
  83418. * * 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
  83419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83420. * * 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)
  83421. * * 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)
  83422. * @returns the VertexData of the box
  83423. */
  83424. static CreateDisc(options: {
  83425. radius?: number;
  83426. tessellation?: number;
  83427. arc?: number;
  83428. sideOrientation?: number;
  83429. frontUVs?: Vector4;
  83430. backUVs?: Vector4;
  83431. }): VertexData;
  83432. /**
  83433. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83434. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83435. * @param polygon a mesh built from polygonTriangulation.build()
  83436. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83437. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83438. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83439. * @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)
  83440. * @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)
  83441. * @returns the VertexData of the Polygon
  83442. */
  83443. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83444. /**
  83445. * Creates the VertexData of the IcoSphere
  83446. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83447. * * radius the radius of the IcoSphere, optional default 1
  83448. * * radiusX allows stretching in the x direction, optional, default radius
  83449. * * radiusY allows stretching in the y direction, optional, default radius
  83450. * * radiusZ allows stretching in the z direction, optional, default radius
  83451. * * flat when true creates a flat shaded mesh, optional, default true
  83452. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83454. * * 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)
  83455. * * 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)
  83456. * @returns the VertexData of the IcoSphere
  83457. */
  83458. static CreateIcoSphere(options: {
  83459. radius?: number;
  83460. radiusX?: number;
  83461. radiusY?: number;
  83462. radiusZ?: number;
  83463. flat?: boolean;
  83464. subdivisions?: number;
  83465. sideOrientation?: number;
  83466. frontUVs?: Vector4;
  83467. backUVs?: Vector4;
  83468. }): VertexData;
  83469. /**
  83470. * Creates the VertexData for a Polyhedron
  83471. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83472. * * type provided types are:
  83473. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83474. * * 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)
  83475. * * size the size of the IcoSphere, optional default 1
  83476. * * sizeX allows stretching in the x direction, optional, default size
  83477. * * sizeY allows stretching in the y direction, optional, default size
  83478. * * sizeZ allows stretching in the z direction, optional, default size
  83479. * * 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
  83480. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83481. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83482. * * flat when true creates a flat shaded mesh, optional, default true
  83483. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83485. * * 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)
  83486. * * 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)
  83487. * @returns the VertexData of the Polyhedron
  83488. */
  83489. static CreatePolyhedron(options: {
  83490. type?: number;
  83491. size?: number;
  83492. sizeX?: number;
  83493. sizeY?: number;
  83494. sizeZ?: number;
  83495. custom?: any;
  83496. faceUV?: Vector4[];
  83497. faceColors?: Color4[];
  83498. flat?: boolean;
  83499. sideOrientation?: number;
  83500. frontUVs?: Vector4;
  83501. backUVs?: Vector4;
  83502. }): VertexData;
  83503. /**
  83504. * Creates the VertexData for a TorusKnot
  83505. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83506. * * radius the radius of the torus knot, optional, default 2
  83507. * * tube the thickness of the tube, optional, default 0.5
  83508. * * radialSegments the number of sides on each tube segments, optional, default 32
  83509. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83510. * * p the number of windings around the z axis, optional, default 2
  83511. * * q the number of windings around the x axis, optional, default 3
  83512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83513. * * 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)
  83514. * * 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)
  83515. * @returns the VertexData of the Torus Knot
  83516. */
  83517. static CreateTorusKnot(options: {
  83518. radius?: number;
  83519. tube?: number;
  83520. radialSegments?: number;
  83521. tubularSegments?: number;
  83522. p?: number;
  83523. q?: number;
  83524. sideOrientation?: number;
  83525. frontUVs?: Vector4;
  83526. backUVs?: Vector4;
  83527. }): VertexData;
  83528. /**
  83529. * Compute normals for given positions and indices
  83530. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83531. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83532. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83533. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83534. * * facetNormals : optional array of facet normals (vector3)
  83535. * * facetPositions : optional array of facet positions (vector3)
  83536. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83537. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83538. * * bInfo : optional bounding info, required for facetPartitioning computation
  83539. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83540. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83541. * * useRightHandedSystem: optional boolean to for right handed system computation
  83542. * * depthSort : optional boolean to enable the facet depth sort computation
  83543. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83544. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83545. */
  83546. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83547. facetNormals?: any;
  83548. facetPositions?: any;
  83549. facetPartitioning?: any;
  83550. ratio?: number;
  83551. bInfo?: any;
  83552. bbSize?: Vector3;
  83553. subDiv?: any;
  83554. useRightHandedSystem?: boolean;
  83555. depthSort?: boolean;
  83556. distanceTo?: Vector3;
  83557. depthSortedFacets?: any;
  83558. }): void;
  83559. /** @hidden */
  83560. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83561. /**
  83562. * Applies VertexData created from the imported parameters to the geometry
  83563. * @param parsedVertexData the parsed data from an imported file
  83564. * @param geometry the geometry to apply the VertexData to
  83565. */
  83566. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83567. }
  83568. }
  83569. declare module BABYLON {
  83570. /**
  83571. * Class containing static functions to help procedurally build meshes
  83572. */
  83573. export class DiscBuilder {
  83574. /**
  83575. * Creates a plane polygonal mesh. By default, this is a disc
  83576. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83577. * * 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
  83578. * * 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
  83579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83582. * @param name defines the name of the mesh
  83583. * @param options defines the options used to create the mesh
  83584. * @param scene defines the hosting scene
  83585. * @returns the plane polygonal mesh
  83586. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83587. */
  83588. static CreateDisc(name: string, options: {
  83589. radius?: number;
  83590. tessellation?: number;
  83591. arc?: number;
  83592. updatable?: boolean;
  83593. sideOrientation?: number;
  83594. frontUVs?: Vector4;
  83595. backUVs?: Vector4;
  83596. }, scene?: Nullable<Scene>): Mesh;
  83597. }
  83598. }
  83599. declare module BABYLON {
  83600. /**
  83601. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83602. *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.
  83603. * The SPS is also a particle system. It provides some methods to manage the particles.
  83604. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83605. *
  83606. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83607. */
  83608. export class SolidParticleSystem implements IDisposable {
  83609. /**
  83610. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83611. * Example : var p = SPS.particles[i];
  83612. */
  83613. particles: SolidParticle[];
  83614. /**
  83615. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83616. */
  83617. nbParticles: number;
  83618. /**
  83619. * If the particles must ever face the camera (default false). Useful for planar particles.
  83620. */
  83621. billboard: boolean;
  83622. /**
  83623. * Recompute normals when adding a shape
  83624. */
  83625. recomputeNormals: boolean;
  83626. /**
  83627. * This a counter ofr your own usage. It's not set by any SPS functions.
  83628. */
  83629. counter: number;
  83630. /**
  83631. * The SPS name. This name is also given to the underlying mesh.
  83632. */
  83633. name: string;
  83634. /**
  83635. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83636. */
  83637. mesh: Mesh;
  83638. /**
  83639. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83640. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83641. */
  83642. vars: any;
  83643. /**
  83644. * This array is populated when the SPS is set as 'pickable'.
  83645. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83646. * Each element of this array is an object `{idx: int, faceId: int}`.
  83647. * `idx` is the picked particle index in the `SPS.particles` array
  83648. * `faceId` is the picked face index counted within this particle.
  83649. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83650. */
  83651. pickedParticles: {
  83652. idx: number;
  83653. faceId: number;
  83654. }[];
  83655. /**
  83656. * This array is populated when `enableDepthSort` is set to true.
  83657. * Each element of this array is an instance of the class DepthSortedParticle.
  83658. */
  83659. depthSortedParticles: DepthSortedParticle[];
  83660. /**
  83661. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83662. * @hidden
  83663. */
  83664. _bSphereOnly: boolean;
  83665. /**
  83666. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83667. * @hidden
  83668. */
  83669. _bSphereRadiusFactor: number;
  83670. private _scene;
  83671. private _positions;
  83672. private _indices;
  83673. private _normals;
  83674. private _colors;
  83675. private _uvs;
  83676. private _indices32;
  83677. private _positions32;
  83678. private _normals32;
  83679. private _fixedNormal32;
  83680. private _colors32;
  83681. private _uvs32;
  83682. private _index;
  83683. private _updatable;
  83684. private _pickable;
  83685. private _isVisibilityBoxLocked;
  83686. private _alwaysVisible;
  83687. private _depthSort;
  83688. private _shapeCounter;
  83689. private _copy;
  83690. private _color;
  83691. private _computeParticleColor;
  83692. private _computeParticleTexture;
  83693. private _computeParticleRotation;
  83694. private _computeParticleVertex;
  83695. private _computeBoundingBox;
  83696. private _depthSortParticles;
  83697. private _camera;
  83698. private _mustUnrotateFixedNormals;
  83699. private _particlesIntersect;
  83700. private _needs32Bits;
  83701. /**
  83702. * Creates a SPS (Solid Particle System) object.
  83703. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83704. * @param scene (Scene) is the scene in which the SPS is added.
  83705. * @param options defines the options of the sps e.g.
  83706. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83707. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83708. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83709. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83710. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83711. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83712. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83713. */
  83714. constructor(name: string, scene: Scene, options?: {
  83715. updatable?: boolean;
  83716. isPickable?: boolean;
  83717. enableDepthSort?: boolean;
  83718. particleIntersection?: boolean;
  83719. boundingSphereOnly?: boolean;
  83720. bSphereRadiusFactor?: number;
  83721. });
  83722. /**
  83723. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83724. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83725. * @returns the created mesh
  83726. */
  83727. buildMesh(): Mesh;
  83728. /**
  83729. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83730. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83731. * Thus the particles generated from `digest()` have their property `position` set yet.
  83732. * @param mesh ( Mesh ) is the mesh to be digested
  83733. * @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
  83734. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83735. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83736. * @returns the current SPS
  83737. */
  83738. digest(mesh: Mesh, options?: {
  83739. facetNb?: number;
  83740. number?: number;
  83741. delta?: number;
  83742. }): SolidParticleSystem;
  83743. private _unrotateFixedNormals;
  83744. private _resetCopy;
  83745. private _meshBuilder;
  83746. private _posToShape;
  83747. private _uvsToShapeUV;
  83748. private _addParticle;
  83749. /**
  83750. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83751. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83752. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83753. * @param nb (positive integer) the number of particles to be created from this model
  83754. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83755. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83756. * @returns the number of shapes in the system
  83757. */
  83758. addShape(mesh: Mesh, nb: number, options?: {
  83759. positionFunction?: any;
  83760. vertexFunction?: any;
  83761. }): number;
  83762. private _rebuildParticle;
  83763. /**
  83764. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83765. * @returns the SPS.
  83766. */
  83767. rebuildMesh(): SolidParticleSystem;
  83768. /**
  83769. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83770. * This method calls `updateParticle()` for each particle of the SPS.
  83771. * For an animated SPS, it is usually called within the render loop.
  83772. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83773. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83774. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83775. * @returns the SPS.
  83776. */
  83777. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83778. /**
  83779. * Disposes the SPS.
  83780. */
  83781. dispose(): void;
  83782. /**
  83783. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83784. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83785. * @returns the SPS.
  83786. */
  83787. refreshVisibleSize(): SolidParticleSystem;
  83788. /**
  83789. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83790. * @param size the size (float) of the visibility box
  83791. * note : this doesn't lock the SPS mesh bounding box.
  83792. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83793. */
  83794. setVisibilityBox(size: number): void;
  83795. /**
  83796. * Gets whether the SPS as always visible or not
  83797. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83798. */
  83799. /**
  83800. * Sets the SPS as always visible or not
  83801. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83802. */
  83803. isAlwaysVisible: boolean;
  83804. /**
  83805. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83806. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83807. */
  83808. /**
  83809. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83810. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83811. */
  83812. isVisibilityBoxLocked: boolean;
  83813. /**
  83814. * Tells to `setParticles()` to compute the particle rotations or not.
  83815. * Default value : true. The SPS is faster when it's set to false.
  83816. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83817. */
  83818. /**
  83819. * Gets if `setParticles()` computes the particle rotations or not.
  83820. * Default value : true. The SPS is faster when it's set to false.
  83821. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83822. */
  83823. computeParticleRotation: boolean;
  83824. /**
  83825. * Tells to `setParticles()` to compute the particle colors or not.
  83826. * Default value : true. The SPS is faster when it's set to false.
  83827. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83828. */
  83829. /**
  83830. * Gets if `setParticles()` computes the particle colors or not.
  83831. * Default value : true. The SPS is faster when it's set to false.
  83832. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83833. */
  83834. computeParticleColor: boolean;
  83835. /**
  83836. * Gets if `setParticles()` computes the particle textures or not.
  83837. * Default value : true. The SPS is faster when it's set to false.
  83838. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83839. */
  83840. computeParticleTexture: boolean;
  83841. /**
  83842. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83843. * Default value : false. The SPS is faster when it's set to false.
  83844. * Note : the particle custom vertex positions aren't stored values.
  83845. */
  83846. /**
  83847. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83848. * Default value : false. The SPS is faster when it's set to false.
  83849. * Note : the particle custom vertex positions aren't stored values.
  83850. */
  83851. computeParticleVertex: boolean;
  83852. /**
  83853. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83854. */
  83855. /**
  83856. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83857. */
  83858. computeBoundingBox: boolean;
  83859. /**
  83860. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83861. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83862. * Default : `true`
  83863. */
  83864. /**
  83865. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83866. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83867. * Default : `true`
  83868. */
  83869. depthSortParticles: boolean;
  83870. /**
  83871. * This function does nothing. It may be overwritten to set all the particle first values.
  83872. * The SPS doesn't call this function, you may have to call it by your own.
  83873. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83874. */
  83875. initParticles(): void;
  83876. /**
  83877. * This function does nothing. It may be overwritten to recycle a particle.
  83878. * The SPS doesn't call this function, you may have to call it by your own.
  83879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83880. * @param particle The particle to recycle
  83881. * @returns the recycled particle
  83882. */
  83883. recycleParticle(particle: SolidParticle): SolidParticle;
  83884. /**
  83885. * Updates a particle : this function should be overwritten by the user.
  83886. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83888. * @example : just set a particle position or velocity and recycle conditions
  83889. * @param particle The particle to update
  83890. * @returns the updated particle
  83891. */
  83892. updateParticle(particle: SolidParticle): SolidParticle;
  83893. /**
  83894. * Updates a vertex of a particle : it can be overwritten by the user.
  83895. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83896. * @param particle the current particle
  83897. * @param vertex the current index of the current particle
  83898. * @param pt the index of the current vertex in the particle shape
  83899. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83900. * @example : just set a vertex particle position
  83901. * @returns the updated vertex
  83902. */
  83903. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83904. /**
  83905. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83906. * This does nothing and may be overwritten by the user.
  83907. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83908. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83909. * @param update the boolean update value actually passed to setParticles()
  83910. */
  83911. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83912. /**
  83913. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83914. * This will be passed three parameters.
  83915. * This does nothing and may be overwritten by the user.
  83916. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83917. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83918. * @param update the boolean update value actually passed to setParticles()
  83919. */
  83920. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83921. }
  83922. }
  83923. declare module BABYLON {
  83924. /**
  83925. * Represents one particle of a solid particle system.
  83926. */
  83927. export class SolidParticle {
  83928. /**
  83929. * particle global index
  83930. */
  83931. idx: number;
  83932. /**
  83933. * The color of the particle
  83934. */
  83935. color: Nullable<Color4>;
  83936. /**
  83937. * The world space position of the particle.
  83938. */
  83939. position: Vector3;
  83940. /**
  83941. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83942. */
  83943. rotation: Vector3;
  83944. /**
  83945. * The world space rotation quaternion of the particle.
  83946. */
  83947. rotationQuaternion: Nullable<Quaternion>;
  83948. /**
  83949. * The scaling of the particle.
  83950. */
  83951. scaling: Vector3;
  83952. /**
  83953. * The uvs of the particle.
  83954. */
  83955. uvs: Vector4;
  83956. /**
  83957. * The current speed of the particle.
  83958. */
  83959. velocity: Vector3;
  83960. /**
  83961. * The pivot point in the particle local space.
  83962. */
  83963. pivot: Vector3;
  83964. /**
  83965. * Must the particle be translated from its pivot point in its local space ?
  83966. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83967. * Default : false
  83968. */
  83969. translateFromPivot: boolean;
  83970. /**
  83971. * Is the particle active or not ?
  83972. */
  83973. alive: boolean;
  83974. /**
  83975. * Is the particle visible or not ?
  83976. */
  83977. isVisible: boolean;
  83978. /**
  83979. * Index of this particle in the global "positions" array (Internal use)
  83980. * @hidden
  83981. */
  83982. _pos: number;
  83983. /**
  83984. * @hidden Index of this particle in the global "indices" array (Internal use)
  83985. */
  83986. _ind: number;
  83987. /**
  83988. * @hidden ModelShape of this particle (Internal use)
  83989. */
  83990. _model: ModelShape;
  83991. /**
  83992. * ModelShape id of this particle
  83993. */
  83994. shapeId: number;
  83995. /**
  83996. * Index of the particle in its shape id (Internal use)
  83997. */
  83998. idxInShape: number;
  83999. /**
  84000. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84001. */
  84002. _modelBoundingInfo: BoundingInfo;
  84003. /**
  84004. * @hidden Particle BoundingInfo object (Internal use)
  84005. */
  84006. _boundingInfo: BoundingInfo;
  84007. /**
  84008. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84009. */
  84010. _sps: SolidParticleSystem;
  84011. /**
  84012. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84013. */
  84014. _stillInvisible: boolean;
  84015. /**
  84016. * @hidden Last computed particle rotation matrix
  84017. */
  84018. _rotationMatrix: number[];
  84019. /**
  84020. * Parent particle Id, if any.
  84021. * Default null.
  84022. */
  84023. parentId: Nullable<number>;
  84024. /**
  84025. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84026. * The possible values are :
  84027. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84028. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84029. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84031. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84032. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84033. * */
  84034. cullingStrategy: number;
  84035. /**
  84036. * @hidden Internal global position in the SPS.
  84037. */
  84038. _globalPosition: Vector3;
  84039. /**
  84040. * Creates a Solid Particle object.
  84041. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84042. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84043. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84044. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84045. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84046. * @param shapeId (integer) is the model shape identifier in the SPS.
  84047. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84048. * @param sps defines the sps it is associated to
  84049. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84050. */
  84051. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84052. /**
  84053. * Legacy support, changed scale to scaling
  84054. */
  84055. /**
  84056. * Legacy support, changed scale to scaling
  84057. */
  84058. scale: Vector3;
  84059. /**
  84060. * Legacy support, changed quaternion to rotationQuaternion
  84061. */
  84062. /**
  84063. * Legacy support, changed quaternion to rotationQuaternion
  84064. */
  84065. quaternion: Nullable<Quaternion>;
  84066. /**
  84067. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84068. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84069. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84070. * @returns true if it intersects
  84071. */
  84072. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84073. /**
  84074. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84075. * A particle is in the frustum if its bounding box intersects the frustum
  84076. * @param frustumPlanes defines the frustum to test
  84077. * @returns true if the particle is in the frustum planes
  84078. */
  84079. isInFrustum(frustumPlanes: Plane[]): boolean;
  84080. /**
  84081. * get the rotation matrix of the particle
  84082. * @hidden
  84083. */
  84084. getRotationMatrix(m: Matrix): void;
  84085. }
  84086. /**
  84087. * Represents the shape of the model used by one particle of a solid particle system.
  84088. * SPS internal tool, don't use it manually.
  84089. */
  84090. export class ModelShape {
  84091. /**
  84092. * The shape id
  84093. * @hidden
  84094. */
  84095. shapeID: number;
  84096. /**
  84097. * flat array of model positions (internal use)
  84098. * @hidden
  84099. */
  84100. _shape: Vector3[];
  84101. /**
  84102. * flat array of model UVs (internal use)
  84103. * @hidden
  84104. */
  84105. _shapeUV: number[];
  84106. /**
  84107. * length of the shape in the model indices array (internal use)
  84108. * @hidden
  84109. */
  84110. _indicesLength: number;
  84111. /**
  84112. * Custom position function (internal use)
  84113. * @hidden
  84114. */
  84115. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84116. /**
  84117. * Custom vertex function (internal use)
  84118. * @hidden
  84119. */
  84120. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84121. /**
  84122. * 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.
  84123. * SPS internal tool, don't use it manually.
  84124. * @hidden
  84125. */
  84126. 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>);
  84127. }
  84128. /**
  84129. * Represents a Depth Sorted Particle in the solid particle system.
  84130. */
  84131. export class DepthSortedParticle {
  84132. /**
  84133. * Index of the particle in the "indices" array
  84134. */
  84135. ind: number;
  84136. /**
  84137. * Length of the particle shape in the "indices" array
  84138. */
  84139. indicesLength: number;
  84140. /**
  84141. * Squared distance from the particle to the camera
  84142. */
  84143. sqDistance: number;
  84144. }
  84145. }
  84146. declare module BABYLON {
  84147. /**
  84148. * @hidden
  84149. */
  84150. export class _MeshCollisionData {
  84151. _checkCollisions: boolean;
  84152. _collisionMask: number;
  84153. _collisionGroup: number;
  84154. _collider: Nullable<Collider>;
  84155. _oldPositionForCollisions: Vector3;
  84156. _diffPositionForCollisions: Vector3;
  84157. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84158. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84159. }
  84160. }
  84161. declare module BABYLON {
  84162. /**
  84163. * Class used to store all common mesh properties
  84164. */
  84165. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84166. /** No occlusion */
  84167. static OCCLUSION_TYPE_NONE: number;
  84168. /** Occlusion set to optimisitic */
  84169. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84170. /** Occlusion set to strict */
  84171. static OCCLUSION_TYPE_STRICT: number;
  84172. /** Use an accurante occlusion algorithm */
  84173. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84174. /** Use a conservative occlusion algorithm */
  84175. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84176. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84177. * Test order :
  84178. * Is the bounding sphere outside the frustum ?
  84179. * If not, are the bounding box vertices outside the frustum ?
  84180. * It not, then the cullable object is in the frustum.
  84181. */
  84182. static readonly CULLINGSTRATEGY_STANDARD: number;
  84183. /** Culling strategy : Bounding Sphere Only.
  84184. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84185. * It's also less accurate than the standard because some not visible objects can still be selected.
  84186. * Test : is the bounding sphere outside the frustum ?
  84187. * If not, then the cullable object is in the frustum.
  84188. */
  84189. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84190. /** Culling strategy : Optimistic Inclusion.
  84191. * This in an inclusion test first, then the standard exclusion test.
  84192. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84193. * 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.
  84194. * Anyway, it's as accurate as the standard strategy.
  84195. * Test :
  84196. * Is the cullable object bounding sphere center in the frustum ?
  84197. * If not, apply the default culling strategy.
  84198. */
  84199. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84200. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84201. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84202. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84203. * 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.
  84204. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84205. * Test :
  84206. * Is the cullable object bounding sphere center in the frustum ?
  84207. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84208. */
  84209. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84210. /**
  84211. * No billboard
  84212. */
  84213. static readonly BILLBOARDMODE_NONE: number;
  84214. /** Billboard on X axis */
  84215. static readonly BILLBOARDMODE_X: number;
  84216. /** Billboard on Y axis */
  84217. static readonly BILLBOARDMODE_Y: number;
  84218. /** Billboard on Z axis */
  84219. static readonly BILLBOARDMODE_Z: number;
  84220. /** Billboard on all axes */
  84221. static readonly BILLBOARDMODE_ALL: number;
  84222. private _internalAbstractMeshDataInfo;
  84223. /**
  84224. * The culling strategy to use to check whether the mesh must be rendered or not.
  84225. * This value can be changed at any time and will be used on the next render mesh selection.
  84226. * The possible values are :
  84227. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84228. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84229. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84231. * Please read each static variable documentation to get details about the culling process.
  84232. * */
  84233. cullingStrategy: number;
  84234. /**
  84235. * Gets the number of facets in the mesh
  84236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84237. */
  84238. readonly facetNb: number;
  84239. /**
  84240. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84242. */
  84243. partitioningSubdivisions: number;
  84244. /**
  84245. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84246. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84248. */
  84249. partitioningBBoxRatio: number;
  84250. /**
  84251. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84252. * Works only for updatable meshes.
  84253. * Doesn't work with multi-materials
  84254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84255. */
  84256. mustDepthSortFacets: boolean;
  84257. /**
  84258. * The location (Vector3) where the facet depth sort must be computed from.
  84259. * By default, the active camera position.
  84260. * Used only when facet depth sort is enabled
  84261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84262. */
  84263. facetDepthSortFrom: Vector3;
  84264. /**
  84265. * gets a boolean indicating if facetData is enabled
  84266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84267. */
  84268. readonly isFacetDataEnabled: boolean;
  84269. /** @hidden */
  84270. _updateNonUniformScalingState(value: boolean): boolean;
  84271. /**
  84272. * An event triggered when this mesh collides with another one
  84273. */
  84274. onCollideObservable: Observable<AbstractMesh>;
  84275. /** Set a function to call when this mesh collides with another one */
  84276. onCollide: () => void;
  84277. /**
  84278. * An event triggered when the collision's position changes
  84279. */
  84280. onCollisionPositionChangeObservable: Observable<Vector3>;
  84281. /** Set a function to call when the collision's position changes */
  84282. onCollisionPositionChange: () => void;
  84283. /**
  84284. * An event triggered when material is changed
  84285. */
  84286. onMaterialChangedObservable: Observable<AbstractMesh>;
  84287. /**
  84288. * Gets or sets the orientation for POV movement & rotation
  84289. */
  84290. definedFacingForward: boolean;
  84291. /** @hidden */
  84292. _occlusionQuery: Nullable<WebGLQuery>;
  84293. /** @hidden */
  84294. _isActive: boolean;
  84295. /** @hidden */
  84296. _onlyForInstances: boolean;
  84297. /** @hidden */
  84298. _renderingGroup: Nullable<RenderingGroup>;
  84299. /**
  84300. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84301. */
  84302. /**
  84303. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84304. */
  84305. visibility: number;
  84306. /** Gets or sets the alpha index used to sort transparent meshes
  84307. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84308. */
  84309. alphaIndex: number;
  84310. /**
  84311. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84312. */
  84313. isVisible: boolean;
  84314. /**
  84315. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84316. */
  84317. isPickable: boolean;
  84318. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84319. showSubMeshesBoundingBox: boolean;
  84320. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84321. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84322. */
  84323. isBlocker: boolean;
  84324. /**
  84325. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84326. */
  84327. enablePointerMoveEvents: boolean;
  84328. /**
  84329. * Specifies the rendering group id for this mesh (0 by default)
  84330. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84331. */
  84332. renderingGroupId: number;
  84333. private _material;
  84334. /** Gets or sets current material */
  84335. material: Nullable<Material>;
  84336. /**
  84337. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84338. * @see http://doc.babylonjs.com/babylon101/shadows
  84339. */
  84340. receiveShadows: boolean;
  84341. /** Defines color to use when rendering outline */
  84342. outlineColor: Color3;
  84343. /** Define width to use when rendering outline */
  84344. outlineWidth: number;
  84345. /** Defines color to use when rendering overlay */
  84346. overlayColor: Color3;
  84347. /** Defines alpha to use when rendering overlay */
  84348. overlayAlpha: number;
  84349. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84350. hasVertexAlpha: boolean;
  84351. /** 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) */
  84352. useVertexColors: boolean;
  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. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84358. numBoneInfluencers: number;
  84359. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84360. applyFog: boolean;
  84361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84362. useOctreeForRenderingSelection: boolean;
  84363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84364. useOctreeForPicking: boolean;
  84365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84366. useOctreeForCollisions: boolean;
  84367. /**
  84368. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84369. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84370. */
  84371. layerMask: number;
  84372. /**
  84373. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84374. */
  84375. alwaysSelectAsActiveMesh: boolean;
  84376. /**
  84377. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84378. */
  84379. doNotSyncBoundingInfo: boolean;
  84380. /**
  84381. * Gets or sets the current action manager
  84382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84383. */
  84384. actionManager: Nullable<AbstractActionManager>;
  84385. private _meshCollisionData;
  84386. /**
  84387. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84389. */
  84390. ellipsoid: Vector3;
  84391. /**
  84392. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84394. */
  84395. ellipsoidOffset: Vector3;
  84396. /**
  84397. * Gets or sets a collision mask used to mask collisions (default is -1).
  84398. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84399. */
  84400. collisionMask: number;
  84401. /**
  84402. * Gets or sets the current collision group mask (-1 by default).
  84403. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84404. */
  84405. collisionGroup: number;
  84406. /**
  84407. * Defines edge width used when edgesRenderer is enabled
  84408. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84409. */
  84410. edgesWidth: number;
  84411. /**
  84412. * Defines edge color used when edgesRenderer is enabled
  84413. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84414. */
  84415. edgesColor: Color4;
  84416. /** @hidden */
  84417. _edgesRenderer: Nullable<IEdgesRenderer>;
  84418. /** @hidden */
  84419. _masterMesh: Nullable<AbstractMesh>;
  84420. /** @hidden */
  84421. _boundingInfo: Nullable<BoundingInfo>;
  84422. /** @hidden */
  84423. _renderId: number;
  84424. /**
  84425. * Gets or sets the list of subMeshes
  84426. * @see http://doc.babylonjs.com/how_to/multi_materials
  84427. */
  84428. subMeshes: SubMesh[];
  84429. /** @hidden */
  84430. _intersectionsInProgress: AbstractMesh[];
  84431. /** @hidden */
  84432. _unIndexed: boolean;
  84433. /** @hidden */
  84434. _lightSources: Light[];
  84435. /** Gets the list of lights affecting that mesh */
  84436. readonly lightSources: Light[];
  84437. /** @hidden */
  84438. readonly _positions: Nullable<Vector3[]>;
  84439. /** @hidden */
  84440. _waitingData: {
  84441. lods: Nullable<any>;
  84442. actions: Nullable<any>;
  84443. freezeWorldMatrix: Nullable<boolean>;
  84444. };
  84445. /** @hidden */
  84446. _bonesTransformMatrices: Nullable<Float32Array>;
  84447. /**
  84448. * Gets or sets a skeleton to apply skining transformations
  84449. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84450. */
  84451. skeleton: Nullable<Skeleton>;
  84452. /**
  84453. * An event triggered when the mesh is rebuilt.
  84454. */
  84455. onRebuildObservable: Observable<AbstractMesh>;
  84456. /**
  84457. * Creates a new AbstractMesh
  84458. * @param name defines the name of the mesh
  84459. * @param scene defines the hosting scene
  84460. */
  84461. constructor(name: string, scene?: Nullable<Scene>);
  84462. /**
  84463. * Returns the string "AbstractMesh"
  84464. * @returns "AbstractMesh"
  84465. */
  84466. getClassName(): string;
  84467. /**
  84468. * Gets a string representation of the current mesh
  84469. * @param fullDetails defines a boolean indicating if full details must be included
  84470. * @returns a string representation of the current mesh
  84471. */
  84472. toString(fullDetails?: boolean): string;
  84473. /**
  84474. * @hidden
  84475. */
  84476. protected _getEffectiveParent(): Nullable<Node>;
  84477. /** @hidden */
  84478. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84479. /** @hidden */
  84480. _rebuild(): void;
  84481. /** @hidden */
  84482. _resyncLightSources(): void;
  84483. /** @hidden */
  84484. _resyncLighSource(light: Light): void;
  84485. /** @hidden */
  84486. _unBindEffect(): void;
  84487. /** @hidden */
  84488. _removeLightSource(light: Light): void;
  84489. private _markSubMeshesAsDirty;
  84490. /** @hidden */
  84491. _markSubMeshesAsLightDirty(): void;
  84492. /** @hidden */
  84493. _markSubMeshesAsAttributesDirty(): void;
  84494. /** @hidden */
  84495. _markSubMeshesAsMiscDirty(): void;
  84496. /**
  84497. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84498. */
  84499. scaling: Vector3;
  84500. /**
  84501. * Returns true if the mesh is blocked. Implemented by child classes
  84502. */
  84503. readonly isBlocked: boolean;
  84504. /**
  84505. * Returns the mesh itself by default. Implemented by child classes
  84506. * @param camera defines the camera to use to pick the right LOD level
  84507. * @returns the currentAbstractMesh
  84508. */
  84509. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84510. /**
  84511. * Returns 0 by default. Implemented by child classes
  84512. * @returns an integer
  84513. */
  84514. getTotalVertices(): number;
  84515. /**
  84516. * Returns a positive integer : the total number of indices in this mesh geometry.
  84517. * @returns the numner of indices or zero if the mesh has no geometry.
  84518. */
  84519. getTotalIndices(): number;
  84520. /**
  84521. * Returns null by default. Implemented by child classes
  84522. * @returns null
  84523. */
  84524. getIndices(): Nullable<IndicesArray>;
  84525. /**
  84526. * Returns the array of the requested vertex data kind. Implemented by child classes
  84527. * @param kind defines the vertex data kind to use
  84528. * @returns null
  84529. */
  84530. getVerticesData(kind: string): Nullable<FloatArray>;
  84531. /**
  84532. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84533. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84534. * Note that a new underlying VertexBuffer object is created each call.
  84535. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84536. * @param kind defines vertex data kind:
  84537. * * VertexBuffer.PositionKind
  84538. * * VertexBuffer.UVKind
  84539. * * VertexBuffer.UV2Kind
  84540. * * VertexBuffer.UV3Kind
  84541. * * VertexBuffer.UV4Kind
  84542. * * VertexBuffer.UV5Kind
  84543. * * VertexBuffer.UV6Kind
  84544. * * VertexBuffer.ColorKind
  84545. * * VertexBuffer.MatricesIndicesKind
  84546. * * VertexBuffer.MatricesIndicesExtraKind
  84547. * * VertexBuffer.MatricesWeightsKind
  84548. * * VertexBuffer.MatricesWeightsExtraKind
  84549. * @param data defines the data source
  84550. * @param updatable defines if the data must be flagged as updatable (or static)
  84551. * @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
  84552. * @returns the current mesh
  84553. */
  84554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84555. /**
  84556. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84557. * If the mesh has no geometry, it is simply returned as it is.
  84558. * @param kind defines vertex data kind:
  84559. * * VertexBuffer.PositionKind
  84560. * * VertexBuffer.UVKind
  84561. * * VertexBuffer.UV2Kind
  84562. * * VertexBuffer.UV3Kind
  84563. * * VertexBuffer.UV4Kind
  84564. * * VertexBuffer.UV5Kind
  84565. * * VertexBuffer.UV6Kind
  84566. * * VertexBuffer.ColorKind
  84567. * * VertexBuffer.MatricesIndicesKind
  84568. * * VertexBuffer.MatricesIndicesExtraKind
  84569. * * VertexBuffer.MatricesWeightsKind
  84570. * * VertexBuffer.MatricesWeightsExtraKind
  84571. * @param data defines the data source
  84572. * @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
  84573. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84574. * @returns the current mesh
  84575. */
  84576. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84577. /**
  84578. * Sets the mesh indices,
  84579. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84580. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84581. * @param totalVertices Defines the total number of vertices
  84582. * @returns the current mesh
  84583. */
  84584. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84585. /**
  84586. * Gets a boolean indicating if specific vertex data is present
  84587. * @param kind defines the vertex data kind to use
  84588. * @returns true is data kind is present
  84589. */
  84590. isVerticesDataPresent(kind: string): boolean;
  84591. /**
  84592. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84593. * @returns a BoundingInfo
  84594. */
  84595. getBoundingInfo(): BoundingInfo;
  84596. /**
  84597. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84598. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84599. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84600. * @returns the current mesh
  84601. */
  84602. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84603. /**
  84604. * Overwrite the current bounding info
  84605. * @param boundingInfo defines the new bounding info
  84606. * @returns the current mesh
  84607. */
  84608. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84609. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84610. readonly useBones: boolean;
  84611. /** @hidden */
  84612. _preActivate(): void;
  84613. /** @hidden */
  84614. _preActivateForIntermediateRendering(renderId: number): void;
  84615. /** @hidden */
  84616. _activate(renderId: number): boolean;
  84617. /** @hidden */
  84618. _postActivate(): void;
  84619. /** @hidden */
  84620. _freeze(): void;
  84621. /** @hidden */
  84622. _unFreeze(): void;
  84623. /**
  84624. * Gets the current world matrix
  84625. * @returns a Matrix
  84626. */
  84627. getWorldMatrix(): Matrix;
  84628. /** @hidden */
  84629. _getWorldMatrixDeterminant(): number;
  84630. /**
  84631. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84632. */
  84633. readonly isAnInstance: boolean;
  84634. /**
  84635. * Perform relative position change from the point of view of behind the front of the mesh.
  84636. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84637. * Supports definition of mesh facing forward or backward
  84638. * @param amountRight defines the distance on the right axis
  84639. * @param amountUp defines the distance on the up axis
  84640. * @param amountForward defines the distance on the forward axis
  84641. * @returns the current mesh
  84642. */
  84643. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84644. /**
  84645. * Calculate relative position change from the point of view of behind the front of the mesh.
  84646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84647. * Supports definition of mesh facing forward or backward
  84648. * @param amountRight defines the distance on the right axis
  84649. * @param amountUp defines the distance on the up axis
  84650. * @param amountForward defines the distance on the forward axis
  84651. * @returns the new displacement vector
  84652. */
  84653. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84654. /**
  84655. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84656. * Supports definition of mesh facing forward or backward
  84657. * @param flipBack defines the flip
  84658. * @param twirlClockwise defines the twirl
  84659. * @param tiltRight defines the tilt
  84660. * @returns the current mesh
  84661. */
  84662. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84663. /**
  84664. * Calculate 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 new rotation vector
  84670. */
  84671. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84672. /**
  84673. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84674. * This means the mesh underlying bounding box and sphere are recomputed.
  84675. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84676. * @returns the current mesh
  84677. */
  84678. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84679. /** @hidden */
  84680. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84681. /** @hidden */
  84682. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84683. /** @hidden */
  84684. _updateBoundingInfo(): AbstractMesh;
  84685. /** @hidden */
  84686. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84687. /** @hidden */
  84688. protected _afterComputeWorldMatrix(): void;
  84689. /** @hidden */
  84690. readonly _effectiveMesh: AbstractMesh;
  84691. /**
  84692. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84693. * A mesh is in the frustum if its bounding box intersects the frustum
  84694. * @param frustumPlanes defines the frustum to test
  84695. * @returns true if the mesh is in the frustum planes
  84696. */
  84697. isInFrustum(frustumPlanes: Plane[]): boolean;
  84698. /**
  84699. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84700. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84701. * @param frustumPlanes defines the frustum to test
  84702. * @returns true if the mesh is completely in the frustum planes
  84703. */
  84704. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84705. /**
  84706. * True if the mesh intersects another mesh or a SolidParticle object
  84707. * @param mesh defines a target mesh or SolidParticle to test
  84708. * @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)
  84709. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84710. * @returns true if there is an intersection
  84711. */
  84712. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84713. /**
  84714. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84715. * @param point defines the point to test
  84716. * @returns true if there is an intersection
  84717. */
  84718. intersectsPoint(point: Vector3): boolean;
  84719. /**
  84720. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84722. */
  84723. checkCollisions: boolean;
  84724. /**
  84725. * Gets Collider object used to compute collisions (not physics)
  84726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84727. */
  84728. readonly collider: Nullable<Collider>;
  84729. /**
  84730. * Move the mesh using collision engine
  84731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84732. * @param displacement defines the requested displacement vector
  84733. * @returns the current mesh
  84734. */
  84735. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84736. private _onCollisionPositionChange;
  84737. /** @hidden */
  84738. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84739. /** @hidden */
  84740. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84741. /** @hidden */
  84742. _checkCollision(collider: Collider): AbstractMesh;
  84743. /** @hidden */
  84744. _generatePointsArray(): boolean;
  84745. /**
  84746. * Checks if the passed Ray intersects with the mesh
  84747. * @param ray defines the ray to use
  84748. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84749. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84750. * @returns the picking info
  84751. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84752. */
  84753. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84754. /**
  84755. * Clones the current mesh
  84756. * @param name defines the mesh name
  84757. * @param newParent defines the new mesh parent
  84758. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84759. * @returns the new mesh
  84760. */
  84761. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84762. /**
  84763. * Disposes all the submeshes of the current meshnp
  84764. * @returns the current mesh
  84765. */
  84766. releaseSubMeshes(): AbstractMesh;
  84767. /**
  84768. * Releases resources associated with this abstract mesh.
  84769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84771. */
  84772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84773. /**
  84774. * Adds the passed mesh as a child to the current mesh
  84775. * @param mesh defines the child mesh
  84776. * @returns the current mesh
  84777. */
  84778. addChild(mesh: AbstractMesh): AbstractMesh;
  84779. /**
  84780. * Removes the passed mesh from the current mesh children list
  84781. * @param mesh defines the child mesh
  84782. * @returns the current mesh
  84783. */
  84784. removeChild(mesh: AbstractMesh): AbstractMesh;
  84785. /** @hidden */
  84786. private _initFacetData;
  84787. /**
  84788. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84789. * This method can be called within the render loop.
  84790. * 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
  84791. * @returns the current mesh
  84792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84793. */
  84794. updateFacetData(): AbstractMesh;
  84795. /**
  84796. * Returns the facetLocalNormals array.
  84797. * The normals are expressed in the mesh local spac
  84798. * @returns an array of Vector3
  84799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84800. */
  84801. getFacetLocalNormals(): Vector3[];
  84802. /**
  84803. * Returns the facetLocalPositions array.
  84804. * The facet positions are expressed in the mesh local space
  84805. * @returns an array of Vector3
  84806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84807. */
  84808. getFacetLocalPositions(): Vector3[];
  84809. /**
  84810. * Returns the facetLocalPartioning array
  84811. * @returns an array of array of numbers
  84812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84813. */
  84814. getFacetLocalPartitioning(): number[][];
  84815. /**
  84816. * Returns the i-th facet position in the world system.
  84817. * This method allocates a new Vector3 per call
  84818. * @param i defines the facet index
  84819. * @returns a new Vector3
  84820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84821. */
  84822. getFacetPosition(i: number): Vector3;
  84823. /**
  84824. * Sets the reference Vector3 with the i-th facet position in the world system
  84825. * @param i defines the facet index
  84826. * @param ref defines the target vector
  84827. * @returns the current mesh
  84828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84829. */
  84830. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84831. /**
  84832. * Returns the i-th facet normal in the world system.
  84833. * This method allocates a new Vector3 per call
  84834. * @param i defines the facet index
  84835. * @returns a new Vector3
  84836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84837. */
  84838. getFacetNormal(i: number): Vector3;
  84839. /**
  84840. * Sets the reference Vector3 with the i-th facet normal in the world system
  84841. * @param i defines the facet index
  84842. * @param ref defines the target vector
  84843. * @returns the current mesh
  84844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84845. */
  84846. getFacetNormalToRef(i: number, ref: Vector3): this;
  84847. /**
  84848. * 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)
  84849. * @param x defines x coordinate
  84850. * @param y defines y coordinate
  84851. * @param z defines z coordinate
  84852. * @returns the array of facet indexes
  84853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84854. */
  84855. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84856. /**
  84857. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84858. * @param projected sets as the (x,y,z) world projection on the facet
  84859. * @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
  84860. * @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
  84861. * @param x defines x coordinate
  84862. * @param y defines y coordinate
  84863. * @param z defines z coordinate
  84864. * @returns the face index if found (or null instead)
  84865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84866. */
  84867. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84868. /**
  84869. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84870. * @param projected sets as the (x,y,z) local projection on the facet
  84871. * @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
  84872. * @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
  84873. * @param x defines x coordinate
  84874. * @param y defines y coordinate
  84875. * @param z defines z coordinate
  84876. * @returns the face index if found (or null instead)
  84877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84878. */
  84879. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84880. /**
  84881. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84882. * @returns the parameters
  84883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84884. */
  84885. getFacetDataParameters(): any;
  84886. /**
  84887. * Disables the feature FacetData and frees the related memory
  84888. * @returns the current mesh
  84889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84890. */
  84891. disableFacetData(): AbstractMesh;
  84892. /**
  84893. * Updates the AbstractMesh indices array
  84894. * @param indices defines the data source
  84895. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84896. * @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)
  84897. * @returns the current mesh
  84898. */
  84899. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84900. /**
  84901. * Creates new normals data for the mesh
  84902. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84903. * @returns the current mesh
  84904. */
  84905. createNormals(updatable: boolean): AbstractMesh;
  84906. /**
  84907. * Align the mesh with a normal
  84908. * @param normal defines the normal to use
  84909. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84910. * @returns the current mesh
  84911. */
  84912. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84913. /** @hidden */
  84914. _checkOcclusionQuery(): boolean;
  84915. }
  84916. }
  84917. declare module BABYLON {
  84918. /**
  84919. * Interface used to define ActionEvent
  84920. */
  84921. export interface IActionEvent {
  84922. /** The mesh or sprite that triggered the action */
  84923. source: any;
  84924. /** The X mouse cursor position at the time of the event */
  84925. pointerX: number;
  84926. /** The Y mouse cursor position at the time of the event */
  84927. pointerY: number;
  84928. /** The mesh that is currently pointed at (can be null) */
  84929. meshUnderPointer: Nullable<AbstractMesh>;
  84930. /** the original (browser) event that triggered the ActionEvent */
  84931. sourceEvent?: any;
  84932. /** additional data for the event */
  84933. additionalData?: any;
  84934. }
  84935. /**
  84936. * ActionEvent is the event being sent when an action is triggered.
  84937. */
  84938. export class ActionEvent implements IActionEvent {
  84939. /** The mesh or sprite that triggered the action */
  84940. source: any;
  84941. /** The X mouse cursor position at the time of the event */
  84942. pointerX: number;
  84943. /** The Y mouse cursor position at the time of the event */
  84944. pointerY: number;
  84945. /** The mesh that is currently pointed at (can be null) */
  84946. meshUnderPointer: Nullable<AbstractMesh>;
  84947. /** the original (browser) event that triggered the ActionEvent */
  84948. sourceEvent?: any;
  84949. /** additional data for the event */
  84950. additionalData?: any;
  84951. /**
  84952. * Creates a new ActionEvent
  84953. * @param source The mesh or sprite that triggered the action
  84954. * @param pointerX The X mouse cursor position at the time of the event
  84955. * @param pointerY The Y mouse cursor position at the time of the event
  84956. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84957. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84958. * @param additionalData additional data for the event
  84959. */
  84960. constructor(
  84961. /** The mesh or sprite that triggered the action */
  84962. source: any,
  84963. /** The X mouse cursor position at the time of the event */
  84964. pointerX: number,
  84965. /** The Y mouse cursor position at the time of the event */
  84966. pointerY: number,
  84967. /** The mesh that is currently pointed at (can be null) */
  84968. meshUnderPointer: Nullable<AbstractMesh>,
  84969. /** the original (browser) event that triggered the ActionEvent */
  84970. sourceEvent?: any,
  84971. /** additional data for the event */
  84972. additionalData?: any);
  84973. /**
  84974. * Helper function to auto-create an ActionEvent from a source mesh.
  84975. * @param source The source mesh that triggered the event
  84976. * @param evt The original (browser) event
  84977. * @param additionalData additional data for the event
  84978. * @returns the new ActionEvent
  84979. */
  84980. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84981. /**
  84982. * Helper function to auto-create an ActionEvent from a source sprite
  84983. * @param source The source sprite that triggered the event
  84984. * @param scene Scene associated with the sprite
  84985. * @param evt The original (browser) event
  84986. * @param additionalData additional data for the event
  84987. * @returns the new ActionEvent
  84988. */
  84989. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84990. /**
  84991. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84992. * @param scene the scene where the event occurred
  84993. * @param evt The original (browser) event
  84994. * @returns the new ActionEvent
  84995. */
  84996. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84997. /**
  84998. * Helper function to auto-create an ActionEvent from a primitive
  84999. * @param prim defines the target primitive
  85000. * @param pointerPos defines the pointer position
  85001. * @param evt The original (browser) event
  85002. * @param additionalData additional data for the event
  85003. * @returns the new ActionEvent
  85004. */
  85005. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85006. }
  85007. }
  85008. declare module BABYLON {
  85009. /**
  85010. * Abstract class used to decouple action Manager from scene and meshes.
  85011. * Do not instantiate.
  85012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85013. */
  85014. export abstract class AbstractActionManager implements IDisposable {
  85015. /** Gets the list of active triggers */
  85016. static Triggers: {
  85017. [key: string]: number;
  85018. };
  85019. /** Gets the cursor to use when hovering items */
  85020. hoverCursor: string;
  85021. /** Gets the list of actions */
  85022. actions: IAction[];
  85023. /**
  85024. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85025. */
  85026. isRecursive: boolean;
  85027. /**
  85028. * Releases all associated resources
  85029. */
  85030. abstract dispose(): void;
  85031. /**
  85032. * Does this action manager has pointer triggers
  85033. */
  85034. abstract readonly hasPointerTriggers: boolean;
  85035. /**
  85036. * Does this action manager has pick triggers
  85037. */
  85038. abstract readonly hasPickTriggers: boolean;
  85039. /**
  85040. * Process a specific trigger
  85041. * @param trigger defines the trigger to process
  85042. * @param evt defines the event details to be processed
  85043. */
  85044. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85045. /**
  85046. * Does this action manager handles actions of any of the given triggers
  85047. * @param triggers defines the triggers to be tested
  85048. * @return a boolean indicating whether one (or more) of the triggers is handled
  85049. */
  85050. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85051. /**
  85052. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85053. * speed.
  85054. * @param triggerA defines the trigger to be tested
  85055. * @param triggerB defines the trigger to be tested
  85056. * @return a boolean indicating whether one (or more) of the triggers is handled
  85057. */
  85058. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85059. /**
  85060. * Does this action manager handles actions of a given trigger
  85061. * @param trigger defines the trigger to be tested
  85062. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85063. * @return whether the trigger is handled
  85064. */
  85065. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85066. /**
  85067. * Serialize this manager to a JSON object
  85068. * @param name defines the property name to store this manager
  85069. * @returns a JSON representation of this manager
  85070. */
  85071. abstract serialize(name: string): any;
  85072. /**
  85073. * Registers an action to this action manager
  85074. * @param action defines the action to be registered
  85075. * @return the action amended (prepared) after registration
  85076. */
  85077. abstract registerAction(action: IAction): Nullable<IAction>;
  85078. /**
  85079. * Unregisters an action to this action manager
  85080. * @param action defines the action to be unregistered
  85081. * @return a boolean indicating whether the action has been unregistered
  85082. */
  85083. abstract unregisterAction(action: IAction): Boolean;
  85084. /**
  85085. * Does exist one action manager with at least one trigger
  85086. **/
  85087. static readonly HasTriggers: boolean;
  85088. /**
  85089. * Does exist one action manager with at least one pick trigger
  85090. **/
  85091. static readonly HasPickTriggers: boolean;
  85092. /**
  85093. * Does exist one action manager that handles actions of a given trigger
  85094. * @param trigger defines the trigger to be tested
  85095. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85096. **/
  85097. static HasSpecificTrigger(trigger: number): boolean;
  85098. }
  85099. }
  85100. declare module BABYLON {
  85101. /**
  85102. * Defines how a node can be built from a string name.
  85103. */
  85104. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85105. /**
  85106. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85107. */
  85108. export class Node implements IBehaviorAware<Node> {
  85109. /** @hidden */
  85110. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85111. private static _NodeConstructors;
  85112. /**
  85113. * Add a new node constructor
  85114. * @param type defines the type name of the node to construct
  85115. * @param constructorFunc defines the constructor function
  85116. */
  85117. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85118. /**
  85119. * Returns a node constructor based on type name
  85120. * @param type defines the type name
  85121. * @param name defines the new node name
  85122. * @param scene defines the hosting scene
  85123. * @param options defines optional options to transmit to constructors
  85124. * @returns the new constructor or null
  85125. */
  85126. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85127. /**
  85128. * Gets or sets the name of the node
  85129. */
  85130. name: string;
  85131. /**
  85132. * Gets or sets the id of the node
  85133. */
  85134. id: string;
  85135. /**
  85136. * Gets or sets the unique id of the node
  85137. */
  85138. uniqueId: number;
  85139. /**
  85140. * Gets or sets a string used to store user defined state for the node
  85141. */
  85142. state: string;
  85143. /**
  85144. * Gets or sets an object used to store user defined information for the node
  85145. */
  85146. metadata: any;
  85147. /**
  85148. * For internal use only. Please do not use.
  85149. */
  85150. reservedDataStore: any;
  85151. /**
  85152. * List of inspectable custom properties (used by the Inspector)
  85153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85154. */
  85155. inspectableCustomProperties: IInspectable[];
  85156. /**
  85157. * Gets or sets a boolean used to define if the node must be serialized
  85158. */
  85159. doNotSerialize: boolean;
  85160. /** @hidden */
  85161. _isDisposed: boolean;
  85162. /**
  85163. * Gets a list of Animations associated with the node
  85164. */
  85165. animations: Animation[];
  85166. protected _ranges: {
  85167. [name: string]: Nullable<AnimationRange>;
  85168. };
  85169. /**
  85170. * Callback raised when the node is ready to be used
  85171. */
  85172. onReady: Nullable<(node: Node) => void>;
  85173. private _isEnabled;
  85174. private _isParentEnabled;
  85175. private _isReady;
  85176. /** @hidden */
  85177. _currentRenderId: number;
  85178. private _parentUpdateId;
  85179. /** @hidden */
  85180. _childUpdateId: number;
  85181. /** @hidden */
  85182. _waitingParentId: Nullable<string>;
  85183. /** @hidden */
  85184. _scene: Scene;
  85185. /** @hidden */
  85186. _cache: any;
  85187. private _parentNode;
  85188. private _children;
  85189. /** @hidden */
  85190. _worldMatrix: Matrix;
  85191. /** @hidden */
  85192. _worldMatrixDeterminant: number;
  85193. /** @hidden */
  85194. _worldMatrixDeterminantIsDirty: boolean;
  85195. /** @hidden */
  85196. private _sceneRootNodesIndex;
  85197. /**
  85198. * Gets a boolean indicating if the node has been disposed
  85199. * @returns true if the node was disposed
  85200. */
  85201. isDisposed(): boolean;
  85202. /**
  85203. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85204. * @see https://doc.babylonjs.com/how_to/parenting
  85205. */
  85206. parent: Nullable<Node>;
  85207. private addToSceneRootNodes;
  85208. private removeFromSceneRootNodes;
  85209. private _animationPropertiesOverride;
  85210. /**
  85211. * Gets or sets the animation properties override
  85212. */
  85213. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85214. /**
  85215. * Gets a string idenfifying the name of the class
  85216. * @returns "Node" string
  85217. */
  85218. getClassName(): string;
  85219. /** @hidden */
  85220. readonly _isNode: boolean;
  85221. /**
  85222. * An event triggered when the mesh is disposed
  85223. */
  85224. onDisposeObservable: Observable<Node>;
  85225. private _onDisposeObserver;
  85226. /**
  85227. * Sets a callback that will be raised when the node will be disposed
  85228. */
  85229. onDispose: () => void;
  85230. /**
  85231. * Creates a new Node
  85232. * @param name the name and id to be given to this node
  85233. * @param scene the scene this node will be added to
  85234. * @param addToRootNodes the node will be added to scene.rootNodes
  85235. */
  85236. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85237. /**
  85238. * Gets the scene of the node
  85239. * @returns a scene
  85240. */
  85241. getScene(): Scene;
  85242. /**
  85243. * Gets the engine of the node
  85244. * @returns a Engine
  85245. */
  85246. getEngine(): Engine;
  85247. private _behaviors;
  85248. /**
  85249. * Attach a behavior to the node
  85250. * @see http://doc.babylonjs.com/features/behaviour
  85251. * @param behavior defines the behavior to attach
  85252. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85253. * @returns the current Node
  85254. */
  85255. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85256. /**
  85257. * Remove an attached behavior
  85258. * @see http://doc.babylonjs.com/features/behaviour
  85259. * @param behavior defines the behavior to attach
  85260. * @returns the current Node
  85261. */
  85262. removeBehavior(behavior: Behavior<Node>): Node;
  85263. /**
  85264. * Gets the list of attached behaviors
  85265. * @see http://doc.babylonjs.com/features/behaviour
  85266. */
  85267. readonly behaviors: Behavior<Node>[];
  85268. /**
  85269. * Gets an attached behavior by name
  85270. * @param name defines the name of the behavior to look for
  85271. * @see http://doc.babylonjs.com/features/behaviour
  85272. * @returns null if behavior was not found else the requested behavior
  85273. */
  85274. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85275. /**
  85276. * Returns the latest update of the World matrix
  85277. * @returns a Matrix
  85278. */
  85279. getWorldMatrix(): Matrix;
  85280. /** @hidden */
  85281. _getWorldMatrixDeterminant(): number;
  85282. /**
  85283. * Returns directly the latest state of the mesh World matrix.
  85284. * A Matrix is returned.
  85285. */
  85286. readonly worldMatrixFromCache: Matrix;
  85287. /** @hidden */
  85288. _initCache(): void;
  85289. /** @hidden */
  85290. updateCache(force?: boolean): void;
  85291. /** @hidden */
  85292. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85293. /** @hidden */
  85294. _updateCache(ignoreParentClass?: boolean): void;
  85295. /** @hidden */
  85296. _isSynchronized(): boolean;
  85297. /** @hidden */
  85298. _markSyncedWithParent(): void;
  85299. /** @hidden */
  85300. isSynchronizedWithParent(): boolean;
  85301. /** @hidden */
  85302. isSynchronized(): boolean;
  85303. /**
  85304. * Is this node ready to be used/rendered
  85305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85306. * @return true if the node is ready
  85307. */
  85308. isReady(completeCheck?: boolean): boolean;
  85309. /**
  85310. * Is this node enabled?
  85311. * 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
  85312. * @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
  85313. * @return whether this node (and its parent) is enabled
  85314. */
  85315. isEnabled(checkAncestors?: boolean): boolean;
  85316. /** @hidden */
  85317. protected _syncParentEnabledState(): void;
  85318. /**
  85319. * Set the enabled state of this node
  85320. * @param value defines the new enabled state
  85321. */
  85322. setEnabled(value: boolean): void;
  85323. /**
  85324. * Is this node a descendant of the given node?
  85325. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85326. * @param ancestor defines the parent node to inspect
  85327. * @returns a boolean indicating if this node is a descendant of the given node
  85328. */
  85329. isDescendantOf(ancestor: Node): boolean;
  85330. /** @hidden */
  85331. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85332. /**
  85333. * Will return all nodes that have this node as ascendant
  85334. * @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
  85335. * @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
  85336. * @return all children nodes of all types
  85337. */
  85338. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85339. /**
  85340. * Get all child-meshes of this node
  85341. * @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)
  85342. * @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
  85343. * @returns an array of AbstractMesh
  85344. */
  85345. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85346. /**
  85347. * Get all direct children of this node
  85348. * @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
  85349. * @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)
  85350. * @returns an array of Node
  85351. */
  85352. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85353. /** @hidden */
  85354. _setReady(state: boolean): void;
  85355. /**
  85356. * Get an animation by name
  85357. * @param name defines the name of the animation to look for
  85358. * @returns null if not found else the requested animation
  85359. */
  85360. getAnimationByName(name: string): Nullable<Animation>;
  85361. /**
  85362. * Creates an animation range for this node
  85363. * @param name defines the name of the range
  85364. * @param from defines the starting key
  85365. * @param to defines the end key
  85366. */
  85367. createAnimationRange(name: string, from: number, to: number): void;
  85368. /**
  85369. * Delete a specific animation range
  85370. * @param name defines the name of the range to delete
  85371. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85372. */
  85373. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85374. /**
  85375. * Get an animation range by name
  85376. * @param name defines the name of the animation range to look for
  85377. * @returns null if not found else the requested animation range
  85378. */
  85379. getAnimationRange(name: string): Nullable<AnimationRange>;
  85380. /**
  85381. * Gets the list of all animation ranges defined on this node
  85382. * @returns an array
  85383. */
  85384. getAnimationRanges(): Nullable<AnimationRange>[];
  85385. /**
  85386. * Will start the animation sequence
  85387. * @param name defines the range frames for animation sequence
  85388. * @param loop defines if the animation should loop (false by default)
  85389. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85390. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85391. * @returns the object created for this animation. If range does not exist, it will return null
  85392. */
  85393. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85394. /**
  85395. * Serialize animation ranges into a JSON compatible object
  85396. * @returns serialization object
  85397. */
  85398. serializeAnimationRanges(): any;
  85399. /**
  85400. * Computes the world matrix of the node
  85401. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85402. * @returns the world matrix
  85403. */
  85404. computeWorldMatrix(force?: boolean): Matrix;
  85405. /**
  85406. * Releases resources associated with this node.
  85407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85409. */
  85410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85411. /**
  85412. * Parse animation range data from a serialization object and store them into a given node
  85413. * @param node defines where to store the animation ranges
  85414. * @param parsedNode defines the serialization object to read data from
  85415. * @param scene defines the hosting scene
  85416. */
  85417. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85418. /**
  85419. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85420. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85421. * @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
  85422. * @returns the new bounding vectors
  85423. */
  85424. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85425. min: Vector3;
  85426. max: Vector3;
  85427. };
  85428. }
  85429. }
  85430. declare module BABYLON {
  85431. /**
  85432. * @hidden
  85433. */
  85434. export class _IAnimationState {
  85435. key: number;
  85436. repeatCount: number;
  85437. workValue?: any;
  85438. loopMode?: number;
  85439. offsetValue?: any;
  85440. highLimitValue?: any;
  85441. }
  85442. /**
  85443. * Class used to store any kind of animation
  85444. */
  85445. export class Animation {
  85446. /**Name of the animation */
  85447. name: string;
  85448. /**Property to animate */
  85449. targetProperty: string;
  85450. /**The frames per second of the animation */
  85451. framePerSecond: number;
  85452. /**The data type of the animation */
  85453. dataType: number;
  85454. /**The loop mode of the animation */
  85455. loopMode?: number | undefined;
  85456. /**Specifies if blending should be enabled */
  85457. enableBlending?: boolean | undefined;
  85458. /**
  85459. * Use matrix interpolation instead of using direct key value when animating matrices
  85460. */
  85461. static AllowMatricesInterpolation: boolean;
  85462. /**
  85463. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85464. */
  85465. static AllowMatrixDecomposeForInterpolation: boolean;
  85466. /**
  85467. * Stores the key frames of the animation
  85468. */
  85469. private _keys;
  85470. /**
  85471. * Stores the easing function of the animation
  85472. */
  85473. private _easingFunction;
  85474. /**
  85475. * @hidden Internal use only
  85476. */
  85477. _runtimeAnimations: RuntimeAnimation[];
  85478. /**
  85479. * The set of event that will be linked to this animation
  85480. */
  85481. private _events;
  85482. /**
  85483. * Stores an array of target property paths
  85484. */
  85485. targetPropertyPath: string[];
  85486. /**
  85487. * Stores the blending speed of the animation
  85488. */
  85489. blendingSpeed: number;
  85490. /**
  85491. * Stores the animation ranges for the animation
  85492. */
  85493. private _ranges;
  85494. /**
  85495. * @hidden Internal use
  85496. */
  85497. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85498. /**
  85499. * Sets up an animation
  85500. * @param property The property to animate
  85501. * @param animationType The animation type to apply
  85502. * @param framePerSecond The frames per second of the animation
  85503. * @param easingFunction The easing function used in the animation
  85504. * @returns The created animation
  85505. */
  85506. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85507. /**
  85508. * Create and start an animation on a node
  85509. * @param name defines the name of the global animation that will be run on all nodes
  85510. * @param node defines the root node where the animation will take place
  85511. * @param targetProperty defines property to animate
  85512. * @param framePerSecond defines the number of frame per second yo use
  85513. * @param totalFrame defines the number of frames in total
  85514. * @param from defines the initial value
  85515. * @param to defines the final value
  85516. * @param loopMode defines which loop mode you want to use (off by default)
  85517. * @param easingFunction defines the easing function to use (linear by default)
  85518. * @param onAnimationEnd defines the callback to call when animation end
  85519. * @returns the animatable created for this animation
  85520. */
  85521. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85522. /**
  85523. * Create and start an animation on a node and its descendants
  85524. * @param name defines the name of the global animation that will be run on all nodes
  85525. * @param node defines the root node where the animation will take place
  85526. * @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
  85527. * @param targetProperty defines property to animate
  85528. * @param framePerSecond defines the number of frame per second to use
  85529. * @param totalFrame defines the number of frames in total
  85530. * @param from defines the initial value
  85531. * @param to defines the final value
  85532. * @param loopMode defines which loop mode you want to use (off by default)
  85533. * @param easingFunction defines the easing function to use (linear by default)
  85534. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85535. * @returns the list of animatables created for all nodes
  85536. * @example https://www.babylonjs-playground.com/#MH0VLI
  85537. */
  85538. 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[]>;
  85539. /**
  85540. * Creates a new animation, merges it with the existing animations and starts it
  85541. * @param name Name of the animation
  85542. * @param node Node which contains the scene that begins the animations
  85543. * @param targetProperty Specifies which property to animate
  85544. * @param framePerSecond The frames per second of the animation
  85545. * @param totalFrame The total number of frames
  85546. * @param from The frame at the beginning of the animation
  85547. * @param to The frame at the end of the animation
  85548. * @param loopMode Specifies the loop mode of the animation
  85549. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85550. * @param onAnimationEnd Callback to run once the animation is complete
  85551. * @returns Nullable animation
  85552. */
  85553. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85554. /**
  85555. * Transition property of an host to the target Value
  85556. * @param property The property to transition
  85557. * @param targetValue The target Value of the property
  85558. * @param host The object where the property to animate belongs
  85559. * @param scene Scene used to run the animation
  85560. * @param frameRate Framerate (in frame/s) to use
  85561. * @param transition The transition type we want to use
  85562. * @param duration The duration of the animation, in milliseconds
  85563. * @param onAnimationEnd Callback trigger at the end of the animation
  85564. * @returns Nullable animation
  85565. */
  85566. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85567. /**
  85568. * Return the array of runtime animations currently using this animation
  85569. */
  85570. readonly runtimeAnimations: RuntimeAnimation[];
  85571. /**
  85572. * Specifies if any of the runtime animations are currently running
  85573. */
  85574. readonly hasRunningRuntimeAnimations: boolean;
  85575. /**
  85576. * Initializes the animation
  85577. * @param name Name of the animation
  85578. * @param targetProperty Property to animate
  85579. * @param framePerSecond The frames per second of the animation
  85580. * @param dataType The data type of the animation
  85581. * @param loopMode The loop mode of the animation
  85582. * @param enableBlending Specifies if blending should be enabled
  85583. */
  85584. constructor(
  85585. /**Name of the animation */
  85586. name: string,
  85587. /**Property to animate */
  85588. targetProperty: string,
  85589. /**The frames per second of the animation */
  85590. framePerSecond: number,
  85591. /**The data type of the animation */
  85592. dataType: number,
  85593. /**The loop mode of the animation */
  85594. loopMode?: number | undefined,
  85595. /**Specifies if blending should be enabled */
  85596. enableBlending?: boolean | undefined);
  85597. /**
  85598. * Converts the animation to a string
  85599. * @param fullDetails support for multiple levels of logging within scene loading
  85600. * @returns String form of the animation
  85601. */
  85602. toString(fullDetails?: boolean): string;
  85603. /**
  85604. * Add an event to this animation
  85605. * @param event Event to add
  85606. */
  85607. addEvent(event: AnimationEvent): void;
  85608. /**
  85609. * Remove all events found at the given frame
  85610. * @param frame The frame to remove events from
  85611. */
  85612. removeEvents(frame: number): void;
  85613. /**
  85614. * Retrieves all the events from the animation
  85615. * @returns Events from the animation
  85616. */
  85617. getEvents(): AnimationEvent[];
  85618. /**
  85619. * Creates an animation range
  85620. * @param name Name of the animation range
  85621. * @param from Starting frame of the animation range
  85622. * @param to Ending frame of the animation
  85623. */
  85624. createRange(name: string, from: number, to: number): void;
  85625. /**
  85626. * Deletes an animation range by name
  85627. * @param name Name of the animation range to delete
  85628. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85629. */
  85630. deleteRange(name: string, deleteFrames?: boolean): void;
  85631. /**
  85632. * Gets the animation range by name, or null if not defined
  85633. * @param name Name of the animation range
  85634. * @returns Nullable animation range
  85635. */
  85636. getRange(name: string): Nullable<AnimationRange>;
  85637. /**
  85638. * Gets the key frames from the animation
  85639. * @returns The key frames of the animation
  85640. */
  85641. getKeys(): Array<IAnimationKey>;
  85642. /**
  85643. * Gets the highest frame rate of the animation
  85644. * @returns Highest frame rate of the animation
  85645. */
  85646. getHighestFrame(): number;
  85647. /**
  85648. * Gets the easing function of the animation
  85649. * @returns Easing function of the animation
  85650. */
  85651. getEasingFunction(): IEasingFunction;
  85652. /**
  85653. * Sets the easing function of the animation
  85654. * @param easingFunction A custom mathematical formula for animation
  85655. */
  85656. setEasingFunction(easingFunction: EasingFunction): void;
  85657. /**
  85658. * Interpolates a scalar linearly
  85659. * @param startValue Start value of the animation curve
  85660. * @param endValue End value of the animation curve
  85661. * @param gradient Scalar amount to interpolate
  85662. * @returns Interpolated scalar value
  85663. */
  85664. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85665. /**
  85666. * Interpolates a scalar cubically
  85667. * @param startValue Start value of the animation curve
  85668. * @param outTangent End tangent of the animation
  85669. * @param endValue End value of the animation curve
  85670. * @param inTangent Start tangent of the animation curve
  85671. * @param gradient Scalar amount to interpolate
  85672. * @returns Interpolated scalar value
  85673. */
  85674. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85675. /**
  85676. * Interpolates a quaternion using a spherical linear interpolation
  85677. * @param startValue Start value of the animation curve
  85678. * @param endValue End value of the animation curve
  85679. * @param gradient Scalar amount to interpolate
  85680. * @returns Interpolated quaternion value
  85681. */
  85682. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85683. /**
  85684. * Interpolates a quaternion cubically
  85685. * @param startValue Start value of the animation curve
  85686. * @param outTangent End tangent of the animation curve
  85687. * @param endValue End value of the animation curve
  85688. * @param inTangent Start tangent of the animation curve
  85689. * @param gradient Scalar amount to interpolate
  85690. * @returns Interpolated quaternion value
  85691. */
  85692. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85693. /**
  85694. * Interpolates a Vector3 linearl
  85695. * @param startValue Start value of the animation curve
  85696. * @param endValue End value of the animation curve
  85697. * @param gradient Scalar amount to interpolate
  85698. * @returns Interpolated scalar value
  85699. */
  85700. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85701. /**
  85702. * Interpolates a Vector3 cubically
  85703. * @param startValue Start value of the animation curve
  85704. * @param outTangent End tangent of the animation
  85705. * @param endValue End value of the animation curve
  85706. * @param inTangent Start tangent of the animation curve
  85707. * @param gradient Scalar amount to interpolate
  85708. * @returns InterpolatedVector3 value
  85709. */
  85710. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85711. /**
  85712. * Interpolates a Vector2 linearly
  85713. * @param startValue Start value of the animation curve
  85714. * @param endValue End value of the animation curve
  85715. * @param gradient Scalar amount to interpolate
  85716. * @returns Interpolated Vector2 value
  85717. */
  85718. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85719. /**
  85720. * Interpolates a Vector2 cubically
  85721. * @param startValue Start value of the animation curve
  85722. * @param outTangent End tangent of the animation
  85723. * @param endValue End value of the animation curve
  85724. * @param inTangent Start tangent of the animation curve
  85725. * @param gradient Scalar amount to interpolate
  85726. * @returns Interpolated Vector2 value
  85727. */
  85728. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85729. /**
  85730. * Interpolates a size linearly
  85731. * @param startValue Start value of the animation curve
  85732. * @param endValue End value of the animation curve
  85733. * @param gradient Scalar amount to interpolate
  85734. * @returns Interpolated Size value
  85735. */
  85736. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85737. /**
  85738. * Interpolates a Color3 linearly
  85739. * @param startValue Start value of the animation curve
  85740. * @param endValue End value of the animation curve
  85741. * @param gradient Scalar amount to interpolate
  85742. * @returns Interpolated Color3 value
  85743. */
  85744. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85745. /**
  85746. * @hidden Internal use only
  85747. */
  85748. _getKeyValue(value: any): any;
  85749. /**
  85750. * @hidden Internal use only
  85751. */
  85752. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85753. /**
  85754. * Defines the function to use to interpolate matrices
  85755. * @param startValue defines the start matrix
  85756. * @param endValue defines the end matrix
  85757. * @param gradient defines the gradient between both matrices
  85758. * @param result defines an optional target matrix where to store the interpolation
  85759. * @returns the interpolated matrix
  85760. */
  85761. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85762. /**
  85763. * Makes a copy of the animation
  85764. * @returns Cloned animation
  85765. */
  85766. clone(): Animation;
  85767. /**
  85768. * Sets the key frames of the animation
  85769. * @param values The animation key frames to set
  85770. */
  85771. setKeys(values: Array<IAnimationKey>): void;
  85772. /**
  85773. * Serializes the animation to an object
  85774. * @returns Serialized object
  85775. */
  85776. serialize(): any;
  85777. /**
  85778. * Float animation type
  85779. */
  85780. private static _ANIMATIONTYPE_FLOAT;
  85781. /**
  85782. * Vector3 animation type
  85783. */
  85784. private static _ANIMATIONTYPE_VECTOR3;
  85785. /**
  85786. * Quaternion animation type
  85787. */
  85788. private static _ANIMATIONTYPE_QUATERNION;
  85789. /**
  85790. * Matrix animation type
  85791. */
  85792. private static _ANIMATIONTYPE_MATRIX;
  85793. /**
  85794. * Color3 animation type
  85795. */
  85796. private static _ANIMATIONTYPE_COLOR3;
  85797. /**
  85798. * Vector2 animation type
  85799. */
  85800. private static _ANIMATIONTYPE_VECTOR2;
  85801. /**
  85802. * Size animation type
  85803. */
  85804. private static _ANIMATIONTYPE_SIZE;
  85805. /**
  85806. * Relative Loop Mode
  85807. */
  85808. private static _ANIMATIONLOOPMODE_RELATIVE;
  85809. /**
  85810. * Cycle Loop Mode
  85811. */
  85812. private static _ANIMATIONLOOPMODE_CYCLE;
  85813. /**
  85814. * Constant Loop Mode
  85815. */
  85816. private static _ANIMATIONLOOPMODE_CONSTANT;
  85817. /**
  85818. * Get the float animation type
  85819. */
  85820. static readonly ANIMATIONTYPE_FLOAT: number;
  85821. /**
  85822. * Get the Vector3 animation type
  85823. */
  85824. static readonly ANIMATIONTYPE_VECTOR3: number;
  85825. /**
  85826. * Get the Vector2 animation type
  85827. */
  85828. static readonly ANIMATIONTYPE_VECTOR2: number;
  85829. /**
  85830. * Get the Size animation type
  85831. */
  85832. static readonly ANIMATIONTYPE_SIZE: number;
  85833. /**
  85834. * Get the Quaternion animation type
  85835. */
  85836. static readonly ANIMATIONTYPE_QUATERNION: number;
  85837. /**
  85838. * Get the Matrix animation type
  85839. */
  85840. static readonly ANIMATIONTYPE_MATRIX: number;
  85841. /**
  85842. * Get the Color3 animation type
  85843. */
  85844. static readonly ANIMATIONTYPE_COLOR3: number;
  85845. /**
  85846. * Get the Relative Loop Mode
  85847. */
  85848. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85849. /**
  85850. * Get the Cycle Loop Mode
  85851. */
  85852. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85853. /**
  85854. * Get the Constant Loop Mode
  85855. */
  85856. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85857. /** @hidden */
  85858. static _UniversalLerp(left: any, right: any, amount: number): any;
  85859. /**
  85860. * Parses an animation object and creates an animation
  85861. * @param parsedAnimation Parsed animation object
  85862. * @returns Animation object
  85863. */
  85864. static Parse(parsedAnimation: any): Animation;
  85865. /**
  85866. * Appends the serialized animations from the source animations
  85867. * @param source Source containing the animations
  85868. * @param destination Target to store the animations
  85869. */
  85870. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85871. }
  85872. }
  85873. declare module BABYLON {
  85874. /**
  85875. * Base class of all the textures in babylon.
  85876. * It groups all the common properties the materials, post process, lights... might need
  85877. * in order to make a correct use of the texture.
  85878. */
  85879. export class BaseTexture implements IAnimatable {
  85880. /**
  85881. * Default anisotropic filtering level for the application.
  85882. * It is set to 4 as a good tradeoff between perf and quality.
  85883. */
  85884. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85885. /**
  85886. * Gets or sets the unique id of the texture
  85887. */
  85888. uniqueId: number;
  85889. /**
  85890. * Define the name of the texture.
  85891. */
  85892. name: string;
  85893. /**
  85894. * Gets or sets an object used to store user defined information.
  85895. */
  85896. metadata: any;
  85897. /**
  85898. * For internal use only. Please do not use.
  85899. */
  85900. reservedDataStore: any;
  85901. private _hasAlpha;
  85902. /**
  85903. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85904. */
  85905. hasAlpha: boolean;
  85906. /**
  85907. * Defines if the alpha value should be determined via the rgb values.
  85908. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85909. */
  85910. getAlphaFromRGB: boolean;
  85911. /**
  85912. * Intensity or strength of the texture.
  85913. * It is commonly used by materials to fine tune the intensity of the texture
  85914. */
  85915. level: number;
  85916. /**
  85917. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85918. * This is part of the texture as textures usually maps to one uv set.
  85919. */
  85920. coordinatesIndex: number;
  85921. private _coordinatesMode;
  85922. /**
  85923. * How a texture is mapped.
  85924. *
  85925. * | Value | Type | Description |
  85926. * | ----- | ----------------------------------- | ----------- |
  85927. * | 0 | EXPLICIT_MODE | |
  85928. * | 1 | SPHERICAL_MODE | |
  85929. * | 2 | PLANAR_MODE | |
  85930. * | 3 | CUBIC_MODE | |
  85931. * | 4 | PROJECTION_MODE | |
  85932. * | 5 | SKYBOX_MODE | |
  85933. * | 6 | INVCUBIC_MODE | |
  85934. * | 7 | EQUIRECTANGULAR_MODE | |
  85935. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85936. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85937. */
  85938. coordinatesMode: number;
  85939. /**
  85940. * | Value | Type | Description |
  85941. * | ----- | ------------------ | ----------- |
  85942. * | 0 | CLAMP_ADDRESSMODE | |
  85943. * | 1 | WRAP_ADDRESSMODE | |
  85944. * | 2 | MIRROR_ADDRESSMODE | |
  85945. */
  85946. wrapU: number;
  85947. /**
  85948. * | Value | Type | Description |
  85949. * | ----- | ------------------ | ----------- |
  85950. * | 0 | CLAMP_ADDRESSMODE | |
  85951. * | 1 | WRAP_ADDRESSMODE | |
  85952. * | 2 | MIRROR_ADDRESSMODE | |
  85953. */
  85954. wrapV: number;
  85955. /**
  85956. * | Value | Type | Description |
  85957. * | ----- | ------------------ | ----------- |
  85958. * | 0 | CLAMP_ADDRESSMODE | |
  85959. * | 1 | WRAP_ADDRESSMODE | |
  85960. * | 2 | MIRROR_ADDRESSMODE | |
  85961. */
  85962. wrapR: number;
  85963. /**
  85964. * With compliant hardware and browser (supporting anisotropic filtering)
  85965. * this defines the level of anisotropic filtering in the texture.
  85966. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85967. */
  85968. anisotropicFilteringLevel: number;
  85969. /**
  85970. * Define if the texture is a cube texture or if false a 2d texture.
  85971. */
  85972. isCube: boolean;
  85973. /**
  85974. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85975. */
  85976. is3D: boolean;
  85977. /**
  85978. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85979. * HDR texture are usually stored in linear space.
  85980. * This only impacts the PBR and Background materials
  85981. */
  85982. gammaSpace: boolean;
  85983. /**
  85984. * Gets whether or not the texture contains RGBD data.
  85985. */
  85986. readonly isRGBD: boolean;
  85987. /**
  85988. * Is Z inverted in the texture (useful in a cube texture).
  85989. */
  85990. invertZ: boolean;
  85991. /**
  85992. * Are mip maps generated for this texture or not.
  85993. */
  85994. readonly noMipmap: boolean;
  85995. /**
  85996. * @hidden
  85997. */
  85998. lodLevelInAlpha: boolean;
  85999. /**
  86000. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86001. */
  86002. lodGenerationOffset: number;
  86003. /**
  86004. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86005. */
  86006. lodGenerationScale: number;
  86007. /**
  86008. * Define if the texture is a render target.
  86009. */
  86010. isRenderTarget: boolean;
  86011. /**
  86012. * Define the unique id of the texture in the scene.
  86013. */
  86014. readonly uid: string;
  86015. /**
  86016. * Return a string representation of the texture.
  86017. * @returns the texture as a string
  86018. */
  86019. toString(): string;
  86020. /**
  86021. * Get the class name of the texture.
  86022. * @returns "BaseTexture"
  86023. */
  86024. getClassName(): string;
  86025. /**
  86026. * Define the list of animation attached to the texture.
  86027. */
  86028. animations: Animation[];
  86029. /**
  86030. * An event triggered when the texture is disposed.
  86031. */
  86032. onDisposeObservable: Observable<BaseTexture>;
  86033. private _onDisposeObserver;
  86034. /**
  86035. * Callback triggered when the texture has been disposed.
  86036. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86037. */
  86038. onDispose: () => void;
  86039. /**
  86040. * Define the current state of the loading sequence when in delayed load mode.
  86041. */
  86042. delayLoadState: number;
  86043. private _scene;
  86044. /** @hidden */
  86045. _texture: Nullable<InternalTexture>;
  86046. private _uid;
  86047. /**
  86048. * Define if the texture is preventinga material to render or not.
  86049. * If not and the texture is not ready, the engine will use a default black texture instead.
  86050. */
  86051. readonly isBlocking: boolean;
  86052. /**
  86053. * Instantiates a new BaseTexture.
  86054. * Base class of all the textures in babylon.
  86055. * It groups all the common properties the materials, post process, lights... might need
  86056. * in order to make a correct use of the texture.
  86057. * @param scene Define the scene the texture blongs to
  86058. */
  86059. constructor(scene: Nullable<Scene>);
  86060. /**
  86061. * Get the scene the texture belongs to.
  86062. * @returns the scene or null if undefined
  86063. */
  86064. getScene(): Nullable<Scene>;
  86065. /**
  86066. * Get the texture transform matrix used to offset tile the texture for istance.
  86067. * @returns the transformation matrix
  86068. */
  86069. getTextureMatrix(): Matrix;
  86070. /**
  86071. * Get the texture reflection matrix used to rotate/transform the reflection.
  86072. * @returns the reflection matrix
  86073. */
  86074. getReflectionTextureMatrix(): Matrix;
  86075. /**
  86076. * Get the underlying lower level texture from Babylon.
  86077. * @returns the insternal texture
  86078. */
  86079. getInternalTexture(): Nullable<InternalTexture>;
  86080. /**
  86081. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86082. * @returns true if ready or not blocking
  86083. */
  86084. isReadyOrNotBlocking(): boolean;
  86085. /**
  86086. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86087. * @returns true if fully ready
  86088. */
  86089. isReady(): boolean;
  86090. private _cachedSize;
  86091. /**
  86092. * Get the size of the texture.
  86093. * @returns the texture size.
  86094. */
  86095. getSize(): ISize;
  86096. /**
  86097. * Get the base size of the texture.
  86098. * It can be different from the size if the texture has been resized for POT for instance
  86099. * @returns the base size
  86100. */
  86101. getBaseSize(): ISize;
  86102. /**
  86103. * Update the sampling mode of the texture.
  86104. * Default is Trilinear mode.
  86105. *
  86106. * | Value | Type | Description |
  86107. * | ----- | ------------------ | ----------- |
  86108. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86109. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86110. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86111. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86112. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86113. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86114. * | 7 | NEAREST_LINEAR | |
  86115. * | 8 | NEAREST_NEAREST | |
  86116. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86117. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86118. * | 11 | LINEAR_LINEAR | |
  86119. * | 12 | LINEAR_NEAREST | |
  86120. *
  86121. * > _mag_: magnification filter (close to the viewer)
  86122. * > _min_: minification filter (far from the viewer)
  86123. * > _mip_: filter used between mip map levels
  86124. *@param samplingMode Define the new sampling mode of the texture
  86125. */
  86126. updateSamplingMode(samplingMode: number): void;
  86127. /**
  86128. * Scales the texture if is `canRescale()`
  86129. * @param ratio the resize factor we want to use to rescale
  86130. */
  86131. scale(ratio: number): void;
  86132. /**
  86133. * Get if the texture can rescale.
  86134. */
  86135. readonly canRescale: boolean;
  86136. /** @hidden */
  86137. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86138. /** @hidden */
  86139. _rebuild(): void;
  86140. /**
  86141. * Triggers the load sequence in delayed load mode.
  86142. */
  86143. delayLoad(): void;
  86144. /**
  86145. * Clones the texture.
  86146. * @returns the cloned texture
  86147. */
  86148. clone(): Nullable<BaseTexture>;
  86149. /**
  86150. * Get the texture underlying type (INT, FLOAT...)
  86151. */
  86152. readonly textureType: number;
  86153. /**
  86154. * Get the texture underlying format (RGB, RGBA...)
  86155. */
  86156. readonly textureFormat: number;
  86157. /**
  86158. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86159. * This will returns an RGBA array buffer containing either in values (0-255) or
  86160. * float values (0-1) depending of the underlying buffer type.
  86161. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86162. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86163. * @param buffer defines a user defined buffer to fill with data (can be null)
  86164. * @returns The Array buffer containing the pixels data.
  86165. */
  86166. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86167. /**
  86168. * Release and destroy the underlying lower level texture aka internalTexture.
  86169. */
  86170. releaseInternalTexture(): void;
  86171. /**
  86172. * Get the polynomial representation of the texture data.
  86173. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86174. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86175. */
  86176. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86177. /** @hidden */
  86178. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86179. /** @hidden */
  86180. readonly _lodTextureMid: Nullable<BaseTexture>;
  86181. /** @hidden */
  86182. readonly _lodTextureLow: Nullable<BaseTexture>;
  86183. /**
  86184. * Dispose the texture and release its associated resources.
  86185. */
  86186. dispose(): void;
  86187. /**
  86188. * Serialize the texture into a JSON representation that can be parsed later on.
  86189. * @returns the JSON representation of the texture
  86190. */
  86191. serialize(): any;
  86192. /**
  86193. * Helper function to be called back once a list of texture contains only ready textures.
  86194. * @param textures Define the list of textures to wait for
  86195. * @param callback Define the callback triggered once the entire list will be ready
  86196. */
  86197. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86198. }
  86199. }
  86200. declare module BABYLON {
  86201. /**
  86202. * Uniform buffer objects.
  86203. *
  86204. * Handles blocks of uniform on the GPU.
  86205. *
  86206. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86207. *
  86208. * For more information, please refer to :
  86209. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86210. */
  86211. export class UniformBuffer {
  86212. private _engine;
  86213. private _buffer;
  86214. private _data;
  86215. private _bufferData;
  86216. private _dynamic?;
  86217. private _uniformLocations;
  86218. private _uniformSizes;
  86219. private _uniformLocationPointer;
  86220. private _needSync;
  86221. private _noUBO;
  86222. private _currentEffect;
  86223. private static _MAX_UNIFORM_SIZE;
  86224. private static _tempBuffer;
  86225. /**
  86226. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86227. * This is dynamic to allow compat with webgl 1 and 2.
  86228. * You will need to pass the name of the uniform as well as the value.
  86229. */
  86230. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86231. /**
  86232. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86233. * This is dynamic to allow compat with webgl 1 and 2.
  86234. * You will need to pass the name of the uniform as well as the value.
  86235. */
  86236. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86237. /**
  86238. * Lambda to Update a single float in a uniform buffer.
  86239. * This is dynamic to allow compat with webgl 1 and 2.
  86240. * You will need to pass the name of the uniform as well as the value.
  86241. */
  86242. updateFloat: (name: string, x: number) => void;
  86243. /**
  86244. * Lambda to Update a vec2 of float in a uniform buffer.
  86245. * This is dynamic to allow compat with webgl 1 and 2.
  86246. * You will need to pass the name of the uniform as well as the value.
  86247. */
  86248. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86249. /**
  86250. * Lambda to Update a vec3 of float in a uniform buffer.
  86251. * This is dynamic to allow compat with webgl 1 and 2.
  86252. * You will need to pass the name of the uniform as well as the value.
  86253. */
  86254. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86255. /**
  86256. * Lambda to Update a vec4 of float in a uniform buffer.
  86257. * This is dynamic to allow compat with webgl 1 and 2.
  86258. * You will need to pass the name of the uniform as well as the value.
  86259. */
  86260. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86261. /**
  86262. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86263. * This is dynamic to allow compat with webgl 1 and 2.
  86264. * You will need to pass the name of the uniform as well as the value.
  86265. */
  86266. updateMatrix: (name: string, mat: Matrix) => void;
  86267. /**
  86268. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86269. * This is dynamic to allow compat with webgl 1 and 2.
  86270. * You will need to pass the name of the uniform as well as the value.
  86271. */
  86272. updateVector3: (name: string, vector: Vector3) => void;
  86273. /**
  86274. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86275. * This is dynamic to allow compat with webgl 1 and 2.
  86276. * You will need to pass the name of the uniform as well as the value.
  86277. */
  86278. updateVector4: (name: string, vector: Vector4) => void;
  86279. /**
  86280. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86281. * This is dynamic to allow compat with webgl 1 and 2.
  86282. * You will need to pass the name of the uniform as well as the value.
  86283. */
  86284. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86285. /**
  86286. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86287. * This is dynamic to allow compat with webgl 1 and 2.
  86288. * You will need to pass the name of the uniform as well as the value.
  86289. */
  86290. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86291. /**
  86292. * Instantiates a new Uniform buffer objects.
  86293. *
  86294. * Handles blocks of uniform on the GPU.
  86295. *
  86296. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86297. *
  86298. * For more information, please refer to :
  86299. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86300. * @param engine Define the engine the buffer is associated with
  86301. * @param data Define the data contained in the buffer
  86302. * @param dynamic Define if the buffer is updatable
  86303. */
  86304. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86305. /**
  86306. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86307. * or just falling back on setUniformXXX calls.
  86308. */
  86309. readonly useUbo: boolean;
  86310. /**
  86311. * Indicates if the WebGL underlying uniform buffer is in sync
  86312. * with the javascript cache data.
  86313. */
  86314. readonly isSync: boolean;
  86315. /**
  86316. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86317. * Also, a dynamic UniformBuffer will disable cache verification and always
  86318. * update the underlying WebGL uniform buffer to the GPU.
  86319. * @returns if Dynamic, otherwise false
  86320. */
  86321. isDynamic(): boolean;
  86322. /**
  86323. * The data cache on JS side.
  86324. * @returns the underlying data as a float array
  86325. */
  86326. getData(): Float32Array;
  86327. /**
  86328. * The underlying WebGL Uniform buffer.
  86329. * @returns the webgl buffer
  86330. */
  86331. getBuffer(): Nullable<DataBuffer>;
  86332. /**
  86333. * std140 layout specifies how to align data within an UBO structure.
  86334. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86335. * for specs.
  86336. */
  86337. private _fillAlignment;
  86338. /**
  86339. * Adds an uniform in the buffer.
  86340. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86341. * for the layout to be correct !
  86342. * @param name Name of the uniform, as used in the uniform block in the shader.
  86343. * @param size Data size, or data directly.
  86344. */
  86345. addUniform(name: string, size: number | number[]): void;
  86346. /**
  86347. * Adds a Matrix 4x4 to the uniform buffer.
  86348. * @param name Name of the uniform, as used in the uniform block in the shader.
  86349. * @param mat A 4x4 matrix.
  86350. */
  86351. addMatrix(name: string, mat: Matrix): void;
  86352. /**
  86353. * Adds a vec2 to the uniform buffer.
  86354. * @param name Name of the uniform, as used in the uniform block in the shader.
  86355. * @param x Define the x component value of the vec2
  86356. * @param y Define the y component value of the vec2
  86357. */
  86358. addFloat2(name: string, x: number, y: number): void;
  86359. /**
  86360. * Adds a vec3 to the uniform buffer.
  86361. * @param name Name of the uniform, as used in the uniform block in the shader.
  86362. * @param x Define the x component value of the vec3
  86363. * @param y Define the y component value of the vec3
  86364. * @param z Define the z component value of the vec3
  86365. */
  86366. addFloat3(name: string, x: number, y: number, z: number): void;
  86367. /**
  86368. * Adds a vec3 to the uniform buffer.
  86369. * @param name Name of the uniform, as used in the uniform block in the shader.
  86370. * @param color Define the vec3 from a Color
  86371. */
  86372. addColor3(name: string, color: Color3): void;
  86373. /**
  86374. * Adds a vec4 to the uniform buffer.
  86375. * @param name Name of the uniform, as used in the uniform block in the shader.
  86376. * @param color Define the rgb components from a Color
  86377. * @param alpha Define the a component of the vec4
  86378. */
  86379. addColor4(name: string, color: Color3, alpha: number): void;
  86380. /**
  86381. * Adds a vec3 to the uniform buffer.
  86382. * @param name Name of the uniform, as used in the uniform block in the shader.
  86383. * @param vector Define the vec3 components from a Vector
  86384. */
  86385. addVector3(name: string, vector: Vector3): void;
  86386. /**
  86387. * Adds a Matrix 3x3 to the uniform buffer.
  86388. * @param name Name of the uniform, as used in the uniform block in the shader.
  86389. */
  86390. addMatrix3x3(name: string): void;
  86391. /**
  86392. * Adds a Matrix 2x2 to the uniform buffer.
  86393. * @param name Name of the uniform, as used in the uniform block in the shader.
  86394. */
  86395. addMatrix2x2(name: string): void;
  86396. /**
  86397. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86398. */
  86399. create(): void;
  86400. /** @hidden */
  86401. _rebuild(): void;
  86402. /**
  86403. * Updates the WebGL Uniform Buffer on the GPU.
  86404. * If the `dynamic` flag is set to true, no cache comparison is done.
  86405. * Otherwise, the buffer will be updated only if the cache differs.
  86406. */
  86407. update(): void;
  86408. /**
  86409. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86410. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86411. * @param data Define the flattened data
  86412. * @param size Define the size of the data.
  86413. */
  86414. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86415. private _updateMatrix3x3ForUniform;
  86416. private _updateMatrix3x3ForEffect;
  86417. private _updateMatrix2x2ForEffect;
  86418. private _updateMatrix2x2ForUniform;
  86419. private _updateFloatForEffect;
  86420. private _updateFloatForUniform;
  86421. private _updateFloat2ForEffect;
  86422. private _updateFloat2ForUniform;
  86423. private _updateFloat3ForEffect;
  86424. private _updateFloat3ForUniform;
  86425. private _updateFloat4ForEffect;
  86426. private _updateFloat4ForUniform;
  86427. private _updateMatrixForEffect;
  86428. private _updateMatrixForUniform;
  86429. private _updateVector3ForEffect;
  86430. private _updateVector3ForUniform;
  86431. private _updateVector4ForEffect;
  86432. private _updateVector4ForUniform;
  86433. private _updateColor3ForEffect;
  86434. private _updateColor3ForUniform;
  86435. private _updateColor4ForEffect;
  86436. private _updateColor4ForUniform;
  86437. /**
  86438. * Sets a sampler uniform on the effect.
  86439. * @param name Define the name of the sampler.
  86440. * @param texture Define the texture to set in the sampler
  86441. */
  86442. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86443. /**
  86444. * Directly updates the value of the uniform in the cache AND on the GPU.
  86445. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86446. * @param data Define the flattened data
  86447. */
  86448. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86449. /**
  86450. * Binds this uniform buffer to an effect.
  86451. * @param effect Define the effect to bind the buffer to
  86452. * @param name Name of the uniform block in the shader.
  86453. */
  86454. bindToEffect(effect: Effect, name: string): void;
  86455. /**
  86456. * Disposes the uniform buffer.
  86457. */
  86458. dispose(): void;
  86459. }
  86460. }
  86461. declare module BABYLON {
  86462. /**
  86463. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86465. */
  86466. export class Analyser {
  86467. /**
  86468. * Gets or sets the smoothing
  86469. * @ignorenaming
  86470. */
  86471. SMOOTHING: number;
  86472. /**
  86473. * Gets or sets the FFT table size
  86474. * @ignorenaming
  86475. */
  86476. FFT_SIZE: number;
  86477. /**
  86478. * Gets or sets the bar graph amplitude
  86479. * @ignorenaming
  86480. */
  86481. BARGRAPHAMPLITUDE: number;
  86482. /**
  86483. * Gets or sets the position of the debug canvas
  86484. * @ignorenaming
  86485. */
  86486. DEBUGCANVASPOS: {
  86487. x: number;
  86488. y: number;
  86489. };
  86490. /**
  86491. * Gets or sets the debug canvas size
  86492. * @ignorenaming
  86493. */
  86494. DEBUGCANVASSIZE: {
  86495. width: number;
  86496. height: number;
  86497. };
  86498. private _byteFreqs;
  86499. private _byteTime;
  86500. private _floatFreqs;
  86501. private _webAudioAnalyser;
  86502. private _debugCanvas;
  86503. private _debugCanvasContext;
  86504. private _scene;
  86505. private _registerFunc;
  86506. private _audioEngine;
  86507. /**
  86508. * Creates a new analyser
  86509. * @param scene defines hosting scene
  86510. */
  86511. constructor(scene: Scene);
  86512. /**
  86513. * Get the number of data values you will have to play with for the visualization
  86514. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86515. * @returns a number
  86516. */
  86517. getFrequencyBinCount(): number;
  86518. /**
  86519. * Gets the current frequency data as a byte array
  86520. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86521. * @returns a Uint8Array
  86522. */
  86523. getByteFrequencyData(): Uint8Array;
  86524. /**
  86525. * Gets the current waveform as a byte array
  86526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86527. * @returns a Uint8Array
  86528. */
  86529. getByteTimeDomainData(): Uint8Array;
  86530. /**
  86531. * Gets the current frequency data as a float array
  86532. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86533. * @returns a Float32Array
  86534. */
  86535. getFloatFrequencyData(): Float32Array;
  86536. /**
  86537. * Renders the debug canvas
  86538. */
  86539. drawDebugCanvas(): void;
  86540. /**
  86541. * Stops rendering the debug canvas and removes it
  86542. */
  86543. stopDebugCanvas(): void;
  86544. /**
  86545. * Connects two audio nodes
  86546. * @param inputAudioNode defines first node to connect
  86547. * @param outputAudioNode defines second node to connect
  86548. */
  86549. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86550. /**
  86551. * Releases all associated resources
  86552. */
  86553. dispose(): void;
  86554. }
  86555. }
  86556. declare module BABYLON {
  86557. /**
  86558. * This represents an audio engine and it is responsible
  86559. * to play, synchronize and analyse sounds throughout the application.
  86560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86561. */
  86562. export interface IAudioEngine extends IDisposable {
  86563. /**
  86564. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86565. */
  86566. readonly canUseWebAudio: boolean;
  86567. /**
  86568. * Gets the current AudioContext if available.
  86569. */
  86570. readonly audioContext: Nullable<AudioContext>;
  86571. /**
  86572. * The master gain node defines the global audio volume of your audio engine.
  86573. */
  86574. readonly masterGain: GainNode;
  86575. /**
  86576. * Gets whether or not mp3 are supported by your browser.
  86577. */
  86578. readonly isMP3supported: boolean;
  86579. /**
  86580. * Gets whether or not ogg are supported by your browser.
  86581. */
  86582. readonly isOGGsupported: boolean;
  86583. /**
  86584. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86585. * @ignoreNaming
  86586. */
  86587. WarnedWebAudioUnsupported: boolean;
  86588. /**
  86589. * Defines if the audio engine relies on a custom unlocked button.
  86590. * In this case, the embedded button will not be displayed.
  86591. */
  86592. useCustomUnlockedButton: boolean;
  86593. /**
  86594. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86595. */
  86596. readonly unlocked: boolean;
  86597. /**
  86598. * Event raised when audio has been unlocked on the browser.
  86599. */
  86600. onAudioUnlockedObservable: Observable<AudioEngine>;
  86601. /**
  86602. * Event raised when audio has been locked on the browser.
  86603. */
  86604. onAudioLockedObservable: Observable<AudioEngine>;
  86605. /**
  86606. * Flags the audio engine in Locked state.
  86607. * This happens due to new browser policies preventing audio to autoplay.
  86608. */
  86609. lock(): void;
  86610. /**
  86611. * Unlocks the audio engine once a user action has been done on the dom.
  86612. * This is helpful to resume play once browser policies have been satisfied.
  86613. */
  86614. unlock(): void;
  86615. }
  86616. /**
  86617. * This represents the default audio engine used in babylon.
  86618. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86620. */
  86621. export class AudioEngine implements IAudioEngine {
  86622. private _audioContext;
  86623. private _audioContextInitialized;
  86624. private _muteButton;
  86625. private _hostElement;
  86626. /**
  86627. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86628. */
  86629. canUseWebAudio: boolean;
  86630. /**
  86631. * The master gain node defines the global audio volume of your audio engine.
  86632. */
  86633. masterGain: GainNode;
  86634. /**
  86635. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86636. * @ignoreNaming
  86637. */
  86638. WarnedWebAudioUnsupported: boolean;
  86639. /**
  86640. * Gets whether or not mp3 are supported by your browser.
  86641. */
  86642. isMP3supported: boolean;
  86643. /**
  86644. * Gets whether or not ogg are supported by your browser.
  86645. */
  86646. isOGGsupported: boolean;
  86647. /**
  86648. * Gets whether audio has been unlocked on the device.
  86649. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86650. * a user interaction has happened.
  86651. */
  86652. unlocked: boolean;
  86653. /**
  86654. * Defines if the audio engine relies on a custom unlocked button.
  86655. * In this case, the embedded button will not be displayed.
  86656. */
  86657. useCustomUnlockedButton: boolean;
  86658. /**
  86659. * Event raised when audio has been unlocked on the browser.
  86660. */
  86661. onAudioUnlockedObservable: Observable<AudioEngine>;
  86662. /**
  86663. * Event raised when audio has been locked on the browser.
  86664. */
  86665. onAudioLockedObservable: Observable<AudioEngine>;
  86666. /**
  86667. * Gets the current AudioContext if available.
  86668. */
  86669. readonly audioContext: Nullable<AudioContext>;
  86670. private _connectedAnalyser;
  86671. /**
  86672. * Instantiates a new audio engine.
  86673. *
  86674. * There should be only one per page as some browsers restrict the number
  86675. * of audio contexts you can create.
  86676. * @param hostElement defines the host element where to display the mute icon if necessary
  86677. */
  86678. constructor(hostElement?: Nullable<HTMLElement>);
  86679. /**
  86680. * Flags the audio engine in Locked state.
  86681. * This happens due to new browser policies preventing audio to autoplay.
  86682. */
  86683. lock(): void;
  86684. /**
  86685. * Unlocks the audio engine once a user action has been done on the dom.
  86686. * This is helpful to resume play once browser policies have been satisfied.
  86687. */
  86688. unlock(): void;
  86689. private _resumeAudioContext;
  86690. private _initializeAudioContext;
  86691. private _tryToRun;
  86692. private _triggerRunningState;
  86693. private _triggerSuspendedState;
  86694. private _displayMuteButton;
  86695. private _moveButtonToTopLeft;
  86696. private _onResize;
  86697. private _hideMuteButton;
  86698. /**
  86699. * Destroy and release the resources associated with the audio ccontext.
  86700. */
  86701. dispose(): void;
  86702. /**
  86703. * Gets the global volume sets on the master gain.
  86704. * @returns the global volume if set or -1 otherwise
  86705. */
  86706. getGlobalVolume(): number;
  86707. /**
  86708. * Sets the global volume of your experience (sets on the master gain).
  86709. * @param newVolume Defines the new global volume of the application
  86710. */
  86711. setGlobalVolume(newVolume: number): void;
  86712. /**
  86713. * Connect the audio engine to an audio analyser allowing some amazing
  86714. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86716. * @param analyser The analyser to connect to the engine
  86717. */
  86718. connectToAnalyser(analyser: Analyser): void;
  86719. }
  86720. }
  86721. declare module BABYLON {
  86722. /**
  86723. * Interface used to present a loading screen while loading a scene
  86724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86725. */
  86726. export interface ILoadingScreen {
  86727. /**
  86728. * Function called to display the loading screen
  86729. */
  86730. displayLoadingUI: () => void;
  86731. /**
  86732. * Function called to hide the loading screen
  86733. */
  86734. hideLoadingUI: () => void;
  86735. /**
  86736. * Gets or sets the color to use for the background
  86737. */
  86738. loadingUIBackgroundColor: string;
  86739. /**
  86740. * Gets or sets the text to display while loading
  86741. */
  86742. loadingUIText: string;
  86743. }
  86744. /**
  86745. * Class used for the default loading screen
  86746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86747. */
  86748. export class DefaultLoadingScreen implements ILoadingScreen {
  86749. private _renderingCanvas;
  86750. private _loadingText;
  86751. private _loadingDivBackgroundColor;
  86752. private _loadingDiv;
  86753. private _loadingTextDiv;
  86754. /**
  86755. * Creates a new default loading screen
  86756. * @param _renderingCanvas defines the canvas used to render the scene
  86757. * @param _loadingText defines the default text to display
  86758. * @param _loadingDivBackgroundColor defines the default background color
  86759. */
  86760. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86761. /**
  86762. * Function called to display the loading screen
  86763. */
  86764. displayLoadingUI(): void;
  86765. /**
  86766. * Function called to hide the loading screen
  86767. */
  86768. hideLoadingUI(): void;
  86769. /**
  86770. * Gets or sets the text to display while loading
  86771. */
  86772. loadingUIText: string;
  86773. /**
  86774. * Gets or sets the color to use for the background
  86775. */
  86776. loadingUIBackgroundColor: string;
  86777. private _resizeLoadingUI;
  86778. }
  86779. }
  86780. declare module BABYLON {
  86781. /** @hidden */
  86782. export class WebGLPipelineContext implements IPipelineContext {
  86783. engine: Engine;
  86784. program: Nullable<WebGLProgram>;
  86785. context?: WebGLRenderingContext;
  86786. vertexShader?: WebGLShader;
  86787. fragmentShader?: WebGLShader;
  86788. isParallelCompiled: boolean;
  86789. onCompiled?: () => void;
  86790. transformFeedback?: WebGLTransformFeedback | null;
  86791. readonly isAsync: boolean;
  86792. readonly isReady: boolean;
  86793. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86794. }
  86795. }
  86796. declare module BABYLON {
  86797. /** @hidden */
  86798. export class WebGLDataBuffer extends DataBuffer {
  86799. private _buffer;
  86800. constructor(resource: WebGLBuffer);
  86801. readonly underlyingResource: any;
  86802. }
  86803. }
  86804. declare module BABYLON {
  86805. /**
  86806. * Settings for finer control over video usage
  86807. */
  86808. export interface VideoTextureSettings {
  86809. /**
  86810. * Applies `autoplay` to video, if specified
  86811. */
  86812. autoPlay?: boolean;
  86813. /**
  86814. * Applies `loop` to video, if specified
  86815. */
  86816. loop?: boolean;
  86817. /**
  86818. * Automatically updates internal texture from video at every frame in the render loop
  86819. */
  86820. autoUpdateTexture: boolean;
  86821. /**
  86822. * Image src displayed during the video loading or until the user interacts with the video.
  86823. */
  86824. poster?: string;
  86825. }
  86826. /**
  86827. * If you want to display a video in your scene, this is the special texture for that.
  86828. * This special texture works similar to other textures, with the exception of a few parameters.
  86829. * @see https://doc.babylonjs.com/how_to/video_texture
  86830. */
  86831. export class VideoTexture extends Texture {
  86832. /**
  86833. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86834. */
  86835. readonly autoUpdateTexture: boolean;
  86836. /**
  86837. * The video instance used by the texture internally
  86838. */
  86839. readonly video: HTMLVideoElement;
  86840. private _onUserActionRequestedObservable;
  86841. /**
  86842. * Event triggerd when a dom action is required by the user to play the video.
  86843. * This happens due to recent changes in browser policies preventing video to auto start.
  86844. */
  86845. readonly onUserActionRequestedObservable: Observable<Texture>;
  86846. private _generateMipMaps;
  86847. private _engine;
  86848. private _stillImageCaptured;
  86849. private _displayingPosterTexture;
  86850. private _settings;
  86851. private _createInternalTextureOnEvent;
  86852. /**
  86853. * Creates a video texture.
  86854. * If you want to display a video in your scene, this is the special texture for that.
  86855. * This special texture works similar to other textures, with the exception of a few parameters.
  86856. * @see https://doc.babylonjs.com/how_to/video_texture
  86857. * @param name optional name, will detect from video source, if not defined
  86858. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86859. * @param scene is obviously the current scene.
  86860. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86861. * @param invertY is false by default but can be used to invert video on Y axis
  86862. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86863. * @param settings allows finer control over video usage
  86864. */
  86865. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86866. private _getName;
  86867. private _getVideo;
  86868. private _createInternalTexture;
  86869. private reset;
  86870. /**
  86871. * @hidden Internal method to initiate `update`.
  86872. */
  86873. _rebuild(): void;
  86874. /**
  86875. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86876. */
  86877. update(): void;
  86878. /**
  86879. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86880. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86881. */
  86882. updateTexture(isVisible: boolean): void;
  86883. protected _updateInternalTexture: () => void;
  86884. /**
  86885. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86886. * @param url New url.
  86887. */
  86888. updateURL(url: string): void;
  86889. /**
  86890. * Dispose the texture and release its associated resources.
  86891. */
  86892. dispose(): void;
  86893. /**
  86894. * Creates a video texture straight from a stream.
  86895. * @param scene Define the scene the texture should be created in
  86896. * @param stream Define the stream the texture should be created from
  86897. * @returns The created video texture as a promise
  86898. */
  86899. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86900. /**
  86901. * Creates a video texture straight from your WebCam video feed.
  86902. * @param scene Define the scene the texture should be created in
  86903. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86904. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86905. * @returns The created video texture as a promise
  86906. */
  86907. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86908. minWidth: number;
  86909. maxWidth: number;
  86910. minHeight: number;
  86911. maxHeight: number;
  86912. deviceId: string;
  86913. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86914. /**
  86915. * Creates a video texture straight from your WebCam video feed.
  86916. * @param scene Define the scene the texture should be created in
  86917. * @param onReady Define a callback to triggered once the texture will be ready
  86918. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86919. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86920. */
  86921. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86922. minWidth: number;
  86923. maxWidth: number;
  86924. minHeight: number;
  86925. maxHeight: number;
  86926. deviceId: string;
  86927. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86928. }
  86929. }
  86930. declare module BABYLON {
  86931. /**
  86932. * Interface for attribute information associated with buffer instanciation
  86933. */
  86934. export class InstancingAttributeInfo {
  86935. /**
  86936. * Index/offset of the attribute in the vertex shader
  86937. */
  86938. index: number;
  86939. /**
  86940. * size of the attribute, 1, 2, 3 or 4
  86941. */
  86942. attributeSize: number;
  86943. /**
  86944. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86945. * default is FLOAT
  86946. */
  86947. attribyteType: number;
  86948. /**
  86949. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86950. */
  86951. normalized: boolean;
  86952. /**
  86953. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86954. */
  86955. offset: number;
  86956. /**
  86957. * Name of the GLSL attribute, for debugging purpose only
  86958. */
  86959. attributeName: string;
  86960. }
  86961. /**
  86962. * Define options used to create a depth texture
  86963. */
  86964. export class DepthTextureCreationOptions {
  86965. /** Specifies whether or not a stencil should be allocated in the texture */
  86966. generateStencil?: boolean;
  86967. /** Specifies whether or not bilinear filtering is enable on the texture */
  86968. bilinearFiltering?: boolean;
  86969. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86970. comparisonFunction?: number;
  86971. /** Specifies if the created texture is a cube texture */
  86972. isCube?: boolean;
  86973. }
  86974. /**
  86975. * Class used to describe the capabilities of the engine relatively to the current browser
  86976. */
  86977. export class EngineCapabilities {
  86978. /** Maximum textures units per fragment shader */
  86979. maxTexturesImageUnits: number;
  86980. /** Maximum texture units per vertex shader */
  86981. maxVertexTextureImageUnits: number;
  86982. /** Maximum textures units in the entire pipeline */
  86983. maxCombinedTexturesImageUnits: number;
  86984. /** Maximum texture size */
  86985. maxTextureSize: number;
  86986. /** Maximum cube texture size */
  86987. maxCubemapTextureSize: number;
  86988. /** Maximum render texture size */
  86989. maxRenderTextureSize: number;
  86990. /** Maximum number of vertex attributes */
  86991. maxVertexAttribs: number;
  86992. /** Maximum number of varyings */
  86993. maxVaryingVectors: number;
  86994. /** Maximum number of uniforms per vertex shader */
  86995. maxVertexUniformVectors: number;
  86996. /** Maximum number of uniforms per fragment shader */
  86997. maxFragmentUniformVectors: number;
  86998. /** Defines if standard derivates (dx/dy) are supported */
  86999. standardDerivatives: boolean;
  87000. /** Defines if s3tc texture compression is supported */
  87001. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87002. /** Defines if pvrtc texture compression is supported */
  87003. pvrtc: any;
  87004. /** Defines if etc1 texture compression is supported */
  87005. etc1: any;
  87006. /** Defines if etc2 texture compression is supported */
  87007. etc2: any;
  87008. /** Defines if astc texture compression is supported */
  87009. astc: any;
  87010. /** Defines if float textures are supported */
  87011. textureFloat: boolean;
  87012. /** Defines if vertex array objects are supported */
  87013. vertexArrayObject: boolean;
  87014. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87015. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87016. /** Gets the maximum level of anisotropy supported */
  87017. maxAnisotropy: number;
  87018. /** Defines if instancing is supported */
  87019. instancedArrays: boolean;
  87020. /** Defines if 32 bits indices are supported */
  87021. uintIndices: boolean;
  87022. /** Defines if high precision shaders are supported */
  87023. highPrecisionShaderSupported: boolean;
  87024. /** Defines if depth reading in the fragment shader is supported */
  87025. fragmentDepthSupported: boolean;
  87026. /** Defines if float texture linear filtering is supported*/
  87027. textureFloatLinearFiltering: boolean;
  87028. /** Defines if rendering to float textures is supported */
  87029. textureFloatRender: boolean;
  87030. /** Defines if half float textures are supported*/
  87031. textureHalfFloat: boolean;
  87032. /** Defines if half float texture linear filtering is supported*/
  87033. textureHalfFloatLinearFiltering: boolean;
  87034. /** Defines if rendering to half float textures is supported */
  87035. textureHalfFloatRender: boolean;
  87036. /** Defines if textureLOD shader command is supported */
  87037. textureLOD: boolean;
  87038. /** Defines if draw buffers extension is supported */
  87039. drawBuffersExtension: boolean;
  87040. /** Defines if depth textures are supported */
  87041. depthTextureExtension: boolean;
  87042. /** Defines if float color buffer are supported */
  87043. colorBufferFloat: boolean;
  87044. /** Gets disjoint timer query extension (null if not supported) */
  87045. timerQuery: EXT_disjoint_timer_query;
  87046. /** Defines if timestamp can be used with timer query */
  87047. canUseTimestampForTimerQuery: boolean;
  87048. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87049. multiview: any;
  87050. /** Function used to let the system compiles shaders in background */
  87051. parallelShaderCompile: {
  87052. COMPLETION_STATUS_KHR: number;
  87053. };
  87054. }
  87055. /** Interface defining initialization parameters for Engine class */
  87056. export interface EngineOptions extends WebGLContextAttributes {
  87057. /**
  87058. * Defines if the engine should no exceed a specified device ratio
  87059. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87060. */
  87061. limitDeviceRatio?: number;
  87062. /**
  87063. * Defines if webvr should be enabled automatically
  87064. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87065. */
  87066. autoEnableWebVR?: boolean;
  87067. /**
  87068. * Defines if webgl2 should be turned off even if supported
  87069. * @see http://doc.babylonjs.com/features/webgl2
  87070. */
  87071. disableWebGL2Support?: boolean;
  87072. /**
  87073. * Defines if webaudio should be initialized as well
  87074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87075. */
  87076. audioEngine?: boolean;
  87077. /**
  87078. * Defines if animations should run using a deterministic lock step
  87079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87080. */
  87081. deterministicLockstep?: boolean;
  87082. /** Defines the maximum steps to use with deterministic lock step mode */
  87083. lockstepMaxSteps?: number;
  87084. /**
  87085. * Defines that engine should ignore context lost events
  87086. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87087. */
  87088. doNotHandleContextLost?: boolean;
  87089. /**
  87090. * Defines that engine should ignore modifying touch action attribute and style
  87091. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87092. */
  87093. doNotHandleTouchAction?: boolean;
  87094. /**
  87095. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87096. */
  87097. useHighPrecisionFloats?: boolean;
  87098. }
  87099. /**
  87100. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87101. */
  87102. export class Engine {
  87103. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87104. static ExceptionList: ({
  87105. key: string;
  87106. capture: string;
  87107. captureConstraint: number;
  87108. targets: string[];
  87109. } | {
  87110. key: string;
  87111. capture: null;
  87112. captureConstraint: null;
  87113. targets: string[];
  87114. })[];
  87115. /** Gets the list of created engines */
  87116. static readonly Instances: Engine[];
  87117. /**
  87118. * Gets the latest created engine
  87119. */
  87120. static readonly LastCreatedEngine: Nullable<Engine>;
  87121. /**
  87122. * Gets the latest created scene
  87123. */
  87124. static readonly LastCreatedScene: Nullable<Scene>;
  87125. /**
  87126. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87127. * @param flag defines which part of the materials must be marked as dirty
  87128. * @param predicate defines a predicate used to filter which materials should be affected
  87129. */
  87130. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87131. /**
  87132. * Hidden
  87133. */
  87134. static _TextureLoaders: IInternalTextureLoader[];
  87135. /** Defines that alpha blending is disabled */
  87136. static readonly ALPHA_DISABLE: number;
  87137. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87138. static readonly ALPHA_ADD: number;
  87139. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87140. static readonly ALPHA_COMBINE: number;
  87141. /** Defines that alpha blending to DEST - SRC * DEST */
  87142. static readonly ALPHA_SUBTRACT: number;
  87143. /** Defines that alpha blending to SRC * DEST */
  87144. static readonly ALPHA_MULTIPLY: number;
  87145. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87146. static readonly ALPHA_MAXIMIZED: number;
  87147. /** Defines that alpha blending to SRC + DEST */
  87148. static readonly ALPHA_ONEONE: number;
  87149. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87150. static readonly ALPHA_PREMULTIPLIED: number;
  87151. /**
  87152. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87153. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87154. */
  87155. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87156. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87157. static readonly ALPHA_INTERPOLATE: number;
  87158. /**
  87159. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87160. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87161. */
  87162. static readonly ALPHA_SCREENMODE: number;
  87163. /** Defines that the ressource is not delayed*/
  87164. static readonly DELAYLOADSTATE_NONE: number;
  87165. /** Defines that the ressource was successfully delay loaded */
  87166. static readonly DELAYLOADSTATE_LOADED: number;
  87167. /** Defines that the ressource is currently delay loading */
  87168. static readonly DELAYLOADSTATE_LOADING: number;
  87169. /** Defines that the ressource is delayed and has not started loading */
  87170. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87171. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87172. static readonly NEVER: number;
  87173. /** 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 */
  87174. static readonly ALWAYS: number;
  87175. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87176. static readonly LESS: number;
  87177. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87178. static readonly EQUAL: number;
  87179. /** 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 */
  87180. static readonly LEQUAL: number;
  87181. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87182. static readonly GREATER: number;
  87183. /** 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 */
  87184. static readonly GEQUAL: number;
  87185. /** 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 */
  87186. static readonly NOTEQUAL: number;
  87187. /** Passed to stencilOperation to specify that stencil value must be kept */
  87188. static readonly KEEP: number;
  87189. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87190. static readonly REPLACE: number;
  87191. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87192. static readonly INCR: number;
  87193. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87194. static readonly DECR: number;
  87195. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87196. static readonly INVERT: number;
  87197. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87198. static readonly INCR_WRAP: number;
  87199. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87200. static readonly DECR_WRAP: number;
  87201. /** Texture is not repeating outside of 0..1 UVs */
  87202. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87203. /** Texture is repeating outside of 0..1 UVs */
  87204. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87205. /** Texture is repeating and mirrored */
  87206. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87207. /** ALPHA */
  87208. static readonly TEXTUREFORMAT_ALPHA: number;
  87209. /** LUMINANCE */
  87210. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87211. /** LUMINANCE_ALPHA */
  87212. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87213. /** RGB */
  87214. static readonly TEXTUREFORMAT_RGB: number;
  87215. /** RGBA */
  87216. static readonly TEXTUREFORMAT_RGBA: number;
  87217. /** RED */
  87218. static readonly TEXTUREFORMAT_RED: number;
  87219. /** RED (2nd reference) */
  87220. static readonly TEXTUREFORMAT_R: number;
  87221. /** RG */
  87222. static readonly TEXTUREFORMAT_RG: number;
  87223. /** RED_INTEGER */
  87224. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87225. /** RED_INTEGER (2nd reference) */
  87226. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87227. /** RG_INTEGER */
  87228. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87229. /** RGB_INTEGER */
  87230. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87231. /** RGBA_INTEGER */
  87232. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87233. /** UNSIGNED_BYTE */
  87234. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87235. /** UNSIGNED_BYTE (2nd reference) */
  87236. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87237. /** FLOAT */
  87238. static readonly TEXTURETYPE_FLOAT: number;
  87239. /** HALF_FLOAT */
  87240. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87241. /** BYTE */
  87242. static readonly TEXTURETYPE_BYTE: number;
  87243. /** SHORT */
  87244. static readonly TEXTURETYPE_SHORT: number;
  87245. /** UNSIGNED_SHORT */
  87246. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87247. /** INT */
  87248. static readonly TEXTURETYPE_INT: number;
  87249. /** UNSIGNED_INT */
  87250. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87251. /** UNSIGNED_SHORT_4_4_4_4 */
  87252. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87253. /** UNSIGNED_SHORT_5_5_5_1 */
  87254. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87255. /** UNSIGNED_SHORT_5_6_5 */
  87256. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87257. /** UNSIGNED_INT_2_10_10_10_REV */
  87258. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87259. /** UNSIGNED_INT_24_8 */
  87260. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87261. /** UNSIGNED_INT_10F_11F_11F_REV */
  87262. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87263. /** UNSIGNED_INT_5_9_9_9_REV */
  87264. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87265. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87266. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87267. /** nearest is mag = nearest and min = nearest and mip = linear */
  87268. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87269. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87270. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87271. /** Trilinear is mag = linear and min = linear and mip = linear */
  87272. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87273. /** nearest is mag = nearest and min = nearest and mip = linear */
  87274. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87275. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87276. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87277. /** Trilinear is mag = linear and min = linear and mip = linear */
  87278. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87279. /** mag = nearest and min = nearest and mip = nearest */
  87280. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87281. /** mag = nearest and min = linear and mip = nearest */
  87282. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87283. /** mag = nearest and min = linear and mip = linear */
  87284. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87285. /** mag = nearest and min = linear and mip = none */
  87286. static readonly TEXTURE_NEAREST_LINEAR: number;
  87287. /** mag = nearest and min = nearest and mip = none */
  87288. static readonly TEXTURE_NEAREST_NEAREST: number;
  87289. /** mag = linear and min = nearest and mip = nearest */
  87290. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87291. /** mag = linear and min = nearest and mip = linear */
  87292. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87293. /** mag = linear and min = linear and mip = none */
  87294. static readonly TEXTURE_LINEAR_LINEAR: number;
  87295. /** mag = linear and min = nearest and mip = none */
  87296. static readonly TEXTURE_LINEAR_NEAREST: number;
  87297. /** Explicit coordinates mode */
  87298. static readonly TEXTURE_EXPLICIT_MODE: number;
  87299. /** Spherical coordinates mode */
  87300. static readonly TEXTURE_SPHERICAL_MODE: number;
  87301. /** Planar coordinates mode */
  87302. static readonly TEXTURE_PLANAR_MODE: number;
  87303. /** Cubic coordinates mode */
  87304. static readonly TEXTURE_CUBIC_MODE: number;
  87305. /** Projection coordinates mode */
  87306. static readonly TEXTURE_PROJECTION_MODE: number;
  87307. /** Skybox coordinates mode */
  87308. static readonly TEXTURE_SKYBOX_MODE: number;
  87309. /** Inverse Cubic coordinates mode */
  87310. static readonly TEXTURE_INVCUBIC_MODE: number;
  87311. /** Equirectangular coordinates mode */
  87312. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87313. /** Equirectangular Fixed coordinates mode */
  87314. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87315. /** Equirectangular Fixed Mirrored coordinates mode */
  87316. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87317. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87318. static readonly SCALEMODE_FLOOR: number;
  87319. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87320. static readonly SCALEMODE_NEAREST: number;
  87321. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87322. static readonly SCALEMODE_CEILING: number;
  87323. /**
  87324. * Returns the current npm package of the sdk
  87325. */
  87326. static readonly NpmPackage: string;
  87327. /**
  87328. * Returns the current version of the framework
  87329. */
  87330. static readonly Version: string;
  87331. /**
  87332. * Returns a string describing the current engine
  87333. */
  87334. readonly description: string;
  87335. /**
  87336. * Gets or sets the epsilon value used by collision engine
  87337. */
  87338. static CollisionsEpsilon: number;
  87339. /**
  87340. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87341. */
  87342. static ShadersRepository: string;
  87343. /**
  87344. * Method called to create the default loading screen.
  87345. * This can be overriden in your own app.
  87346. * @param canvas The rendering canvas element
  87347. * @returns The loading screen
  87348. */
  87349. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87350. /**
  87351. * Method called to create the default rescale post process on each engine.
  87352. */
  87353. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87354. /**
  87355. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87356. */
  87357. forcePOTTextures: boolean;
  87358. /**
  87359. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87360. */
  87361. isFullscreen: boolean;
  87362. /**
  87363. * Gets a boolean indicating if the pointer is currently locked
  87364. */
  87365. isPointerLock: boolean;
  87366. /**
  87367. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87368. */
  87369. cullBackFaces: boolean;
  87370. /**
  87371. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87372. */
  87373. renderEvenInBackground: boolean;
  87374. /**
  87375. * Gets or sets a boolean indicating that cache can be kept between frames
  87376. */
  87377. preventCacheWipeBetweenFrames: boolean;
  87378. /**
  87379. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87380. **/
  87381. enableOfflineSupport: boolean;
  87382. /**
  87383. * 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)
  87384. **/
  87385. disableManifestCheck: boolean;
  87386. /**
  87387. * Gets the list of created scenes
  87388. */
  87389. scenes: Scene[];
  87390. /**
  87391. * Event raised when a new scene is created
  87392. */
  87393. onNewSceneAddedObservable: Observable<Scene>;
  87394. /**
  87395. * Gets the list of created postprocesses
  87396. */
  87397. postProcesses: PostProcess[];
  87398. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87399. validateShaderPrograms: boolean;
  87400. /**
  87401. * Observable event triggered each time the rendering canvas is resized
  87402. */
  87403. onResizeObservable: Observable<Engine>;
  87404. /**
  87405. * Observable event triggered each time the canvas loses focus
  87406. */
  87407. onCanvasBlurObservable: Observable<Engine>;
  87408. /**
  87409. * Observable event triggered each time the canvas gains focus
  87410. */
  87411. onCanvasFocusObservable: Observable<Engine>;
  87412. /**
  87413. * Observable event triggered each time the canvas receives pointerout event
  87414. */
  87415. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87416. /**
  87417. * Observable event triggered before each texture is initialized
  87418. */
  87419. onBeforeTextureInitObservable: Observable<Texture>;
  87420. /**
  87421. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87422. */
  87423. disableUniformBuffers: boolean;
  87424. /** @hidden */
  87425. _uniformBuffers: UniformBuffer[];
  87426. /**
  87427. * Gets a boolean indicating that the engine supports uniform buffers
  87428. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87429. */
  87430. readonly supportsUniformBuffers: boolean;
  87431. /**
  87432. * Observable raised when the engine begins a new frame
  87433. */
  87434. onBeginFrameObservable: Observable<Engine>;
  87435. /**
  87436. * If set, will be used to request the next animation frame for the render loop
  87437. */
  87438. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87439. /**
  87440. * Observable raised when the engine ends the current frame
  87441. */
  87442. onEndFrameObservable: Observable<Engine>;
  87443. /**
  87444. * Observable raised when the engine is about to compile a shader
  87445. */
  87446. onBeforeShaderCompilationObservable: Observable<Engine>;
  87447. /**
  87448. * Observable raised when the engine has jsut compiled a shader
  87449. */
  87450. onAfterShaderCompilationObservable: Observable<Engine>;
  87451. /** @hidden */
  87452. _gl: WebGLRenderingContext;
  87453. private _renderingCanvas;
  87454. private _windowIsBackground;
  87455. private _webGLVersion;
  87456. protected _highPrecisionShadersAllowed: boolean;
  87457. /** @hidden */
  87458. readonly _shouldUseHighPrecisionShader: boolean;
  87459. /**
  87460. * Gets a boolean indicating that only power of 2 textures are supported
  87461. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87462. */
  87463. readonly needPOTTextures: boolean;
  87464. /** @hidden */
  87465. _badOS: boolean;
  87466. /** @hidden */
  87467. _badDesktopOS: boolean;
  87468. /**
  87469. * Gets the audio engine
  87470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87471. * @ignorenaming
  87472. */
  87473. static audioEngine: IAudioEngine;
  87474. /**
  87475. * Default AudioEngine factory responsible of creating the Audio Engine.
  87476. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87477. */
  87478. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87479. /**
  87480. * Default offline support factory responsible of creating a tool used to store data locally.
  87481. * By default, this will create a Database object if the workload has been embedded.
  87482. */
  87483. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87484. private _onFocus;
  87485. private _onBlur;
  87486. private _onCanvasPointerOut;
  87487. private _onCanvasBlur;
  87488. private _onCanvasFocus;
  87489. private _onFullscreenChange;
  87490. private _onPointerLockChange;
  87491. private _hardwareScalingLevel;
  87492. /** @hidden */
  87493. _caps: EngineCapabilities;
  87494. private _pointerLockRequested;
  87495. private _isStencilEnable;
  87496. private _colorWrite;
  87497. private _loadingScreen;
  87498. /** @hidden */
  87499. _drawCalls: PerfCounter;
  87500. private _glVersion;
  87501. private _glRenderer;
  87502. private _glVendor;
  87503. private _videoTextureSupported;
  87504. private _renderingQueueLaunched;
  87505. private _activeRenderLoops;
  87506. private _deterministicLockstep;
  87507. private _lockstepMaxSteps;
  87508. /**
  87509. * Observable signaled when a context lost event is raised
  87510. */
  87511. onContextLostObservable: Observable<Engine>;
  87512. /**
  87513. * Observable signaled when a context restored event is raised
  87514. */
  87515. onContextRestoredObservable: Observable<Engine>;
  87516. private _onContextLost;
  87517. private _onContextRestored;
  87518. private _contextWasLost;
  87519. /** @hidden */
  87520. _doNotHandleContextLost: boolean;
  87521. /**
  87522. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87524. */
  87525. doNotHandleContextLost: boolean;
  87526. private _performanceMonitor;
  87527. private _fps;
  87528. private _deltaTime;
  87529. /**
  87530. * Turn this value on if you want to pause FPS computation when in background
  87531. */
  87532. disablePerformanceMonitorInBackground: boolean;
  87533. /**
  87534. * Gets the performance monitor attached to this engine
  87535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87536. */
  87537. readonly performanceMonitor: PerformanceMonitor;
  87538. /**
  87539. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87540. */
  87541. disableVertexArrayObjects: boolean;
  87542. /** @hidden */
  87543. protected _depthCullingState: _DepthCullingState;
  87544. /** @hidden */
  87545. protected _stencilState: _StencilState;
  87546. /** @hidden */
  87547. protected _alphaState: _AlphaState;
  87548. /** @hidden */
  87549. protected _alphaMode: number;
  87550. /** @hidden */
  87551. _internalTexturesCache: InternalTexture[];
  87552. /** @hidden */
  87553. protected _activeChannel: number;
  87554. private _currentTextureChannel;
  87555. /** @hidden */
  87556. protected _boundTexturesCache: {
  87557. [key: string]: Nullable<InternalTexture>;
  87558. };
  87559. /** @hidden */
  87560. protected _currentEffect: Nullable<Effect>;
  87561. /** @hidden */
  87562. protected _currentProgram: Nullable<WebGLProgram>;
  87563. private _compiledEffects;
  87564. private _vertexAttribArraysEnabled;
  87565. /** @hidden */
  87566. protected _cachedViewport: Nullable<Viewport>;
  87567. private _cachedVertexArrayObject;
  87568. /** @hidden */
  87569. protected _cachedVertexBuffers: any;
  87570. /** @hidden */
  87571. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87572. /** @hidden */
  87573. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87574. /** @hidden */
  87575. _currentRenderTarget: Nullable<InternalTexture>;
  87576. private _uintIndicesCurrentlySet;
  87577. private _currentBoundBuffer;
  87578. /** @hidden */
  87579. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87580. private _currentBufferPointers;
  87581. private _currentInstanceLocations;
  87582. private _currentInstanceBuffers;
  87583. private _textureUnits;
  87584. /** @hidden */
  87585. _workingCanvas: Nullable<HTMLCanvasElement>;
  87586. /** @hidden */
  87587. _workingContext: Nullable<CanvasRenderingContext2D>;
  87588. private _rescalePostProcess;
  87589. private _dummyFramebuffer;
  87590. private _externalData;
  87591. /** @hidden */
  87592. _bindedRenderFunction: any;
  87593. private _vaoRecordInProgress;
  87594. private _mustWipeVertexAttributes;
  87595. private _emptyTexture;
  87596. private _emptyCubeTexture;
  87597. private _emptyTexture3D;
  87598. /** @hidden */
  87599. _frameHandler: number;
  87600. private _nextFreeTextureSlots;
  87601. private _maxSimultaneousTextures;
  87602. private _activeRequests;
  87603. private _texturesSupported;
  87604. /** @hidden */
  87605. _textureFormatInUse: Nullable<string>;
  87606. /**
  87607. * Gets the list of texture formats supported
  87608. */
  87609. readonly texturesSupported: Array<string>;
  87610. /**
  87611. * Gets the list of texture formats in use
  87612. */
  87613. readonly textureFormatInUse: Nullable<string>;
  87614. /**
  87615. * Gets the current viewport
  87616. */
  87617. readonly currentViewport: Nullable<Viewport>;
  87618. /**
  87619. * Gets the default empty texture
  87620. */
  87621. readonly emptyTexture: InternalTexture;
  87622. /**
  87623. * Gets the default empty 3D texture
  87624. */
  87625. readonly emptyTexture3D: InternalTexture;
  87626. /**
  87627. * Gets the default empty cube texture
  87628. */
  87629. readonly emptyCubeTexture: InternalTexture;
  87630. /**
  87631. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87632. */
  87633. readonly premultipliedAlpha: boolean;
  87634. /**
  87635. * Creates a new engine
  87636. * @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
  87637. * @param antialias defines enable antialiasing (default: false)
  87638. * @param options defines further options to be sent to the getContext() function
  87639. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87640. */
  87641. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87642. /**
  87643. * Initializes a webVR display and starts listening to display change events
  87644. * The onVRDisplayChangedObservable will be notified upon these changes
  87645. * @returns The onVRDisplayChangedObservable
  87646. */
  87647. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87648. /** @hidden */
  87649. _prepareVRComponent(): void;
  87650. /** @hidden */
  87651. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87652. /** @hidden */
  87653. _submitVRFrame(): void;
  87654. /**
  87655. * Call this function to leave webVR mode
  87656. * Will do nothing if webVR is not supported or if there is no webVR device
  87657. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87658. */
  87659. disableVR(): void;
  87660. /**
  87661. * Gets a boolean indicating that the system is in VR mode and is presenting
  87662. * @returns true if VR mode is engaged
  87663. */
  87664. isVRPresenting(): boolean;
  87665. /** @hidden */
  87666. _requestVRFrame(): void;
  87667. private _disableTouchAction;
  87668. private _rebuildInternalTextures;
  87669. private _rebuildEffects;
  87670. /**
  87671. * Gets a boolean indicating if all created effects are ready
  87672. * @returns true if all effects are ready
  87673. */
  87674. areAllEffectsReady(): boolean;
  87675. private _rebuildBuffers;
  87676. private _initGLContext;
  87677. /**
  87678. * Gets version of the current webGL context
  87679. */
  87680. readonly webGLVersion: number;
  87681. /**
  87682. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87683. */
  87684. readonly isStencilEnable: boolean;
  87685. /** @hidden */
  87686. _prepareWorkingCanvas(): void;
  87687. /**
  87688. * Reset the texture cache to empty state
  87689. */
  87690. resetTextureCache(): void;
  87691. /**
  87692. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87694. * @returns true if engine is in deterministic lock step mode
  87695. */
  87696. isDeterministicLockStep(): boolean;
  87697. /**
  87698. * Gets the max steps when engine is running in deterministic lock step
  87699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87700. * @returns the max steps
  87701. */
  87702. getLockstepMaxSteps(): number;
  87703. /**
  87704. * Gets an object containing information about the current webGL context
  87705. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87706. */
  87707. getGlInfo(): {
  87708. vendor: string;
  87709. renderer: string;
  87710. version: string;
  87711. };
  87712. /**
  87713. * Gets current aspect ratio
  87714. * @param camera defines the camera to use to get the aspect ratio
  87715. * @param useScreen defines if screen size must be used (or the current render target if any)
  87716. * @returns a number defining the aspect ratio
  87717. */
  87718. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87719. /**
  87720. * Gets current screen aspect ratio
  87721. * @returns a number defining the aspect ratio
  87722. */
  87723. getScreenAspectRatio(): number;
  87724. /**
  87725. * Gets the current render width
  87726. * @param useScreen defines if screen size must be used (or the current render target if any)
  87727. * @returns a number defining the current render width
  87728. */
  87729. getRenderWidth(useScreen?: boolean): number;
  87730. /**
  87731. * Gets the current render height
  87732. * @param useScreen defines if screen size must be used (or the current render target if any)
  87733. * @returns a number defining the current render height
  87734. */
  87735. getRenderHeight(useScreen?: boolean): number;
  87736. /**
  87737. * Gets the HTML canvas attached with the current webGL context
  87738. * @returns a HTML canvas
  87739. */
  87740. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87741. /**
  87742. * Gets the client rect of the HTML canvas attached with the current webGL context
  87743. * @returns a client rectanglee
  87744. */
  87745. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87746. /**
  87747. * Defines the hardware scaling level.
  87748. * By default the hardware scaling level is computed from the window device ratio.
  87749. * 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.
  87750. * @param level defines the level to use
  87751. */
  87752. setHardwareScalingLevel(level: number): void;
  87753. /**
  87754. * Gets the current hardware scaling level.
  87755. * By default the hardware scaling level is computed from the window device ratio.
  87756. * 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.
  87757. * @returns a number indicating the current hardware scaling level
  87758. */
  87759. getHardwareScalingLevel(): number;
  87760. /**
  87761. * Gets the list of loaded textures
  87762. * @returns an array containing all loaded textures
  87763. */
  87764. getLoadedTexturesCache(): InternalTexture[];
  87765. /**
  87766. * Gets the object containing all engine capabilities
  87767. * @returns the EngineCapabilities object
  87768. */
  87769. getCaps(): EngineCapabilities;
  87770. /**
  87771. * Gets the current depth function
  87772. * @returns a number defining the depth function
  87773. */
  87774. getDepthFunction(): Nullable<number>;
  87775. /**
  87776. * Sets the current depth function
  87777. * @param depthFunc defines the function to use
  87778. */
  87779. setDepthFunction(depthFunc: number): void;
  87780. /**
  87781. * Sets the current depth function to GREATER
  87782. */
  87783. setDepthFunctionToGreater(): void;
  87784. /**
  87785. * Sets the current depth function to GEQUAL
  87786. */
  87787. setDepthFunctionToGreaterOrEqual(): void;
  87788. /**
  87789. * Sets the current depth function to LESS
  87790. */
  87791. setDepthFunctionToLess(): void;
  87792. private _cachedStencilBuffer;
  87793. private _cachedStencilFunction;
  87794. private _cachedStencilMask;
  87795. private _cachedStencilOperationPass;
  87796. private _cachedStencilOperationFail;
  87797. private _cachedStencilOperationDepthFail;
  87798. private _cachedStencilReference;
  87799. /**
  87800. * Caches the the state of the stencil buffer
  87801. */
  87802. cacheStencilState(): void;
  87803. /**
  87804. * Restores the state of the stencil buffer
  87805. */
  87806. restoreStencilState(): void;
  87807. /**
  87808. * Sets the current depth function to LEQUAL
  87809. */
  87810. setDepthFunctionToLessOrEqual(): void;
  87811. /**
  87812. * Gets a boolean indicating if stencil buffer is enabled
  87813. * @returns the current stencil buffer state
  87814. */
  87815. getStencilBuffer(): boolean;
  87816. /**
  87817. * Enable or disable the stencil buffer
  87818. * @param enable defines if the stencil buffer must be enabled or disabled
  87819. */
  87820. setStencilBuffer(enable: boolean): void;
  87821. /**
  87822. * Gets the current stencil mask
  87823. * @returns a number defining the new stencil mask to use
  87824. */
  87825. getStencilMask(): number;
  87826. /**
  87827. * Sets the current stencil mask
  87828. * @param mask defines the new stencil mask to use
  87829. */
  87830. setStencilMask(mask: number): void;
  87831. /**
  87832. * Gets the current stencil function
  87833. * @returns a number defining the stencil function to use
  87834. */
  87835. getStencilFunction(): number;
  87836. /**
  87837. * Gets the current stencil reference value
  87838. * @returns a number defining the stencil reference value to use
  87839. */
  87840. getStencilFunctionReference(): number;
  87841. /**
  87842. * Gets the current stencil mask
  87843. * @returns a number defining the stencil mask to use
  87844. */
  87845. getStencilFunctionMask(): number;
  87846. /**
  87847. * Sets the current stencil function
  87848. * @param stencilFunc defines the new stencil function to use
  87849. */
  87850. setStencilFunction(stencilFunc: number): void;
  87851. /**
  87852. * Sets the current stencil reference
  87853. * @param reference defines the new stencil reference to use
  87854. */
  87855. setStencilFunctionReference(reference: number): void;
  87856. /**
  87857. * Sets the current stencil mask
  87858. * @param mask defines the new stencil mask to use
  87859. */
  87860. setStencilFunctionMask(mask: number): void;
  87861. /**
  87862. * Gets the current stencil operation when stencil fails
  87863. * @returns a number defining stencil operation to use when stencil fails
  87864. */
  87865. getStencilOperationFail(): number;
  87866. /**
  87867. * Gets the current stencil operation when depth fails
  87868. * @returns a number defining stencil operation to use when depth fails
  87869. */
  87870. getStencilOperationDepthFail(): number;
  87871. /**
  87872. * Gets the current stencil operation when stencil passes
  87873. * @returns a number defining stencil operation to use when stencil passes
  87874. */
  87875. getStencilOperationPass(): number;
  87876. /**
  87877. * Sets the stencil operation to use when stencil fails
  87878. * @param operation defines the stencil operation to use when stencil fails
  87879. */
  87880. setStencilOperationFail(operation: number): void;
  87881. /**
  87882. * Sets the stencil operation to use when depth fails
  87883. * @param operation defines the stencil operation to use when depth fails
  87884. */
  87885. setStencilOperationDepthFail(operation: number): void;
  87886. /**
  87887. * Sets the stencil operation to use when stencil passes
  87888. * @param operation defines the stencil operation to use when stencil passes
  87889. */
  87890. setStencilOperationPass(operation: number): void;
  87891. /**
  87892. * Sets a boolean indicating if the dithering state is enabled or disabled
  87893. * @param value defines the dithering state
  87894. */
  87895. setDitheringState(value: boolean): void;
  87896. /**
  87897. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87898. * @param value defines the rasterizer state
  87899. */
  87900. setRasterizerState(value: boolean): void;
  87901. /**
  87902. * stop executing a render loop function and remove it from the execution array
  87903. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87904. */
  87905. stopRenderLoop(renderFunction?: () => void): void;
  87906. /** @hidden */
  87907. _renderLoop(): void;
  87908. /**
  87909. * Register and execute a render loop. The engine can have more than one render function
  87910. * @param renderFunction defines the function to continuously execute
  87911. */
  87912. runRenderLoop(renderFunction: () => void): void;
  87913. /**
  87914. * Toggle full screen mode
  87915. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87916. */
  87917. switchFullscreen(requestPointerLock: boolean): void;
  87918. /**
  87919. * Enters full screen mode
  87920. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87921. */
  87922. enterFullscreen(requestPointerLock: boolean): void;
  87923. /**
  87924. * Exits full screen mode
  87925. */
  87926. exitFullscreen(): void;
  87927. /**
  87928. * Clear the current render buffer or the current render target (if any is set up)
  87929. * @param color defines the color to use
  87930. * @param backBuffer defines if the back buffer must be cleared
  87931. * @param depth defines if the depth buffer must be cleared
  87932. * @param stencil defines if the stencil buffer must be cleared
  87933. */
  87934. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87935. /**
  87936. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87937. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87938. * @param y defines the y-coordinate of the corner of the clear rectangle
  87939. * @param width defines the width of the clear rectangle
  87940. * @param height defines the height of the clear rectangle
  87941. * @param clearColor defines the clear color
  87942. */
  87943. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87944. /**
  87945. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  87951. enableScissor(x: number, y: number, width: number, height: number): void;
  87952. /**
  87953. * Disable previously set scissor test rectangle
  87954. */
  87955. disableScissor(): void;
  87956. private _viewportCached;
  87957. /** @hidden */
  87958. _viewport(x: number, y: number, width: number, height: number): void;
  87959. /**
  87960. * Set the WebGL's viewport
  87961. * @param viewport defines the viewport element to be used
  87962. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87963. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87964. */
  87965. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87966. /**
  87967. * Directly set the WebGL Viewport
  87968. * @param x defines the x coordinate of the viewport (in screen space)
  87969. * @param y defines the y coordinate of the viewport (in screen space)
  87970. * @param width defines the width of the viewport (in screen space)
  87971. * @param height defines the height of the viewport (in screen space)
  87972. * @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
  87973. */
  87974. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87975. /**
  87976. * Begin a new frame
  87977. */
  87978. beginFrame(): void;
  87979. /**
  87980. * Enf the current frame
  87981. */
  87982. endFrame(): void;
  87983. /**
  87984. * Resize the view according to the canvas' size
  87985. */
  87986. resize(): void;
  87987. /**
  87988. * Force a specific size of the canvas
  87989. * @param width defines the new canvas' width
  87990. * @param height defines the new canvas' height
  87991. */
  87992. setSize(width: number, height: number): void;
  87993. /**
  87994. * Binds the frame buffer to the specified texture.
  87995. * @param texture The texture to render to or null for the default canvas
  87996. * @param faceIndex The face of the texture to render to in case of cube texture
  87997. * @param requiredWidth The width of the target to render to
  87998. * @param requiredHeight The height of the target to render to
  87999. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88000. * @param depthStencilTexture The depth stencil texture to use to render
  88001. * @param lodLevel defines le lod level to bind to the frame buffer
  88002. */
  88003. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88004. /** @hidden */
  88005. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88006. /**
  88007. * Unbind the current render target texture from the webGL context
  88008. * @param texture defines the render target texture to unbind
  88009. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88010. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88011. */
  88012. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88013. /**
  88014. * Force the mipmap generation for the given render target texture
  88015. * @param texture defines the render target texture to use
  88016. */
  88017. generateMipMapsForCubemap(texture: InternalTexture): void;
  88018. /**
  88019. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88020. */
  88021. flushFramebuffer(): void;
  88022. /**
  88023. * Unbind the current render target and bind the default framebuffer
  88024. */
  88025. restoreDefaultFramebuffer(): void;
  88026. /**
  88027. * Create an uniform buffer
  88028. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88029. * @param elements defines the content of the uniform buffer
  88030. * @returns the webGL uniform buffer
  88031. */
  88032. createUniformBuffer(elements: FloatArray): DataBuffer;
  88033. /**
  88034. * Create a dynamic uniform buffer
  88035. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88036. * @param elements defines the content of the uniform buffer
  88037. * @returns the webGL uniform buffer
  88038. */
  88039. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88040. /**
  88041. * Update an existing uniform buffer
  88042. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88043. * @param uniformBuffer defines the target uniform buffer
  88044. * @param elements defines the content to update
  88045. * @param offset defines the offset in the uniform buffer where update should start
  88046. * @param count defines the size of the data to update
  88047. */
  88048. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88049. private _resetVertexBufferBinding;
  88050. /**
  88051. * Creates a vertex buffer
  88052. * @param data the data for the vertex buffer
  88053. * @returns the new WebGL static buffer
  88054. */
  88055. createVertexBuffer(data: DataArray): DataBuffer;
  88056. /**
  88057. * Creates a dynamic vertex buffer
  88058. * @param data the data for the dynamic vertex buffer
  88059. * @returns the new WebGL dynamic buffer
  88060. */
  88061. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88062. /**
  88063. * Update a dynamic index buffer
  88064. * @param indexBuffer defines the target index buffer
  88065. * @param indices defines the data to update
  88066. * @param offset defines the offset in the target index buffer where update should start
  88067. */
  88068. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88069. /**
  88070. * Updates a dynamic vertex buffer.
  88071. * @param vertexBuffer the vertex buffer to update
  88072. * @param data the data used to update the vertex buffer
  88073. * @param byteOffset the byte offset of the data
  88074. * @param byteLength the byte length of the data
  88075. */
  88076. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88077. private _resetIndexBufferBinding;
  88078. /**
  88079. * Creates a new index buffer
  88080. * @param indices defines the content of the index buffer
  88081. * @param updatable defines if the index buffer must be updatable
  88082. * @returns a new webGL buffer
  88083. */
  88084. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88085. /**
  88086. * Bind a webGL buffer to the webGL context
  88087. * @param buffer defines the buffer to bind
  88088. */
  88089. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88090. /**
  88091. * Bind an uniform buffer to the current webGL context
  88092. * @param buffer defines the buffer to bind
  88093. */
  88094. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88095. /**
  88096. * Bind a buffer to the current webGL context at a given location
  88097. * @param buffer defines the buffer to bind
  88098. * @param location defines the index where to bind the buffer
  88099. */
  88100. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88101. /**
  88102. * Bind a specific block at a given index in a specific shader program
  88103. * @param pipelineContext defines the pipeline context to use
  88104. * @param blockName defines the block name
  88105. * @param index defines the index where to bind the block
  88106. */
  88107. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88108. private bindIndexBuffer;
  88109. private bindBuffer;
  88110. /**
  88111. * update the bound buffer with the given data
  88112. * @param data defines the data to update
  88113. */
  88114. updateArrayBuffer(data: Float32Array): void;
  88115. private _vertexAttribPointer;
  88116. private _bindIndexBufferWithCache;
  88117. private _bindVertexBuffersAttributes;
  88118. /**
  88119. * Records a vertex array object
  88120. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88121. * @param vertexBuffers defines the list of vertex buffers to store
  88122. * @param indexBuffer defines the index buffer to store
  88123. * @param effect defines the effect to store
  88124. * @returns the new vertex array object
  88125. */
  88126. recordVertexArrayObject(vertexBuffers: {
  88127. [key: string]: VertexBuffer;
  88128. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88129. /**
  88130. * Bind a specific vertex array object
  88131. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88132. * @param vertexArrayObject defines the vertex array object to bind
  88133. * @param indexBuffer defines the index buffer to bind
  88134. */
  88135. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88136. /**
  88137. * Bind webGl buffers directly to the webGL context
  88138. * @param vertexBuffer defines the vertex buffer to bind
  88139. * @param indexBuffer defines the index buffer to bind
  88140. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88141. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88142. * @param effect defines the effect associated with the vertex buffer
  88143. */
  88144. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88145. private _unbindVertexArrayObject;
  88146. /**
  88147. * Bind a list of vertex buffers to the webGL context
  88148. * @param vertexBuffers defines the list of vertex buffers to bind
  88149. * @param indexBuffer defines the index buffer to bind
  88150. * @param effect defines the effect associated with the vertex buffers
  88151. */
  88152. bindBuffers(vertexBuffers: {
  88153. [key: string]: Nullable<VertexBuffer>;
  88154. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88155. /**
  88156. * Unbind all instance attributes
  88157. */
  88158. unbindInstanceAttributes(): void;
  88159. /**
  88160. * Release and free the memory of a vertex array object
  88161. * @param vao defines the vertex array object to delete
  88162. */
  88163. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88164. /** @hidden */
  88165. _releaseBuffer(buffer: DataBuffer): boolean;
  88166. /**
  88167. * Creates a webGL buffer to use with instanciation
  88168. * @param capacity defines the size of the buffer
  88169. * @returns the webGL buffer
  88170. */
  88171. createInstancesBuffer(capacity: number): DataBuffer;
  88172. /**
  88173. * Delete a webGL buffer used with instanciation
  88174. * @param buffer defines the webGL buffer to delete
  88175. */
  88176. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88177. /**
  88178. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88179. * @param instancesBuffer defines the webGL buffer to update and bind
  88180. * @param data defines the data to store in the buffer
  88181. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88182. */
  88183. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88184. /**
  88185. * Apply all cached states (depth, culling, stencil and alpha)
  88186. */
  88187. applyStates(): void;
  88188. /**
  88189. * Send a draw order
  88190. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88191. * @param indexStart defines the starting index
  88192. * @param indexCount defines the number of index to draw
  88193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88194. */
  88195. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88196. /**
  88197. * Draw a list of points
  88198. * @param verticesStart defines the index of first vertex to draw
  88199. * @param verticesCount defines the count of vertices to draw
  88200. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88201. */
  88202. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88203. /**
  88204. * Draw a list of unindexed primitives
  88205. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88206. * @param verticesStart defines the index of first vertex to draw
  88207. * @param verticesCount defines the count of vertices to draw
  88208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88209. */
  88210. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88211. /**
  88212. * Draw a list of indexed primitives
  88213. * @param fillMode defines the primitive to use
  88214. * @param indexStart defines the starting index
  88215. * @param indexCount defines the number of index to draw
  88216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88217. */
  88218. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88219. /**
  88220. * Draw a list of unindexed primitives
  88221. * @param fillMode defines the primitive to use
  88222. * @param verticesStart defines the index of first vertex to draw
  88223. * @param verticesCount defines the count of vertices to draw
  88224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88225. */
  88226. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88227. private _drawMode;
  88228. /** @hidden */
  88229. _releaseEffect(effect: Effect): void;
  88230. /** @hidden */
  88231. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88232. /**
  88233. * Create a new effect (used to store vertex/fragment shaders)
  88234. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88235. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88236. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88237. * @param samplers defines an array of string used to represent textures
  88238. * @param defines defines the string containing the defines to use to compile the shaders
  88239. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88240. * @param onCompiled defines a function to call when the effect creation is successful
  88241. * @param onError defines a function to call when the effect creation has failed
  88242. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88243. * @returns the new Effect
  88244. */
  88245. 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;
  88246. private _compileShader;
  88247. private _compileRawShader;
  88248. /**
  88249. * Directly creates a webGL program
  88250. * @param pipelineContext defines the pipeline context to attach to
  88251. * @param vertexCode defines the vertex shader code to use
  88252. * @param fragmentCode defines the fragment shader code to use
  88253. * @param context defines the webGL context to use (if not set, the current one will be used)
  88254. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88255. * @returns the new webGL program
  88256. */
  88257. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88258. /**
  88259. * Creates a webGL program
  88260. * @param pipelineContext defines the pipeline context to attach to
  88261. * @param vertexCode defines the vertex shader code to use
  88262. * @param fragmentCode defines the fragment shader code to use
  88263. * @param defines defines the string containing the defines to use to compile the shaders
  88264. * @param context defines the webGL context to use (if not set, the current one will be used)
  88265. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88266. * @returns the new webGL program
  88267. */
  88268. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88269. /**
  88270. * Creates a new pipeline context
  88271. * @returns the new pipeline
  88272. */
  88273. createPipelineContext(): WebGLPipelineContext;
  88274. private _createShaderProgram;
  88275. private _finalizePipelineContext;
  88276. /** @hidden */
  88277. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88278. /** @hidden */
  88279. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88280. /** @hidden */
  88281. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88282. /**
  88283. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88284. * @param pipelineContext defines the pipeline context to use
  88285. * @param uniformsNames defines the list of uniform names
  88286. * @returns an array of webGL uniform locations
  88287. */
  88288. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88289. /**
  88290. * Gets the lsit of active attributes for a given webGL program
  88291. * @param pipelineContext defines the pipeline context to use
  88292. * @param attributesNames defines the list of attribute names to get
  88293. * @returns an array of indices indicating the offset of each attribute
  88294. */
  88295. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88296. /**
  88297. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88298. * @param effect defines the effect to activate
  88299. */
  88300. enableEffect(effect: Nullable<Effect>): void;
  88301. /**
  88302. * Set the value of an uniform to an array of int32
  88303. * @param uniform defines the webGL uniform location where to store the value
  88304. * @param array defines the array of int32 to store
  88305. */
  88306. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88307. /**
  88308. * Set the value of an uniform to an array of int32 (stored as vec2)
  88309. * @param uniform defines the webGL uniform location where to store the value
  88310. * @param array defines the array of int32 to store
  88311. */
  88312. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88313. /**
  88314. * Set the value of an uniform to an array of int32 (stored as vec3)
  88315. * @param uniform defines the webGL uniform location where to store the value
  88316. * @param array defines the array of int32 to store
  88317. */
  88318. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88319. /**
  88320. * Set the value of an uniform to an array of int32 (stored as vec4)
  88321. * @param uniform defines the webGL uniform location where to store the value
  88322. * @param array defines the array of int32 to store
  88323. */
  88324. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88325. /**
  88326. * Set the value of an uniform to an array of float32
  88327. * @param uniform defines the webGL uniform location where to store the value
  88328. * @param array defines the array of float32 to store
  88329. */
  88330. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88331. /**
  88332. * Set the value of an uniform to an array of float32 (stored as vec2)
  88333. * @param uniform defines the webGL uniform location where to store the value
  88334. * @param array defines the array of float32 to store
  88335. */
  88336. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88337. /**
  88338. * Set the value of an uniform to an array of float32 (stored as vec3)
  88339. * @param uniform defines the webGL uniform location where to store the value
  88340. * @param array defines the array of float32 to store
  88341. */
  88342. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88343. /**
  88344. * Set the value of an uniform to an array of float32 (stored as vec4)
  88345. * @param uniform defines the webGL uniform location where to store the value
  88346. * @param array defines the array of float32 to store
  88347. */
  88348. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88349. /**
  88350. * Set the value of an uniform to an array of number
  88351. * @param uniform defines the webGL uniform location where to store the value
  88352. * @param array defines the array of number to store
  88353. */
  88354. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88355. /**
  88356. * Set the value of an uniform to an array of number (stored as vec2)
  88357. * @param uniform defines the webGL uniform location where to store the value
  88358. * @param array defines the array of number to store
  88359. */
  88360. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88361. /**
  88362. * Set the value of an uniform to an array of number (stored as vec3)
  88363. * @param uniform defines the webGL uniform location where to store the value
  88364. * @param array defines the array of number to store
  88365. */
  88366. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88367. /**
  88368. * Set the value of an uniform to an array of number (stored as vec4)
  88369. * @param uniform defines the webGL uniform location where to store the value
  88370. * @param array defines the array of number to store
  88371. */
  88372. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88373. /**
  88374. * Set the value of an uniform to an array of float32 (stored as matrices)
  88375. * @param uniform defines the webGL uniform location where to store the value
  88376. * @param matrices defines the array of float32 to store
  88377. */
  88378. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88379. /**
  88380. * Set the value of an uniform to a matrix
  88381. * @param uniform defines the webGL uniform location where to store the value
  88382. * @param matrix defines the matrix to store
  88383. */
  88384. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88385. /**
  88386. * Set the value of an uniform to a matrix (3x3)
  88387. * @param uniform defines the webGL uniform location where to store the value
  88388. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88389. */
  88390. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88391. /**
  88392. * Set the value of an uniform to a matrix (2x2)
  88393. * @param uniform defines the webGL uniform location where to store the value
  88394. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88395. */
  88396. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88397. /**
  88398. * Set the value of an uniform to a number (int)
  88399. * @param uniform defines the webGL uniform location where to store the value
  88400. * @param value defines the int number to store
  88401. */
  88402. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88403. /**
  88404. * Set the value of an uniform to a number (float)
  88405. * @param uniform defines the webGL uniform location where to store the value
  88406. * @param value defines the float number to store
  88407. */
  88408. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88409. /**
  88410. * Set the value of an uniform to a vec2
  88411. * @param uniform defines the webGL uniform location where to store the value
  88412. * @param x defines the 1st component of the value
  88413. * @param y defines the 2nd component of the value
  88414. */
  88415. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88416. /**
  88417. * Set the value of an uniform to a vec3
  88418. * @param uniform defines the webGL uniform location where to store the value
  88419. * @param x defines the 1st component of the value
  88420. * @param y defines the 2nd component of the value
  88421. * @param z defines the 3rd component of the value
  88422. */
  88423. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88424. /**
  88425. * Set the value of an uniform to a boolean
  88426. * @param uniform defines the webGL uniform location where to store the value
  88427. * @param bool defines the boolean to store
  88428. */
  88429. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88430. /**
  88431. * Set the value of an uniform to a vec4
  88432. * @param uniform defines the webGL uniform location where to store the value
  88433. * @param x defines the 1st component of the value
  88434. * @param y defines the 2nd component of the value
  88435. * @param z defines the 3rd component of the value
  88436. * @param w defines the 4th component of the value
  88437. */
  88438. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88439. /**
  88440. * Set the value of an uniform to a Color3
  88441. * @param uniform defines the webGL uniform location where to store the value
  88442. * @param color3 defines the color to store
  88443. */
  88444. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88445. /**
  88446. * Set the value of an uniform to a Color3 and an alpha value
  88447. * @param uniform defines the webGL uniform location where to store the value
  88448. * @param color3 defines the color to store
  88449. * @param alpha defines the alpha component to store
  88450. */
  88451. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88452. /**
  88453. * Sets a Color4 on a uniform variable
  88454. * @param uniform defines the uniform location
  88455. * @param color4 defines the value to be set
  88456. */
  88457. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88458. /**
  88459. * Set various states to the webGL context
  88460. * @param culling defines backface culling state
  88461. * @param zOffset defines the value to apply to zOffset (0 by default)
  88462. * @param force defines if states must be applied even if cache is up to date
  88463. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88464. */
  88465. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88466. /**
  88467. * Set the z offset to apply to current rendering
  88468. * @param value defines the offset to apply
  88469. */
  88470. setZOffset(value: number): void;
  88471. /**
  88472. * Gets the current value of the zOffset
  88473. * @returns the current zOffset state
  88474. */
  88475. getZOffset(): number;
  88476. /**
  88477. * Enable or disable depth buffering
  88478. * @param enable defines the state to set
  88479. */
  88480. setDepthBuffer(enable: boolean): void;
  88481. /**
  88482. * Gets a boolean indicating if depth writing is enabled
  88483. * @returns the current depth writing state
  88484. */
  88485. getDepthWrite(): boolean;
  88486. /**
  88487. * Enable or disable depth writing
  88488. * @param enable defines the state to set
  88489. */
  88490. setDepthWrite(enable: boolean): void;
  88491. /**
  88492. * Enable or disable color writing
  88493. * @param enable defines the state to set
  88494. */
  88495. setColorWrite(enable: boolean): void;
  88496. /**
  88497. * Gets a boolean indicating if color writing is enabled
  88498. * @returns the current color writing state
  88499. */
  88500. getColorWrite(): boolean;
  88501. /**
  88502. * Sets alpha constants used by some alpha blending modes
  88503. * @param r defines the red component
  88504. * @param g defines the green component
  88505. * @param b defines the blue component
  88506. * @param a defines the alpha component
  88507. */
  88508. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88509. /**
  88510. * Sets the current alpha mode
  88511. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88514. */
  88515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88516. /**
  88517. * Gets the current alpha mode
  88518. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88519. * @returns the current alpha mode
  88520. */
  88521. getAlphaMode(): number;
  88522. /**
  88523. * Clears the list of texture accessible through engine.
  88524. * This can help preventing texture load conflict due to name collision.
  88525. */
  88526. clearInternalTexturesCache(): void;
  88527. /**
  88528. * Force the entire cache to be cleared
  88529. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88530. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88531. */
  88532. wipeCaches(bruteForce?: boolean): void;
  88533. /**
  88534. * Set the compressed texture format to use, based on the formats you have, and the formats
  88535. * supported by the hardware / browser.
  88536. *
  88537. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88538. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88539. * to API arguments needed to compressed textures. This puts the burden on the container
  88540. * generator to house the arcane code for determining these for current & future formats.
  88541. *
  88542. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88543. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88544. *
  88545. * Note: The result of this call is not taken into account when a texture is base64.
  88546. *
  88547. * @param formatsAvailable defines the list of those format families you have created
  88548. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88549. *
  88550. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88551. * @returns The extension selected.
  88552. */
  88553. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88554. /** @hidden */
  88555. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88556. min: number;
  88557. mag: number;
  88558. };
  88559. /** @hidden */
  88560. _createTexture(): WebGLTexture;
  88561. /**
  88562. * Usually called from Texture.ts.
  88563. * Passed information to create a WebGLTexture
  88564. * @param urlArg defines a value which contains one of the following:
  88565. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88566. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88567. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88569. * @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)
  88570. * @param scene needed for loading to the correct scene
  88571. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88572. * @param onLoad optional callback to be called upon successful completion
  88573. * @param onError optional callback to be called upon failure
  88574. * @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
  88575. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88576. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88577. * @param forcedExtension defines the extension to use to pick the right loader
  88578. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88579. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88580. */
  88581. 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;
  88582. private _rescaleTexture;
  88583. private _unpackFlipYCached;
  88584. /**
  88585. * In case you are sharing the context with other applications, it might
  88586. * be interested to not cache the unpack flip y state to ensure a consistent
  88587. * value would be set.
  88588. */
  88589. enableUnpackFlipYCached: boolean;
  88590. /** @hidden */
  88591. _unpackFlipY(value: boolean): void;
  88592. /** @hidden */
  88593. _getUnpackAlignement(): number;
  88594. /**
  88595. * Creates a dynamic texture
  88596. * @param width defines the width of the texture
  88597. * @param height defines the height of the texture
  88598. * @param generateMipMaps defines if the engine should generate the mip levels
  88599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88600. * @returns the dynamic texture inside an InternalTexture
  88601. */
  88602. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88603. /**
  88604. * Update the sampling mode of a given texture
  88605. * @param samplingMode defines the required sampling mode
  88606. * @param texture defines the texture to update
  88607. */
  88608. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88609. /**
  88610. * Update the content of a dynamic texture
  88611. * @param texture defines the texture to update
  88612. * @param canvas defines the canvas containing the source
  88613. * @param invertY defines if data must be stored with Y axis inverted
  88614. * @param premulAlpha defines if alpha is stored as premultiplied
  88615. * @param format defines the format of the data
  88616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88617. */
  88618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88619. /**
  88620. * Update a video texture
  88621. * @param texture defines the texture to update
  88622. * @param video defines the video element to use
  88623. * @param invertY defines if data must be stored with Y axis inverted
  88624. */
  88625. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88626. /**
  88627. * Updates a depth texture Comparison Mode and Function.
  88628. * If the comparison Function is equal to 0, the mode will be set to none.
  88629. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88630. * @param texture The texture to set the comparison function for
  88631. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88632. */
  88633. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88634. /** @hidden */
  88635. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88636. width: number;
  88637. height: number;
  88638. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88639. /**
  88640. * Creates a depth stencil texture.
  88641. * This is only available in WebGL 2 or with the depth texture extension available.
  88642. * @param size The size of face edge in the texture.
  88643. * @param options The options defining the texture.
  88644. * @returns The texture
  88645. */
  88646. createDepthStencilTexture(size: number | {
  88647. width: number;
  88648. height: number;
  88649. }, options: DepthTextureCreationOptions): InternalTexture;
  88650. /**
  88651. * Creates a depth stencil texture.
  88652. * This is only available in WebGL 2 or with the depth texture extension available.
  88653. * @param size The size of face edge in the texture.
  88654. * @param options The options defining the texture.
  88655. * @returns The texture
  88656. */
  88657. private _createDepthStencilTexture;
  88658. /**
  88659. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88660. * @param renderTarget The render target to set the frame buffer for
  88661. */
  88662. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88663. /**
  88664. * Creates a new render target texture
  88665. * @param size defines the size of the texture
  88666. * @param options defines the options used to create the texture
  88667. * @returns a new render target texture stored in an InternalTexture
  88668. */
  88669. createRenderTargetTexture(size: number | {
  88670. width: number;
  88671. height: number;
  88672. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88673. /** @hidden */
  88674. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88675. /**
  88676. * Updates the sample count of a render target texture
  88677. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88678. * @param texture defines the texture to update
  88679. * @param samples defines the sample count to set
  88680. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88681. */
  88682. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88683. /** @hidden */
  88684. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88685. /** @hidden */
  88686. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88687. /** @hidden */
  88688. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88689. /** @hidden */
  88690. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88691. /**
  88692. * @hidden
  88693. */
  88694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88695. private _prepareWebGLTextureContinuation;
  88696. private _prepareWebGLTexture;
  88697. /** @hidden */
  88698. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88699. /** @hidden */
  88700. _releaseFramebufferObjects(texture: InternalTexture): void;
  88701. /** @hidden */
  88702. _releaseTexture(texture: InternalTexture): void;
  88703. private setProgram;
  88704. private _boundUniforms;
  88705. /**
  88706. * Binds an effect to the webGL context
  88707. * @param effect defines the effect to bind
  88708. */
  88709. bindSamplers(effect: Effect): void;
  88710. private _activateCurrentTexture;
  88711. /** @hidden */
  88712. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88713. /** @hidden */
  88714. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88715. /**
  88716. * Sets a texture to the webGL context from a postprocess
  88717. * @param channel defines the channel to use
  88718. * @param postProcess defines the source postprocess
  88719. */
  88720. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88721. /**
  88722. * Binds the output of the passed in post process to the texture channel specified
  88723. * @param channel The channel the texture should be bound to
  88724. * @param postProcess The post process which's output should be bound
  88725. */
  88726. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88727. /**
  88728. * Unbind all textures from the webGL context
  88729. */
  88730. unbindAllTextures(): void;
  88731. /**
  88732. * Sets a texture to the according uniform.
  88733. * @param channel The texture channel
  88734. * @param uniform The uniform to set
  88735. * @param texture The texture to apply
  88736. */
  88737. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88738. /**
  88739. * Sets a depth stencil texture from a render target to the according uniform.
  88740. * @param channel The texture channel
  88741. * @param uniform The uniform to set
  88742. * @param texture The render target texture containing the depth stencil texture to apply
  88743. */
  88744. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88745. private _bindSamplerUniformToChannel;
  88746. private _getTextureWrapMode;
  88747. private _setTexture;
  88748. /**
  88749. * Sets an array of texture to the webGL context
  88750. * @param channel defines the channel where the texture array must be set
  88751. * @param uniform defines the associated uniform location
  88752. * @param textures defines the array of textures to bind
  88753. */
  88754. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88755. /** @hidden */
  88756. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88757. private _setTextureParameterFloat;
  88758. private _setTextureParameterInteger;
  88759. /**
  88760. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88761. * @param x defines the x coordinate of the rectangle where pixels must be read
  88762. * @param y defines the y coordinate of the rectangle where pixels must be read
  88763. * @param width defines the width of the rectangle where pixels must be read
  88764. * @param height defines the height of the rectangle where pixels must be read
  88765. * @returns a Uint8Array containing RGBA colors
  88766. */
  88767. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88768. /**
  88769. * Add an externaly attached data from its key.
  88770. * This method call will fail and return false, if such key already exists.
  88771. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88772. * @param key the unique key that identifies the data
  88773. * @param data the data object to associate to the key for this Engine instance
  88774. * @return true if no such key were already present and the data was added successfully, false otherwise
  88775. */
  88776. addExternalData<T>(key: string, data: T): boolean;
  88777. /**
  88778. * Get an externaly attached data from its key
  88779. * @param key the unique key that identifies the data
  88780. * @return the associated data, if present (can be null), or undefined if not present
  88781. */
  88782. getExternalData<T>(key: string): T;
  88783. /**
  88784. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88785. * @param key the unique key that identifies the data
  88786. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88787. * @return the associated data, can be null if the factory returned null.
  88788. */
  88789. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88790. /**
  88791. * Remove an externaly attached data from the Engine instance
  88792. * @param key the unique key that identifies the data
  88793. * @return true if the data was successfully removed, false if it doesn't exist
  88794. */
  88795. removeExternalData(key: string): boolean;
  88796. /**
  88797. * Unbind all vertex attributes from the webGL context
  88798. */
  88799. unbindAllAttributes(): void;
  88800. /**
  88801. * 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
  88802. */
  88803. releaseEffects(): void;
  88804. /**
  88805. * Dispose and release all associated resources
  88806. */
  88807. dispose(): void;
  88808. /**
  88809. * Display the loading screen
  88810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88811. */
  88812. displayLoadingUI(): void;
  88813. /**
  88814. * Hide the loading screen
  88815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88816. */
  88817. hideLoadingUI(): void;
  88818. /**
  88819. * Gets the current loading screen object
  88820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88821. */
  88822. /**
  88823. * Sets the current loading screen object
  88824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88825. */
  88826. loadingScreen: ILoadingScreen;
  88827. /**
  88828. * Sets the current loading screen text
  88829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88830. */
  88831. loadingUIText: string;
  88832. /**
  88833. * Sets the current loading screen background color
  88834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88835. */
  88836. loadingUIBackgroundColor: string;
  88837. /**
  88838. * Attach a new callback raised when context lost event is fired
  88839. * @param callback defines the callback to call
  88840. */
  88841. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88842. /**
  88843. * Attach a new callback raised when context restored event is fired
  88844. * @param callback defines the callback to call
  88845. */
  88846. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88847. /**
  88848. * Gets the source code of the vertex shader associated with a specific webGL program
  88849. * @param program defines the program to use
  88850. * @returns a string containing the source code of the vertex shader associated with the program
  88851. */
  88852. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88853. /**
  88854. * Gets the source code of the fragment shader associated with a specific webGL program
  88855. * @param program defines the program to use
  88856. * @returns a string containing the source code of the fragment shader associated with the program
  88857. */
  88858. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88859. /**
  88860. * Get the current error code of the webGL context
  88861. * @returns the error code
  88862. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88863. */
  88864. getError(): number;
  88865. /**
  88866. * Gets the current framerate
  88867. * @returns a number representing the framerate
  88868. */
  88869. getFps(): number;
  88870. /**
  88871. * Gets the time spent between current and previous frame
  88872. * @returns a number representing the delta time in ms
  88873. */
  88874. getDeltaTime(): number;
  88875. private _measureFps;
  88876. /** @hidden */
  88877. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88878. private _canRenderToFloatFramebuffer;
  88879. private _canRenderToHalfFloatFramebuffer;
  88880. private _canRenderToFramebuffer;
  88881. /** @hidden */
  88882. _getWebGLTextureType(type: number): number;
  88883. /** @hidden */
  88884. _getInternalFormat(format: number): number;
  88885. /** @hidden */
  88886. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88887. /** @hidden */
  88888. _getRGBAMultiSampleBufferFormat(type: number): number;
  88889. /** @hidden */
  88890. _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;
  88891. /** @hidden */
  88892. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88893. /**
  88894. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88895. * @returns true if the engine can be created
  88896. * @ignorenaming
  88897. */
  88898. static isSupported(): boolean;
  88899. }
  88900. }
  88901. declare module BABYLON {
  88902. /**
  88903. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88904. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88905. */
  88906. export class EffectFallbacks {
  88907. private _defines;
  88908. private _currentRank;
  88909. private _maxRank;
  88910. private _mesh;
  88911. /**
  88912. * Removes the fallback from the bound mesh.
  88913. */
  88914. unBindMesh(): void;
  88915. /**
  88916. * Adds a fallback on the specified property.
  88917. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88918. * @param define The name of the define in the shader
  88919. */
  88920. addFallback(rank: number, define: string): void;
  88921. /**
  88922. * Sets the mesh to use CPU skinning when needing to fallback.
  88923. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88924. * @param mesh The mesh to use the fallbacks.
  88925. */
  88926. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88927. /**
  88928. * Checks to see if more fallbacks are still availible.
  88929. */
  88930. readonly isMoreFallbacks: boolean;
  88931. /**
  88932. * Removes the defines that shoould be removed when falling back.
  88933. * @param currentDefines defines the current define statements for the shader.
  88934. * @param effect defines the current effect we try to compile
  88935. * @returns The resulting defines with defines of the current rank removed.
  88936. */
  88937. reduce(currentDefines: string, effect: Effect): string;
  88938. }
  88939. /**
  88940. * Options to be used when creating an effect.
  88941. */
  88942. export class EffectCreationOptions {
  88943. /**
  88944. * Atrributes that will be used in the shader.
  88945. */
  88946. attributes: string[];
  88947. /**
  88948. * Uniform varible names that will be set in the shader.
  88949. */
  88950. uniformsNames: string[];
  88951. /**
  88952. * Uniform buffer varible names that will be set in the shader.
  88953. */
  88954. uniformBuffersNames: string[];
  88955. /**
  88956. * Sampler texture variable names that will be set in the shader.
  88957. */
  88958. samplers: string[];
  88959. /**
  88960. * Define statements that will be set in the shader.
  88961. */
  88962. defines: any;
  88963. /**
  88964. * Possible fallbacks for this effect to improve performance when needed.
  88965. */
  88966. fallbacks: Nullable<EffectFallbacks>;
  88967. /**
  88968. * Callback that will be called when the shader is compiled.
  88969. */
  88970. onCompiled: Nullable<(effect: Effect) => void>;
  88971. /**
  88972. * Callback that will be called if an error occurs during shader compilation.
  88973. */
  88974. onError: Nullable<(effect: Effect, errors: string) => void>;
  88975. /**
  88976. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88977. */
  88978. indexParameters: any;
  88979. /**
  88980. * Max number of lights that can be used in the shader.
  88981. */
  88982. maxSimultaneousLights: number;
  88983. /**
  88984. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88985. */
  88986. transformFeedbackVaryings: Nullable<string[]>;
  88987. }
  88988. /**
  88989. * Effect containing vertex and fragment shader that can be executed on an object.
  88990. */
  88991. export class Effect implements IDisposable {
  88992. /**
  88993. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88994. */
  88995. static ShadersRepository: string;
  88996. /**
  88997. * Name of the effect.
  88998. */
  88999. name: any;
  89000. /**
  89001. * String container all the define statements that should be set on the shader.
  89002. */
  89003. defines: string;
  89004. /**
  89005. * Callback that will be called when the shader is compiled.
  89006. */
  89007. onCompiled: Nullable<(effect: Effect) => void>;
  89008. /**
  89009. * Callback that will be called if an error occurs during shader compilation.
  89010. */
  89011. onError: Nullable<(effect: Effect, errors: string) => void>;
  89012. /**
  89013. * Callback that will be called when effect is bound.
  89014. */
  89015. onBind: Nullable<(effect: Effect) => void>;
  89016. /**
  89017. * Unique ID of the effect.
  89018. */
  89019. uniqueId: number;
  89020. /**
  89021. * Observable that will be called when the shader is compiled.
  89022. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89023. */
  89024. onCompileObservable: Observable<Effect>;
  89025. /**
  89026. * Observable that will be called if an error occurs during shader compilation.
  89027. */
  89028. onErrorObservable: Observable<Effect>;
  89029. /** @hidden */
  89030. _onBindObservable: Nullable<Observable<Effect>>;
  89031. /**
  89032. * Observable that will be called when effect is bound.
  89033. */
  89034. readonly onBindObservable: Observable<Effect>;
  89035. /** @hidden */
  89036. _bonesComputationForcedToCPU: boolean;
  89037. private static _uniqueIdSeed;
  89038. private _engine;
  89039. private _uniformBuffersNames;
  89040. private _uniformsNames;
  89041. private _samplerList;
  89042. private _samplers;
  89043. private _isReady;
  89044. private _compilationError;
  89045. private _attributesNames;
  89046. private _attributes;
  89047. private _uniforms;
  89048. /**
  89049. * Key for the effect.
  89050. * @hidden
  89051. */
  89052. _key: string;
  89053. private _indexParameters;
  89054. private _fallbacks;
  89055. private _vertexSourceCode;
  89056. private _fragmentSourceCode;
  89057. private _vertexSourceCodeOverride;
  89058. private _fragmentSourceCodeOverride;
  89059. private _transformFeedbackVaryings;
  89060. /**
  89061. * Compiled shader to webGL program.
  89062. * @hidden
  89063. */
  89064. _pipelineContext: Nullable<IPipelineContext>;
  89065. private _valueCache;
  89066. private static _baseCache;
  89067. /**
  89068. * Instantiates an effect.
  89069. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89070. * @param baseName Name of the effect.
  89071. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89072. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89073. * @param samplers List of sampler variables that will be passed to the shader.
  89074. * @param engine Engine to be used to render the effect
  89075. * @param defines Define statements to be added to the shader.
  89076. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89077. * @param onCompiled Callback that will be called when the shader is compiled.
  89078. * @param onError Callback that will be called if an error occurs during shader compilation.
  89079. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89080. */
  89081. 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);
  89082. /**
  89083. * Unique key for this effect
  89084. */
  89085. readonly key: string;
  89086. /**
  89087. * If the effect has been compiled and prepared.
  89088. * @returns if the effect is compiled and prepared.
  89089. */
  89090. isReady(): boolean;
  89091. /**
  89092. * The engine the effect was initialized with.
  89093. * @returns the engine.
  89094. */
  89095. getEngine(): Engine;
  89096. /**
  89097. * The pipeline context for this effect
  89098. * @returns the associated pipeline context
  89099. */
  89100. getPipelineContext(): Nullable<IPipelineContext>;
  89101. /**
  89102. * The set of names of attribute variables for the shader.
  89103. * @returns An array of attribute names.
  89104. */
  89105. getAttributesNames(): string[];
  89106. /**
  89107. * Returns the attribute at the given index.
  89108. * @param index The index of the attribute.
  89109. * @returns The location of the attribute.
  89110. */
  89111. getAttributeLocation(index: number): number;
  89112. /**
  89113. * Returns the attribute based on the name of the variable.
  89114. * @param name of the attribute to look up.
  89115. * @returns the attribute location.
  89116. */
  89117. getAttributeLocationByName(name: string): number;
  89118. /**
  89119. * The number of attributes.
  89120. * @returns the numnber of attributes.
  89121. */
  89122. getAttributesCount(): number;
  89123. /**
  89124. * Gets the index of a uniform variable.
  89125. * @param uniformName of the uniform to look up.
  89126. * @returns the index.
  89127. */
  89128. getUniformIndex(uniformName: string): number;
  89129. /**
  89130. * Returns the attribute based on the name of the variable.
  89131. * @param uniformName of the uniform to look up.
  89132. * @returns the location of the uniform.
  89133. */
  89134. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89135. /**
  89136. * Returns an array of sampler variable names
  89137. * @returns The array of sampler variable neames.
  89138. */
  89139. getSamplers(): string[];
  89140. /**
  89141. * The error from the last compilation.
  89142. * @returns the error string.
  89143. */
  89144. getCompilationError(): string;
  89145. /**
  89146. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89147. * @param func The callback to be used.
  89148. */
  89149. executeWhenCompiled(func: (effect: Effect) => void): void;
  89150. private _checkIsReady;
  89151. /** @hidden */
  89152. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89153. /** @hidden */
  89154. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89155. /** @hidden */
  89156. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89157. private _processShaderConversion;
  89158. private _processIncludes;
  89159. private _processPrecision;
  89160. /**
  89161. * Recompiles the webGL program
  89162. * @param vertexSourceCode The source code for the vertex shader.
  89163. * @param fragmentSourceCode The source code for the fragment shader.
  89164. * @param onCompiled Callback called when completed.
  89165. * @param onError Callback called on error.
  89166. * @hidden
  89167. */
  89168. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89169. /**
  89170. * Prepares the effect
  89171. * @hidden
  89172. */
  89173. _prepareEffect(): void;
  89174. /**
  89175. * Checks if the effect is supported. (Must be called after compilation)
  89176. */
  89177. readonly isSupported: boolean;
  89178. /**
  89179. * Binds a texture to the engine to be used as output of the shader.
  89180. * @param channel Name of the output variable.
  89181. * @param texture Texture to bind.
  89182. * @hidden
  89183. */
  89184. _bindTexture(channel: string, texture: InternalTexture): void;
  89185. /**
  89186. * Sets a texture on the engine to be used in the shader.
  89187. * @param channel Name of the sampler variable.
  89188. * @param texture Texture to set.
  89189. */
  89190. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89191. /**
  89192. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89193. * @param channel Name of the sampler variable.
  89194. * @param texture Texture to set.
  89195. */
  89196. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89197. /**
  89198. * Sets an array of textures on the engine to be used in the shader.
  89199. * @param channel Name of the variable.
  89200. * @param textures Textures to set.
  89201. */
  89202. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89203. /**
  89204. * 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)
  89205. * @param channel Name of the sampler variable.
  89206. * @param postProcess Post process to get the input texture from.
  89207. */
  89208. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89209. /**
  89210. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89211. * 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)
  89212. * @param channel Name of the sampler variable.
  89213. * @param postProcess Post process to get the output texture from.
  89214. */
  89215. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89216. /** @hidden */
  89217. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89218. /** @hidden */
  89219. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89220. /** @hidden */
  89221. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89222. /** @hidden */
  89223. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89224. /**
  89225. * Binds a buffer to a uniform.
  89226. * @param buffer Buffer to bind.
  89227. * @param name Name of the uniform variable to bind to.
  89228. */
  89229. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89230. /**
  89231. * Binds block to a uniform.
  89232. * @param blockName Name of the block to bind.
  89233. * @param index Index to bind.
  89234. */
  89235. bindUniformBlock(blockName: string, index: number): void;
  89236. /**
  89237. * Sets an interger value on a uniform variable.
  89238. * @param uniformName Name of the variable.
  89239. * @param value Value to be set.
  89240. * @returns this effect.
  89241. */
  89242. setInt(uniformName: string, value: number): Effect;
  89243. /**
  89244. * Sets an int array on a uniform variable.
  89245. * @param uniformName Name of the variable.
  89246. * @param array array to be set.
  89247. * @returns this effect.
  89248. */
  89249. setIntArray(uniformName: string, array: Int32Array): Effect;
  89250. /**
  89251. * 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)
  89252. * @param uniformName Name of the variable.
  89253. * @param array array to be set.
  89254. * @returns this effect.
  89255. */
  89256. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89257. /**
  89258. * 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)
  89259. * @param uniformName Name of the variable.
  89260. * @param array array to be set.
  89261. * @returns this effect.
  89262. */
  89263. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89264. /**
  89265. * 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)
  89266. * @param uniformName Name of the variable.
  89267. * @param array array to be set.
  89268. * @returns this effect.
  89269. */
  89270. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89271. /**
  89272. * Sets an float array on a uniform variable.
  89273. * @param uniformName Name of the variable.
  89274. * @param array array to be set.
  89275. * @returns this effect.
  89276. */
  89277. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89278. /**
  89279. * 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)
  89280. * @param uniformName Name of the variable.
  89281. * @param array array to be set.
  89282. * @returns this effect.
  89283. */
  89284. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89285. /**
  89286. * 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)
  89287. * @param uniformName Name of the variable.
  89288. * @param array array to be set.
  89289. * @returns this effect.
  89290. */
  89291. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89292. /**
  89293. * 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)
  89294. * @param uniformName Name of the variable.
  89295. * @param array array to be set.
  89296. * @returns this effect.
  89297. */
  89298. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89299. /**
  89300. * Sets an array on a uniform variable.
  89301. * @param uniformName Name of the variable.
  89302. * @param array array to be set.
  89303. * @returns this effect.
  89304. */
  89305. setArray(uniformName: string, array: number[]): Effect;
  89306. /**
  89307. * 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)
  89308. * @param uniformName Name of the variable.
  89309. * @param array array to be set.
  89310. * @returns this effect.
  89311. */
  89312. setArray2(uniformName: string, array: number[]): Effect;
  89313. /**
  89314. * 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)
  89315. * @param uniformName Name of the variable.
  89316. * @param array array to be set.
  89317. * @returns this effect.
  89318. */
  89319. setArray3(uniformName: string, array: number[]): Effect;
  89320. /**
  89321. * 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)
  89322. * @param uniformName Name of the variable.
  89323. * @param array array to be set.
  89324. * @returns this effect.
  89325. */
  89326. setArray4(uniformName: string, array: number[]): Effect;
  89327. /**
  89328. * Sets matrices on a uniform variable.
  89329. * @param uniformName Name of the variable.
  89330. * @param matrices matrices to be set.
  89331. * @returns this effect.
  89332. */
  89333. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89334. /**
  89335. * Sets matrix on a uniform variable.
  89336. * @param uniformName Name of the variable.
  89337. * @param matrix matrix to be set.
  89338. * @returns this effect.
  89339. */
  89340. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89341. /**
  89342. * 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)
  89343. * @param uniformName Name of the variable.
  89344. * @param matrix matrix to be set.
  89345. * @returns this effect.
  89346. */
  89347. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89348. /**
  89349. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89350. * @param uniformName Name of the variable.
  89351. * @param matrix matrix to be set.
  89352. * @returns this effect.
  89353. */
  89354. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89355. /**
  89356. * Sets a float on a uniform variable.
  89357. * @param uniformName Name of the variable.
  89358. * @param value value to be set.
  89359. * @returns this effect.
  89360. */
  89361. setFloat(uniformName: string, value: number): Effect;
  89362. /**
  89363. * Sets a boolean on a uniform variable.
  89364. * @param uniformName Name of the variable.
  89365. * @param bool value to be set.
  89366. * @returns this effect.
  89367. */
  89368. setBool(uniformName: string, bool: boolean): Effect;
  89369. /**
  89370. * Sets a Vector2 on a uniform variable.
  89371. * @param uniformName Name of the variable.
  89372. * @param vector2 vector2 to be set.
  89373. * @returns this effect.
  89374. */
  89375. setVector2(uniformName: string, vector2: Vector2): Effect;
  89376. /**
  89377. * Sets a float2 on a uniform variable.
  89378. * @param uniformName Name of the variable.
  89379. * @param x First float in float2.
  89380. * @param y Second float in float2.
  89381. * @returns this effect.
  89382. */
  89383. setFloat2(uniformName: string, x: number, y: number): Effect;
  89384. /**
  89385. * Sets a Vector3 on a uniform variable.
  89386. * @param uniformName Name of the variable.
  89387. * @param vector3 Value to be set.
  89388. * @returns this effect.
  89389. */
  89390. setVector3(uniformName: string, vector3: Vector3): Effect;
  89391. /**
  89392. * Sets a float3 on a uniform variable.
  89393. * @param uniformName Name of the variable.
  89394. * @param x First float in float3.
  89395. * @param y Second float in float3.
  89396. * @param z Third float in float3.
  89397. * @returns this effect.
  89398. */
  89399. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89400. /**
  89401. * Sets a Vector4 on a uniform variable.
  89402. * @param uniformName Name of the variable.
  89403. * @param vector4 Value to be set.
  89404. * @returns this effect.
  89405. */
  89406. setVector4(uniformName: string, vector4: Vector4): Effect;
  89407. /**
  89408. * Sets a float4 on a uniform variable.
  89409. * @param uniformName Name of the variable.
  89410. * @param x First float in float4.
  89411. * @param y Second float in float4.
  89412. * @param z Third float in float4.
  89413. * @param w Fourth float in float4.
  89414. * @returns this effect.
  89415. */
  89416. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89417. /**
  89418. * Sets a Color3 on a uniform variable.
  89419. * @param uniformName Name of the variable.
  89420. * @param color3 Value to be set.
  89421. * @returns this effect.
  89422. */
  89423. setColor3(uniformName: string, color3: Color3): Effect;
  89424. /**
  89425. * Sets a Color4 on a uniform variable.
  89426. * @param uniformName Name of the variable.
  89427. * @param color3 Value to be set.
  89428. * @param alpha Alpha value to be set.
  89429. * @returns this effect.
  89430. */
  89431. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89432. /**
  89433. * Sets a Color4 on a uniform variable
  89434. * @param uniformName defines the name of the variable
  89435. * @param color4 defines the value to be set
  89436. * @returns this effect.
  89437. */
  89438. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89439. /** Release all associated resources */
  89440. dispose(): void;
  89441. /**
  89442. * This function will add a new shader to the shader store
  89443. * @param name the name of the shader
  89444. * @param pixelShader optional pixel shader content
  89445. * @param vertexShader optional vertex shader content
  89446. */
  89447. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89448. /**
  89449. * Store of each shader (The can be looked up using effect.key)
  89450. */
  89451. static ShadersStore: {
  89452. [key: string]: string;
  89453. };
  89454. /**
  89455. * Store of each included file for a shader (The can be looked up using effect.key)
  89456. */
  89457. static IncludesShadersStore: {
  89458. [key: string]: string;
  89459. };
  89460. /**
  89461. * Resets the cache of effects.
  89462. */
  89463. static ResetCache(): void;
  89464. }
  89465. }
  89466. declare module BABYLON {
  89467. /**
  89468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89470. * 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;
  89471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89472. */
  89473. export class ColorCurves {
  89474. private _dirty;
  89475. private _tempColor;
  89476. private _globalCurve;
  89477. private _highlightsCurve;
  89478. private _midtonesCurve;
  89479. private _shadowsCurve;
  89480. private _positiveCurve;
  89481. private _negativeCurve;
  89482. private _globalHue;
  89483. private _globalDensity;
  89484. private _globalSaturation;
  89485. private _globalExposure;
  89486. /**
  89487. * Gets the global Hue value.
  89488. * 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).
  89489. */
  89490. /**
  89491. * Sets the global Hue value.
  89492. * 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).
  89493. */
  89494. globalHue: number;
  89495. /**
  89496. * Gets the global Density value.
  89497. * 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.
  89498. * Values less than zero provide a filter of opposite hue.
  89499. */
  89500. /**
  89501. * Sets the global Density value.
  89502. * 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.
  89503. * Values less than zero provide a filter of opposite hue.
  89504. */
  89505. globalDensity: number;
  89506. /**
  89507. * Gets the global Saturation value.
  89508. * 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.
  89509. */
  89510. /**
  89511. * Sets the global Saturation value.
  89512. * 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.
  89513. */
  89514. globalSaturation: number;
  89515. /**
  89516. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  89518. */
  89519. /**
  89520. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  89522. */
  89523. globalExposure: number;
  89524. private _highlightsHue;
  89525. private _highlightsDensity;
  89526. private _highlightsSaturation;
  89527. private _highlightsExposure;
  89528. /**
  89529. * Gets the highlights Hue value.
  89530. * 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).
  89531. */
  89532. /**
  89533. * Sets the highlights Hue value.
  89534. * 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).
  89535. */
  89536. highlightsHue: number;
  89537. /**
  89538. * Gets the highlights Density value.
  89539. * 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.
  89540. * Values less than zero provide a filter of opposite hue.
  89541. */
  89542. /**
  89543. * Sets the highlights Density value.
  89544. * 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.
  89545. * Values less than zero provide a filter of opposite hue.
  89546. */
  89547. highlightsDensity: number;
  89548. /**
  89549. * Gets the highlights Saturation value.
  89550. * 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.
  89551. */
  89552. /**
  89553. * Sets the highlights Saturation value.
  89554. * 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.
  89555. */
  89556. highlightsSaturation: number;
  89557. /**
  89558. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  89560. */
  89561. /**
  89562. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  89564. */
  89565. highlightsExposure: number;
  89566. private _midtonesHue;
  89567. private _midtonesDensity;
  89568. private _midtonesSaturation;
  89569. private _midtonesExposure;
  89570. /**
  89571. * Gets the midtones Hue value.
  89572. * 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).
  89573. */
  89574. /**
  89575. * Sets the midtones Hue value.
  89576. * 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).
  89577. */
  89578. midtonesHue: number;
  89579. /**
  89580. * Gets the midtones Density value.
  89581. * 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.
  89582. * Values less than zero provide a filter of opposite hue.
  89583. */
  89584. /**
  89585. * Sets the midtones Density value.
  89586. * 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.
  89587. * Values less than zero provide a filter of opposite hue.
  89588. */
  89589. midtonesDensity: number;
  89590. /**
  89591. * Gets the midtones Saturation value.
  89592. * 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.
  89593. */
  89594. /**
  89595. * Sets the midtones Saturation value.
  89596. * 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.
  89597. */
  89598. midtonesSaturation: number;
  89599. /**
  89600. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  89602. */
  89603. /**
  89604. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  89606. */
  89607. midtonesExposure: number;
  89608. private _shadowsHue;
  89609. private _shadowsDensity;
  89610. private _shadowsSaturation;
  89611. private _shadowsExposure;
  89612. /**
  89613. * Gets the shadows Hue value.
  89614. * 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).
  89615. */
  89616. /**
  89617. * Sets the shadows Hue value.
  89618. * 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).
  89619. */
  89620. shadowsHue: number;
  89621. /**
  89622. * Gets the shadows Density value.
  89623. * 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.
  89624. * Values less than zero provide a filter of opposite hue.
  89625. */
  89626. /**
  89627. * Sets the shadows Density value.
  89628. * 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.
  89629. * Values less than zero provide a filter of opposite hue.
  89630. */
  89631. shadowsDensity: number;
  89632. /**
  89633. * Gets the shadows Saturation value.
  89634. * 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.
  89635. */
  89636. /**
  89637. * Sets the shadows Saturation value.
  89638. * 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.
  89639. */
  89640. shadowsSaturation: number;
  89641. /**
  89642. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  89644. */
  89645. /**
  89646. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  89648. */
  89649. shadowsExposure: number;
  89650. /**
  89651. * Returns the class name
  89652. * @returns The class name
  89653. */
  89654. getClassName(): string;
  89655. /**
  89656. * Binds the color curves to the shader.
  89657. * @param colorCurves The color curve to bind
  89658. * @param effect The effect to bind to
  89659. * @param positiveUniform The positive uniform shader parameter
  89660. * @param neutralUniform The neutral uniform shader parameter
  89661. * @param negativeUniform The negative uniform shader parameter
  89662. */
  89663. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89664. /**
  89665. * Prepare the list of uniforms associated with the ColorCurves effects.
  89666. * @param uniformsList The list of uniforms used in the effect
  89667. */
  89668. static PrepareUniforms(uniformsList: string[]): void;
  89669. /**
  89670. * Returns color grading data based on a hue, density, saturation and exposure value.
  89671. * @param filterHue The hue of the color filter.
  89672. * @param filterDensity The density of the color filter.
  89673. * @param saturation The saturation.
  89674. * @param exposure The exposure.
  89675. * @param result The result data container.
  89676. */
  89677. private getColorGradingDataToRef;
  89678. /**
  89679. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89680. * @param value The input slider value in range [-100,100].
  89681. * @returns Adjusted value.
  89682. */
  89683. private static applyColorGradingSliderNonlinear;
  89684. /**
  89685. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89686. * @param hue The hue (H) input.
  89687. * @param saturation The saturation (S) input.
  89688. * @param brightness The brightness (B) input.
  89689. * @result An RGBA color represented as Vector4.
  89690. */
  89691. private static fromHSBToRef;
  89692. /**
  89693. * Returns a value clamped between min and max
  89694. * @param value The value to clamp
  89695. * @param min The minimum of value
  89696. * @param max The maximum of value
  89697. * @returns The clamped value.
  89698. */
  89699. private static clamp;
  89700. /**
  89701. * Clones the current color curve instance.
  89702. * @return The cloned curves
  89703. */
  89704. clone(): ColorCurves;
  89705. /**
  89706. * Serializes the current color curve instance to a json representation.
  89707. * @return a JSON representation
  89708. */
  89709. serialize(): any;
  89710. /**
  89711. * Parses the color curve from a json representation.
  89712. * @param source the JSON source to parse
  89713. * @return The parsed curves
  89714. */
  89715. static Parse(source: any): ColorCurves;
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /**
  89720. * Interface to follow in your material defines to integrate easily the
  89721. * Image proccessing functions.
  89722. * @hidden
  89723. */
  89724. export interface IImageProcessingConfigurationDefines {
  89725. IMAGEPROCESSING: boolean;
  89726. VIGNETTE: boolean;
  89727. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89728. VIGNETTEBLENDMODEOPAQUE: boolean;
  89729. TONEMAPPING: boolean;
  89730. TONEMAPPING_ACES: boolean;
  89731. CONTRAST: boolean;
  89732. EXPOSURE: boolean;
  89733. COLORCURVES: boolean;
  89734. COLORGRADING: boolean;
  89735. COLORGRADING3D: boolean;
  89736. SAMPLER3DGREENDEPTH: boolean;
  89737. SAMPLER3DBGRMAP: boolean;
  89738. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89739. }
  89740. /**
  89741. * @hidden
  89742. */
  89743. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89744. IMAGEPROCESSING: boolean;
  89745. VIGNETTE: boolean;
  89746. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89747. VIGNETTEBLENDMODEOPAQUE: boolean;
  89748. TONEMAPPING: boolean;
  89749. TONEMAPPING_ACES: boolean;
  89750. CONTRAST: boolean;
  89751. COLORCURVES: boolean;
  89752. COLORGRADING: boolean;
  89753. COLORGRADING3D: boolean;
  89754. SAMPLER3DGREENDEPTH: boolean;
  89755. SAMPLER3DBGRMAP: boolean;
  89756. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89757. EXPOSURE: boolean;
  89758. constructor();
  89759. }
  89760. /**
  89761. * This groups together the common properties used for image processing either in direct forward pass
  89762. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89763. * or not.
  89764. */
  89765. export class ImageProcessingConfiguration {
  89766. /**
  89767. * Default tone mapping applied in BabylonJS.
  89768. */
  89769. static readonly TONEMAPPING_STANDARD: number;
  89770. /**
  89771. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89772. * to other engines rendering to increase portability.
  89773. */
  89774. static readonly TONEMAPPING_ACES: number;
  89775. /**
  89776. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89777. */
  89778. colorCurves: Nullable<ColorCurves>;
  89779. private _colorCurvesEnabled;
  89780. /**
  89781. * Gets wether the color curves effect is enabled.
  89782. */
  89783. /**
  89784. * Sets wether the color curves effect is enabled.
  89785. */
  89786. colorCurvesEnabled: boolean;
  89787. private _colorGradingTexture;
  89788. /**
  89789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89790. */
  89791. /**
  89792. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89793. */
  89794. colorGradingTexture: Nullable<BaseTexture>;
  89795. private _colorGradingEnabled;
  89796. /**
  89797. * Gets wether the color grading effect is enabled.
  89798. */
  89799. /**
  89800. * Sets wether the color grading effect is enabled.
  89801. */
  89802. colorGradingEnabled: boolean;
  89803. private _colorGradingWithGreenDepth;
  89804. /**
  89805. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89806. */
  89807. /**
  89808. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89809. */
  89810. colorGradingWithGreenDepth: boolean;
  89811. private _colorGradingBGR;
  89812. /**
  89813. * Gets wether the color grading texture contains BGR values.
  89814. */
  89815. /**
  89816. * Sets wether the color grading texture contains BGR values.
  89817. */
  89818. colorGradingBGR: boolean;
  89819. /** @hidden */
  89820. _exposure: number;
  89821. /**
  89822. * Gets the Exposure used in the effect.
  89823. */
  89824. /**
  89825. * Sets the Exposure used in the effect.
  89826. */
  89827. exposure: number;
  89828. private _toneMappingEnabled;
  89829. /**
  89830. * Gets wether the tone mapping effect is enabled.
  89831. */
  89832. /**
  89833. * Sets wether the tone mapping effect is enabled.
  89834. */
  89835. toneMappingEnabled: boolean;
  89836. private _toneMappingType;
  89837. /**
  89838. * Gets the type of tone mapping effect.
  89839. */
  89840. /**
  89841. * Sets the type of tone mapping effect used in BabylonJS.
  89842. */
  89843. toneMappingType: number;
  89844. protected _contrast: number;
  89845. /**
  89846. * Gets the contrast used in the effect.
  89847. */
  89848. /**
  89849. * Sets the contrast used in the effect.
  89850. */
  89851. contrast: number;
  89852. /**
  89853. * Vignette stretch size.
  89854. */
  89855. vignetteStretch: number;
  89856. /**
  89857. * Vignette centre X Offset.
  89858. */
  89859. vignetteCentreX: number;
  89860. /**
  89861. * Vignette centre Y Offset.
  89862. */
  89863. vignetteCentreY: number;
  89864. /**
  89865. * Vignette weight or intensity of the vignette effect.
  89866. */
  89867. vignetteWeight: number;
  89868. /**
  89869. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89870. * if vignetteEnabled is set to true.
  89871. */
  89872. vignetteColor: Color4;
  89873. /**
  89874. * Camera field of view used by the Vignette effect.
  89875. */
  89876. vignetteCameraFov: number;
  89877. private _vignetteBlendMode;
  89878. /**
  89879. * Gets the vignette blend mode allowing different kind of effect.
  89880. */
  89881. /**
  89882. * Sets the vignette blend mode allowing different kind of effect.
  89883. */
  89884. vignetteBlendMode: number;
  89885. private _vignetteEnabled;
  89886. /**
  89887. * Gets wether the vignette effect is enabled.
  89888. */
  89889. /**
  89890. * Sets wether the vignette effect is enabled.
  89891. */
  89892. vignetteEnabled: boolean;
  89893. private _applyByPostProcess;
  89894. /**
  89895. * Gets wether the image processing is applied through a post process or not.
  89896. */
  89897. /**
  89898. * Sets wether the image processing is applied through a post process or not.
  89899. */
  89900. applyByPostProcess: boolean;
  89901. private _isEnabled;
  89902. /**
  89903. * Gets wether the image processing is enabled or not.
  89904. */
  89905. /**
  89906. * Sets wether the image processing is enabled or not.
  89907. */
  89908. isEnabled: boolean;
  89909. /**
  89910. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89911. */
  89912. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89913. /**
  89914. * Method called each time the image processing information changes requires to recompile the effect.
  89915. */
  89916. protected _updateParameters(): void;
  89917. /**
  89918. * Gets the current class name.
  89919. * @return "ImageProcessingConfiguration"
  89920. */
  89921. getClassName(): string;
  89922. /**
  89923. * Prepare the list of uniforms associated with the Image Processing effects.
  89924. * @param uniforms The list of uniforms used in the effect
  89925. * @param defines the list of defines currently in use
  89926. */
  89927. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89928. /**
  89929. * Prepare the list of samplers associated with the Image Processing effects.
  89930. * @param samplersList The list of uniforms used in the effect
  89931. * @param defines the list of defines currently in use
  89932. */
  89933. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89934. /**
  89935. * Prepare the list of defines associated to the shader.
  89936. * @param defines the list of defines to complete
  89937. * @param forPostProcess Define if we are currently in post process mode or not
  89938. */
  89939. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89940. /**
  89941. * Returns true if all the image processing information are ready.
  89942. * @returns True if ready, otherwise, false
  89943. */
  89944. isReady(): boolean;
  89945. /**
  89946. * Binds the image processing to the shader.
  89947. * @param effect The effect to bind to
  89948. * @param aspectRatio Define the current aspect ratio of the effect
  89949. */
  89950. bind(effect: Effect, aspectRatio?: number): void;
  89951. /**
  89952. * Clones the current image processing instance.
  89953. * @return The cloned image processing
  89954. */
  89955. clone(): ImageProcessingConfiguration;
  89956. /**
  89957. * Serializes the current image processing instance to a json representation.
  89958. * @return a JSON representation
  89959. */
  89960. serialize(): any;
  89961. /**
  89962. * Parses the image processing from a json representation.
  89963. * @param source the JSON source to parse
  89964. * @return The parsed image processing
  89965. */
  89966. static Parse(source: any): ImageProcessingConfiguration;
  89967. private static _VIGNETTEMODE_MULTIPLY;
  89968. private static _VIGNETTEMODE_OPAQUE;
  89969. /**
  89970. * Used to apply the vignette as a mix with the pixel color.
  89971. */
  89972. static readonly VIGNETTEMODE_MULTIPLY: number;
  89973. /**
  89974. * Used to apply the vignette as a replacement of the pixel color.
  89975. */
  89976. static readonly VIGNETTEMODE_OPAQUE: number;
  89977. }
  89978. }
  89979. declare module BABYLON {
  89980. /**
  89981. * This represents all the required information to add a fresnel effect on a material:
  89982. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89983. */
  89984. export class FresnelParameters {
  89985. private _isEnabled;
  89986. /**
  89987. * Define if the fresnel effect is enable or not.
  89988. */
  89989. isEnabled: boolean;
  89990. /**
  89991. * Define the color used on edges (grazing angle)
  89992. */
  89993. leftColor: Color3;
  89994. /**
  89995. * Define the color used on center
  89996. */
  89997. rightColor: Color3;
  89998. /**
  89999. * Define bias applied to computed fresnel term
  90000. */
  90001. bias: number;
  90002. /**
  90003. * Defined the power exponent applied to fresnel term
  90004. */
  90005. power: number;
  90006. /**
  90007. * Clones the current fresnel and its valuues
  90008. * @returns a clone fresnel configuration
  90009. */
  90010. clone(): FresnelParameters;
  90011. /**
  90012. * Serializes the current fresnel parameters to a JSON representation.
  90013. * @return the JSON serialization
  90014. */
  90015. serialize(): any;
  90016. /**
  90017. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90018. * @param parsedFresnelParameters Define the JSON representation
  90019. * @returns the parsed parameters
  90020. */
  90021. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90022. }
  90023. }
  90024. declare module BABYLON {
  90025. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90026. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90027. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90028. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90029. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90030. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90031. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90032. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90033. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90034. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90035. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90037. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90038. /**
  90039. * Decorator used to define property that can be serialized as reference to a camera
  90040. * @param sourceName defines the name of the property to decorate
  90041. */
  90042. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90043. /**
  90044. * Class used to help serialization objects
  90045. */
  90046. export class SerializationHelper {
  90047. /** hidden */
  90048. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90049. /** hidden */
  90050. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90051. /** hidden */
  90052. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90053. /** hidden */
  90054. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90055. /**
  90056. * Appends the serialized animations from the source animations
  90057. * @param source Source containing the animations
  90058. * @param destination Target to store the animations
  90059. */
  90060. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90061. /**
  90062. * Static function used to serialized a specific entity
  90063. * @param entity defines the entity to serialize
  90064. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90065. * @returns a JSON compatible object representing the serialization of the entity
  90066. */
  90067. static Serialize<T>(entity: T, serializationObject?: any): any;
  90068. /**
  90069. * Creates a new entity from a serialization data object
  90070. * @param creationFunction defines a function used to instanciated the new entity
  90071. * @param source defines the source serialization data
  90072. * @param scene defines the hosting scene
  90073. * @param rootUrl defines the root url for resources
  90074. * @returns a new entity
  90075. */
  90076. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90077. /**
  90078. * Clones an object
  90079. * @param creationFunction defines the function used to instanciate the new object
  90080. * @param source defines the source object
  90081. * @returns the cloned object
  90082. */
  90083. static Clone<T>(creationFunction: () => T, source: T): T;
  90084. /**
  90085. * Instanciates a new object based on a source one (some data will be shared between both object)
  90086. * @param creationFunction defines the function used to instanciate the new object
  90087. * @param source defines the source object
  90088. * @returns the new object
  90089. */
  90090. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90091. }
  90092. }
  90093. declare module BABYLON {
  90094. /**
  90095. * This is the base class of all the camera used in the application.
  90096. * @see http://doc.babylonjs.com/features/cameras
  90097. */
  90098. export class Camera extends Node {
  90099. /** @hidden */
  90100. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90101. /**
  90102. * This is the default projection mode used by the cameras.
  90103. * It helps recreating a feeling of perspective and better appreciate depth.
  90104. * This is the best way to simulate real life cameras.
  90105. */
  90106. static readonly PERSPECTIVE_CAMERA: number;
  90107. /**
  90108. * This helps creating camera with an orthographic mode.
  90109. * 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.
  90110. */
  90111. static readonly ORTHOGRAPHIC_CAMERA: number;
  90112. /**
  90113. * This is the default FOV mode for perspective cameras.
  90114. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90115. */
  90116. static readonly FOVMODE_VERTICAL_FIXED: number;
  90117. /**
  90118. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90119. */
  90120. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90121. /**
  90122. * This specifies ther is no need for a camera rig.
  90123. * Basically only one eye is rendered corresponding to the camera.
  90124. */
  90125. static readonly RIG_MODE_NONE: number;
  90126. /**
  90127. * Simulates a camera Rig with one blue eye and one red eye.
  90128. * This can be use with 3d blue and red glasses.
  90129. */
  90130. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90131. /**
  90132. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90133. */
  90134. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90135. /**
  90136. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90137. */
  90138. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90139. /**
  90140. * Defines that both eyes of the camera will be rendered over under each other.
  90141. */
  90142. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90143. /**
  90144. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90145. */
  90146. static readonly RIG_MODE_VR: number;
  90147. /**
  90148. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90149. */
  90150. static readonly RIG_MODE_WEBVR: number;
  90151. /**
  90152. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90153. */
  90154. static readonly RIG_MODE_CUSTOM: number;
  90155. /**
  90156. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90157. */
  90158. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90159. /**
  90160. * Define the input manager associated with the camera.
  90161. */
  90162. inputs: CameraInputsManager<Camera>;
  90163. /** @hidden */
  90164. _position: Vector3;
  90165. /**
  90166. * Define the current local position of the camera in the scene
  90167. */
  90168. position: Vector3;
  90169. /**
  90170. * The vector the camera should consider as up.
  90171. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90172. */
  90173. upVector: Vector3;
  90174. /**
  90175. * Define the current limit on the left side for an orthographic camera
  90176. * In scene unit
  90177. */
  90178. orthoLeft: Nullable<number>;
  90179. /**
  90180. * Define the current limit on the right side for an orthographic camera
  90181. * In scene unit
  90182. */
  90183. orthoRight: Nullable<number>;
  90184. /**
  90185. * Define the current limit on the bottom side for an orthographic camera
  90186. * In scene unit
  90187. */
  90188. orthoBottom: Nullable<number>;
  90189. /**
  90190. * Define the current limit on the top side for an orthographic camera
  90191. * In scene unit
  90192. */
  90193. orthoTop: Nullable<number>;
  90194. /**
  90195. * Field Of View is set in Radians. (default is 0.8)
  90196. */
  90197. fov: number;
  90198. /**
  90199. * Define the minimum distance the camera can see from.
  90200. * This is important to note that the depth buffer are not infinite and the closer it starts
  90201. * the more your scene might encounter depth fighting issue.
  90202. */
  90203. minZ: number;
  90204. /**
  90205. * Define the maximum distance the camera can see to.
  90206. * This is important to note that the depth buffer are not infinite and the further it end
  90207. * the more your scene might encounter depth fighting issue.
  90208. */
  90209. maxZ: number;
  90210. /**
  90211. * Define the default inertia of the camera.
  90212. * This helps giving a smooth feeling to the camera movement.
  90213. */
  90214. inertia: number;
  90215. /**
  90216. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90217. */
  90218. mode: number;
  90219. /**
  90220. * Define wether the camera is intermediate.
  90221. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90222. */
  90223. isIntermediate: boolean;
  90224. /**
  90225. * Define the viewport of the camera.
  90226. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90227. */
  90228. viewport: Viewport;
  90229. /**
  90230. * Restricts the camera to viewing objects with the same layerMask.
  90231. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90232. */
  90233. layerMask: number;
  90234. /**
  90235. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90236. */
  90237. fovMode: number;
  90238. /**
  90239. * Rig mode of the camera.
  90240. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90241. * This is normally controlled byt the camera themselves as internal use.
  90242. */
  90243. cameraRigMode: number;
  90244. /**
  90245. * Defines the distance between both "eyes" in case of a RIG
  90246. */
  90247. interaxialDistance: number;
  90248. /**
  90249. * Defines if stereoscopic rendering is done side by side or over under.
  90250. */
  90251. isStereoscopicSideBySide: boolean;
  90252. /**
  90253. * 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
  90254. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90255. * else in the scene.
  90256. */
  90257. customRenderTargets: RenderTargetTexture[];
  90258. /**
  90259. * When set, the camera will render to this render target instead of the default canvas
  90260. */
  90261. outputRenderTarget: Nullable<RenderTargetTexture>;
  90262. /**
  90263. * Observable triggered when the camera view matrix has changed.
  90264. */
  90265. onViewMatrixChangedObservable: Observable<Camera>;
  90266. /**
  90267. * Observable triggered when the camera Projection matrix has changed.
  90268. */
  90269. onProjectionMatrixChangedObservable: Observable<Camera>;
  90270. /**
  90271. * Observable triggered when the inputs have been processed.
  90272. */
  90273. onAfterCheckInputsObservable: Observable<Camera>;
  90274. /**
  90275. * Observable triggered when reset has been called and applied to the camera.
  90276. */
  90277. onRestoreStateObservable: Observable<Camera>;
  90278. /** @hidden */
  90279. _cameraRigParams: any;
  90280. /** @hidden */
  90281. _rigCameras: Camera[];
  90282. /** @hidden */
  90283. _rigPostProcess: Nullable<PostProcess>;
  90284. protected _webvrViewMatrix: Matrix;
  90285. /** @hidden */
  90286. _skipRendering: boolean;
  90287. /** @hidden */
  90288. _projectionMatrix: Matrix;
  90289. /** @hidden */
  90290. _postProcesses: Nullable<PostProcess>[];
  90291. /** @hidden */
  90292. _activeMeshes: SmartArray<AbstractMesh>;
  90293. protected _globalPosition: Vector3;
  90294. /** hidden */
  90295. _computedViewMatrix: Matrix;
  90296. private _doNotComputeProjectionMatrix;
  90297. private _transformMatrix;
  90298. private _frustumPlanes;
  90299. private _refreshFrustumPlanes;
  90300. private _storedFov;
  90301. private _stateStored;
  90302. /**
  90303. * Instantiates a new camera object.
  90304. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90305. * @see http://doc.babylonjs.com/features/cameras
  90306. * @param name Defines the name of the camera in the scene
  90307. * @param position Defines the position of the camera
  90308. * @param scene Defines the scene the camera belongs too
  90309. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90310. */
  90311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90312. /**
  90313. * Store current camera state (fov, position, etc..)
  90314. * @returns the camera
  90315. */
  90316. storeState(): Camera;
  90317. /**
  90318. * Restores the camera state values if it has been stored. You must call storeState() first
  90319. */
  90320. protected _restoreStateValues(): boolean;
  90321. /**
  90322. * Restored camera state. You must call storeState() first.
  90323. * @returns true if restored and false otherwise
  90324. */
  90325. restoreState(): boolean;
  90326. /**
  90327. * Gets the class name of the camera.
  90328. * @returns the class name
  90329. */
  90330. getClassName(): string;
  90331. /** @hidden */
  90332. readonly _isCamera: boolean;
  90333. /**
  90334. * Gets a string representation of the camera useful for debug purpose.
  90335. * @param fullDetails Defines that a more verboe level of logging is required
  90336. * @returns the string representation
  90337. */
  90338. toString(fullDetails?: boolean): string;
  90339. /**
  90340. * Gets the current world space position of the camera.
  90341. */
  90342. readonly globalPosition: Vector3;
  90343. /**
  90344. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90345. * @returns the active meshe list
  90346. */
  90347. getActiveMeshes(): SmartArray<AbstractMesh>;
  90348. /**
  90349. * Check wether a mesh is part of the current active mesh list of the camera
  90350. * @param mesh Defines the mesh to check
  90351. * @returns true if active, false otherwise
  90352. */
  90353. isActiveMesh(mesh: Mesh): boolean;
  90354. /**
  90355. * Is this camera ready to be used/rendered
  90356. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90357. * @return true if the camera is ready
  90358. */
  90359. isReady(completeCheck?: boolean): boolean;
  90360. /** @hidden */
  90361. _initCache(): void;
  90362. /** @hidden */
  90363. _updateCache(ignoreParentClass?: boolean): void;
  90364. /** @hidden */
  90365. _isSynchronized(): boolean;
  90366. /** @hidden */
  90367. _isSynchronizedViewMatrix(): boolean;
  90368. /** @hidden */
  90369. _isSynchronizedProjectionMatrix(): boolean;
  90370. /**
  90371. * Attach the input controls to a specific dom element to get the input from.
  90372. * @param element Defines the element the controls should be listened from
  90373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90374. */
  90375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90376. /**
  90377. * Detach the current controls from the specified dom element.
  90378. * @param element Defines the element to stop listening the inputs from
  90379. */
  90380. detachControl(element: HTMLElement): void;
  90381. /**
  90382. * Update the camera state according to the different inputs gathered during the frame.
  90383. */
  90384. update(): void;
  90385. /** @hidden */
  90386. _checkInputs(): void;
  90387. /** @hidden */
  90388. readonly rigCameras: Camera[];
  90389. /**
  90390. * Gets the post process used by the rig cameras
  90391. */
  90392. readonly rigPostProcess: Nullable<PostProcess>;
  90393. /**
  90394. * Internal, gets the first post proces.
  90395. * @returns the first post process to be run on this camera.
  90396. */
  90397. _getFirstPostProcess(): Nullable<PostProcess>;
  90398. private _cascadePostProcessesToRigCams;
  90399. /**
  90400. * Attach a post process to the camera.
  90401. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90402. * @param postProcess The post process to attach to the camera
  90403. * @param insertAt The position of the post process in case several of them are in use in the scene
  90404. * @returns the position the post process has been inserted at
  90405. */
  90406. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90407. /**
  90408. * Detach a post process to the camera.
  90409. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90410. * @param postProcess The post process to detach from the camera
  90411. */
  90412. detachPostProcess(postProcess: PostProcess): void;
  90413. /**
  90414. * Gets the current world matrix of the camera
  90415. */
  90416. getWorldMatrix(): Matrix;
  90417. /** @hidden */
  90418. _getViewMatrix(): Matrix;
  90419. /**
  90420. * Gets the current view matrix of the camera.
  90421. * @param force forces the camera to recompute the matrix without looking at the cached state
  90422. * @returns the view matrix
  90423. */
  90424. getViewMatrix(force?: boolean): Matrix;
  90425. /**
  90426. * Freeze the projection matrix.
  90427. * It will prevent the cache check of the camera projection compute and can speed up perf
  90428. * if no parameter of the camera are meant to change
  90429. * @param projection Defines manually a projection if necessary
  90430. */
  90431. freezeProjectionMatrix(projection?: Matrix): void;
  90432. /**
  90433. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90434. */
  90435. unfreezeProjectionMatrix(): void;
  90436. /**
  90437. * Gets the current projection matrix of the camera.
  90438. * @param force forces the camera to recompute the matrix without looking at the cached state
  90439. * @returns the projection matrix
  90440. */
  90441. getProjectionMatrix(force?: boolean): Matrix;
  90442. /**
  90443. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90444. * @returns a Matrix
  90445. */
  90446. getTransformationMatrix(): Matrix;
  90447. private _updateFrustumPlanes;
  90448. /**
  90449. * Checks if a cullable object (mesh...) is in the camera frustum
  90450. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90451. * @param target The object to check
  90452. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90453. * @returns true if the object is in frustum otherwise false
  90454. */
  90455. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90456. /**
  90457. * Checks if a cullable object (mesh...) is in the camera frustum
  90458. * Unlike isInFrustum this cheks the full bounding box
  90459. * @param target The object to check
  90460. * @returns true if the object is in frustum otherwise false
  90461. */
  90462. isCompletelyInFrustum(target: ICullable): boolean;
  90463. /**
  90464. * Gets a ray in the forward direction from the camera.
  90465. * @param length Defines the length of the ray to create
  90466. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90467. * @param origin Defines the start point of the ray which defaults to the camera position
  90468. * @returns the forward ray
  90469. */
  90470. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90471. /**
  90472. * Releases resources associated with this node.
  90473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90475. */
  90476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90477. /** @hidden */
  90478. _isLeftCamera: boolean;
  90479. /**
  90480. * Gets the left camera of a rig setup in case of Rigged Camera
  90481. */
  90482. readonly isLeftCamera: boolean;
  90483. /** @hidden */
  90484. _isRightCamera: boolean;
  90485. /**
  90486. * Gets the right camera of a rig setup in case of Rigged Camera
  90487. */
  90488. readonly isRightCamera: boolean;
  90489. /**
  90490. * Gets the left camera of a rig setup in case of Rigged Camera
  90491. */
  90492. readonly leftCamera: Nullable<FreeCamera>;
  90493. /**
  90494. * Gets the right camera of a rig setup in case of Rigged Camera
  90495. */
  90496. readonly rightCamera: Nullable<FreeCamera>;
  90497. /**
  90498. * Gets the left camera target of a rig setup in case of Rigged Camera
  90499. * @returns the target position
  90500. */
  90501. getLeftTarget(): Nullable<Vector3>;
  90502. /**
  90503. * Gets the right camera target of a rig setup in case of Rigged Camera
  90504. * @returns the target position
  90505. */
  90506. getRightTarget(): Nullable<Vector3>;
  90507. /**
  90508. * @hidden
  90509. */
  90510. setCameraRigMode(mode: number, rigParams: any): void;
  90511. /** @hidden */
  90512. static _setStereoscopicRigMode(camera: Camera): void;
  90513. /** @hidden */
  90514. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90515. /** @hidden */
  90516. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90517. /** @hidden */
  90518. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90519. /** @hidden */
  90520. _getVRProjectionMatrix(): Matrix;
  90521. protected _updateCameraRotationMatrix(): void;
  90522. protected _updateWebVRCameraRotationMatrix(): void;
  90523. /**
  90524. * This function MUST be overwritten by the different WebVR cameras available.
  90525. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90526. * @hidden
  90527. */
  90528. _getWebVRProjectionMatrix(): Matrix;
  90529. /**
  90530. * This function MUST be overwritten by the different WebVR cameras available.
  90531. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90532. * @hidden
  90533. */
  90534. _getWebVRViewMatrix(): Matrix;
  90535. /** @hidden */
  90536. setCameraRigParameter(name: string, value: any): void;
  90537. /**
  90538. * needs to be overridden by children so sub has required properties to be copied
  90539. * @hidden
  90540. */
  90541. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90542. /**
  90543. * May need to be overridden by children
  90544. * @hidden
  90545. */
  90546. _updateRigCameras(): void;
  90547. /** @hidden */
  90548. _setupInputs(): void;
  90549. /**
  90550. * Serialiaze the camera setup to a json represention
  90551. * @returns the JSON representation
  90552. */
  90553. serialize(): any;
  90554. /**
  90555. * Clones the current camera.
  90556. * @param name The cloned camera name
  90557. * @returns the cloned camera
  90558. */
  90559. clone(name: string): Camera;
  90560. /**
  90561. * Gets the direction of the camera relative to a given local axis.
  90562. * @param localAxis Defines the reference axis to provide a relative direction.
  90563. * @return the direction
  90564. */
  90565. getDirection(localAxis: Vector3): Vector3;
  90566. /**
  90567. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90568. * @param localAxis Defines the reference axis to provide a relative direction.
  90569. * @param result Defines the vector to store the result in
  90570. */
  90571. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90572. /**
  90573. * Gets a camera constructor for a given camera type
  90574. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90575. * @param name The name of the camera the result will be able to instantiate
  90576. * @param scene The scene the result will construct the camera in
  90577. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90578. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90579. * @returns a factory method to construc the camera
  90580. */
  90581. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90582. /**
  90583. * Compute the world matrix of the camera.
  90584. * @returns the camera workd matrix
  90585. */
  90586. computeWorldMatrix(): Matrix;
  90587. /**
  90588. * Parse a JSON and creates the camera from the parsed information
  90589. * @param parsedCamera The JSON to parse
  90590. * @param scene The scene to instantiate the camera in
  90591. * @returns the newly constructed camera
  90592. */
  90593. static Parse(parsedCamera: any, scene: Scene): Camera;
  90594. }
  90595. }
  90596. declare module BABYLON {
  90597. /**
  90598. * Interface for any object that can request an animation frame
  90599. */
  90600. export interface ICustomAnimationFrameRequester {
  90601. /**
  90602. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90603. */
  90604. renderFunction?: Function;
  90605. /**
  90606. * Called to request the next frame to render to
  90607. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90608. */
  90609. requestAnimationFrame: Function;
  90610. /**
  90611. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90612. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90613. */
  90614. requestID?: number;
  90615. }
  90616. /**
  90617. * Interface containing an array of animations
  90618. */
  90619. export interface IAnimatable {
  90620. /**
  90621. * Array of animations
  90622. */
  90623. animations: Nullable<Array<Animation>>;
  90624. }
  90625. /** Interface used by value gradients (color, factor, ...) */
  90626. export interface IValueGradient {
  90627. /**
  90628. * Gets or sets the gradient value (between 0 and 1)
  90629. */
  90630. gradient: number;
  90631. }
  90632. /** Class used to store color4 gradient */
  90633. export class ColorGradient implements IValueGradient {
  90634. /**
  90635. * Gets or sets the gradient value (between 0 and 1)
  90636. */
  90637. gradient: number;
  90638. /**
  90639. * Gets or sets first associated color
  90640. */
  90641. color1: Color4;
  90642. /**
  90643. * Gets or sets second associated color
  90644. */
  90645. color2?: Color4;
  90646. /**
  90647. * Will get a color picked randomly between color1 and color2.
  90648. * If color2 is undefined then color1 will be used
  90649. * @param result defines the target Color4 to store the result in
  90650. */
  90651. getColorToRef(result: Color4): void;
  90652. }
  90653. /** Class used to store color 3 gradient */
  90654. export class Color3Gradient implements IValueGradient {
  90655. /**
  90656. * Gets or sets the gradient value (between 0 and 1)
  90657. */
  90658. gradient: number;
  90659. /**
  90660. * Gets or sets the associated color
  90661. */
  90662. color: Color3;
  90663. }
  90664. /** Class used to store factor gradient */
  90665. export class FactorGradient implements IValueGradient {
  90666. /**
  90667. * Gets or sets the gradient value (between 0 and 1)
  90668. */
  90669. gradient: number;
  90670. /**
  90671. * Gets or sets first associated factor
  90672. */
  90673. factor1: number;
  90674. /**
  90675. * Gets or sets second associated factor
  90676. */
  90677. factor2?: number;
  90678. /**
  90679. * Will get a number picked randomly between factor1 and factor2.
  90680. * If factor2 is undefined then factor1 will be used
  90681. * @returns the picked number
  90682. */
  90683. getFactor(): number;
  90684. }
  90685. /**
  90686. * @ignore
  90687. * Application error to support additional information when loading a file
  90688. */
  90689. export class LoadFileError extends Error {
  90690. /** defines the optional web request */
  90691. request?: WebRequest | undefined;
  90692. private static _setPrototypeOf;
  90693. /**
  90694. * Creates a new LoadFileError
  90695. * @param message defines the message of the error
  90696. * @param request defines the optional web request
  90697. */
  90698. constructor(message: string,
  90699. /** defines the optional web request */
  90700. request?: WebRequest | undefined);
  90701. }
  90702. /**
  90703. * Class used to define a retry strategy when error happens while loading assets
  90704. */
  90705. export class RetryStrategy {
  90706. /**
  90707. * Function used to defines an exponential back off strategy
  90708. * @param maxRetries defines the maximum number of retries (3 by default)
  90709. * @param baseInterval defines the interval between retries
  90710. * @returns the strategy function to use
  90711. */
  90712. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90713. }
  90714. /**
  90715. * File request interface
  90716. */
  90717. export interface IFileRequest {
  90718. /**
  90719. * Raised when the request is complete (success or error).
  90720. */
  90721. onCompleteObservable: Observable<IFileRequest>;
  90722. /**
  90723. * Aborts the request for a file.
  90724. */
  90725. abort: () => void;
  90726. }
  90727. /**
  90728. * Class containing a set of static utilities functions
  90729. */
  90730. export class Tools {
  90731. /**
  90732. * Gets or sets the base URL to use to load assets
  90733. */
  90734. static BaseUrl: string;
  90735. /**
  90736. * Enable/Disable Custom HTTP Request Headers globally.
  90737. * default = false
  90738. * @see CustomRequestHeaders
  90739. */
  90740. static UseCustomRequestHeaders: boolean;
  90741. /**
  90742. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90743. * i.e. when loading files, where the server/service expects an Authorization header
  90744. */
  90745. static CustomRequestHeaders: {
  90746. [key: string]: string;
  90747. };
  90748. /**
  90749. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90750. */
  90751. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90752. /**
  90753. * Default behaviour for cors in the application.
  90754. * It can be a string if the expected behavior is identical in the entire app.
  90755. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90756. */
  90757. static CorsBehavior: string | ((url: string | string[]) => string);
  90758. /**
  90759. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90760. * @ignorenaming
  90761. */
  90762. static UseFallbackTexture: boolean;
  90763. /**
  90764. * Use this object to register external classes like custom textures or material
  90765. * to allow the laoders to instantiate them
  90766. */
  90767. static RegisteredExternalClasses: {
  90768. [key: string]: Object;
  90769. };
  90770. /**
  90771. * Texture content used if a texture cannot loaded
  90772. * @ignorenaming
  90773. */
  90774. static fallbackTexture: string;
  90775. /**
  90776. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90777. * @param u defines the coordinate on X axis
  90778. * @param v defines the coordinate on Y axis
  90779. * @param width defines the width of the source data
  90780. * @param height defines the height of the source data
  90781. * @param pixels defines the source byte array
  90782. * @param color defines the output color
  90783. */
  90784. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90785. /**
  90786. * Interpolates between a and b via alpha
  90787. * @param a The lower value (returned when alpha = 0)
  90788. * @param b The upper value (returned when alpha = 1)
  90789. * @param alpha The interpolation-factor
  90790. * @return The mixed value
  90791. */
  90792. static Mix(a: number, b: number, alpha: number): number;
  90793. /**
  90794. * Tries to instantiate a new object from a given class name
  90795. * @param className defines the class name to instantiate
  90796. * @returns the new object or null if the system was not able to do the instantiation
  90797. */
  90798. static Instantiate(className: string): any;
  90799. /**
  90800. * Provides a slice function that will work even on IE
  90801. * @param data defines the array to slice
  90802. * @param start defines the start of the data (optional)
  90803. * @param end defines the end of the data (optional)
  90804. * @returns the new sliced array
  90805. */
  90806. static Slice<T>(data: T, start?: number, end?: number): T;
  90807. /**
  90808. * Polyfill for setImmediate
  90809. * @param action defines the action to execute after the current execution block
  90810. */
  90811. static SetImmediate(action: () => void): void;
  90812. /**
  90813. * Function indicating if a number is an exponent of 2
  90814. * @param value defines the value to test
  90815. * @returns true if the value is an exponent of 2
  90816. */
  90817. static IsExponentOfTwo(value: number): boolean;
  90818. private static _tmpFloatArray;
  90819. /**
  90820. * Returns the nearest 32-bit single precision float representation of a Number
  90821. * @param value A Number. If the parameter is of a different type, it will get converted
  90822. * to a number or to NaN if it cannot be converted
  90823. * @returns number
  90824. */
  90825. static FloatRound(value: number): number;
  90826. /**
  90827. * Find the next highest power of two.
  90828. * @param x Number to start search from.
  90829. * @return Next highest power of two.
  90830. */
  90831. static CeilingPOT(x: number): number;
  90832. /**
  90833. * Find the next lowest power of two.
  90834. * @param x Number to start search from.
  90835. * @return Next lowest power of two.
  90836. */
  90837. static FloorPOT(x: number): number;
  90838. /**
  90839. * Find the nearest power of two.
  90840. * @param x Number to start search from.
  90841. * @return Next nearest power of two.
  90842. */
  90843. static NearestPOT(x: number): number;
  90844. /**
  90845. * Get the closest exponent of two
  90846. * @param value defines the value to approximate
  90847. * @param max defines the maximum value to return
  90848. * @param mode defines how to define the closest value
  90849. * @returns closest exponent of two of the given value
  90850. */
  90851. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90852. /**
  90853. * Extracts the filename from a path
  90854. * @param path defines the path to use
  90855. * @returns the filename
  90856. */
  90857. static GetFilename(path: string): string;
  90858. /**
  90859. * Extracts the "folder" part of a path (everything before the filename).
  90860. * @param uri The URI to extract the info from
  90861. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90862. * @returns The "folder" part of the path
  90863. */
  90864. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90865. /**
  90866. * Extracts text content from a DOM element hierarchy
  90867. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90868. */
  90869. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90870. /**
  90871. * Convert an angle in radians to degrees
  90872. * @param angle defines the angle to convert
  90873. * @returns the angle in degrees
  90874. */
  90875. static ToDegrees(angle: number): number;
  90876. /**
  90877. * Convert an angle in degrees to radians
  90878. * @param angle defines the angle to convert
  90879. * @returns the angle in radians
  90880. */
  90881. static ToRadians(angle: number): number;
  90882. /**
  90883. * Encode a buffer to a base64 string
  90884. * @param buffer defines the buffer to encode
  90885. * @returns the encoded string
  90886. */
  90887. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90888. /**
  90889. * Extracts minimum and maximum values from a list of indexed positions
  90890. * @param positions defines the positions to use
  90891. * @param indices defines the indices to the positions
  90892. * @param indexStart defines the start index
  90893. * @param indexCount defines the end index
  90894. * @param bias defines bias value to add to the result
  90895. * @return minimum and maximum values
  90896. */
  90897. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90898. minimum: Vector3;
  90899. maximum: Vector3;
  90900. };
  90901. /**
  90902. * Extracts minimum and maximum values from a list of positions
  90903. * @param positions defines the positions to use
  90904. * @param start defines the start index in the positions array
  90905. * @param count defines the number of positions to handle
  90906. * @param bias defines bias value to add to the result
  90907. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90908. * @return minimum and maximum values
  90909. */
  90910. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90911. minimum: Vector3;
  90912. maximum: Vector3;
  90913. };
  90914. /**
  90915. * Returns an array if obj is not an array
  90916. * @param obj defines the object to evaluate as an array
  90917. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90918. * @returns either obj directly if obj is an array or a new array containing obj
  90919. */
  90920. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90921. /**
  90922. * Gets the pointer prefix to use
  90923. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90924. */
  90925. static GetPointerPrefix(): string;
  90926. /**
  90927. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90928. * @param func - the function to be called
  90929. * @param requester - the object that will request the next frame. Falls back to window.
  90930. * @returns frame number
  90931. */
  90932. static QueueNewFrame(func: () => void, requester?: any): number;
  90933. /**
  90934. * Ask the browser to promote the current element to fullscreen rendering mode
  90935. * @param element defines the DOM element to promote
  90936. */
  90937. static RequestFullscreen(element: HTMLElement): void;
  90938. /**
  90939. * Asks the browser to exit fullscreen mode
  90940. */
  90941. static ExitFullscreen(): void;
  90942. /**
  90943. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90944. * @param url define the url we are trying
  90945. * @param element define the dom element where to configure the cors policy
  90946. */
  90947. static SetCorsBehavior(url: string | string[], element: {
  90948. crossOrigin: string | null;
  90949. }): void;
  90950. /**
  90951. * Removes unwanted characters from an url
  90952. * @param url defines the url to clean
  90953. * @returns the cleaned url
  90954. */
  90955. static CleanUrl(url: string): string;
  90956. /**
  90957. * Gets or sets a function used to pre-process url before using them to load assets
  90958. */
  90959. static PreprocessUrl: (url: string) => string;
  90960. /**
  90961. * Loads an image as an HTMLImageElement.
  90962. * @param input url string, ArrayBuffer, or Blob to load
  90963. * @param onLoad callback called when the image successfully loads
  90964. * @param onError callback called when the image fails to load
  90965. * @param offlineProvider offline provider for caching
  90966. * @returns the HTMLImageElement of the loaded image
  90967. */
  90968. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90969. /**
  90970. * Loads a file
  90971. * @param url url string, ArrayBuffer, or Blob to load
  90972. * @param onSuccess callback called when the file successfully loads
  90973. * @param onProgress callback called while file is loading (if the server supports this mode)
  90974. * @param offlineProvider defines the offline provider for caching
  90975. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90976. * @param onError callback called when the file fails to load
  90977. * @returns a file request object
  90978. */
  90979. 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;
  90980. /**
  90981. * Load a script (identified by an url). When the url returns, the
  90982. * content of this file is added into a new script element, attached to the DOM (body element)
  90983. * @param scriptUrl defines the url of the script to laod
  90984. * @param onSuccess defines the callback called when the script is loaded
  90985. * @param onError defines the callback to call if an error occurs
  90986. * @param scriptId defines the id of the script element
  90987. */
  90988. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90989. /**
  90990. * Load an asynchronous 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 scriptId defines the id of the script element
  90994. * @returns a promise request object
  90995. */
  90996. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90997. /**
  90998. * Loads a file from a blob
  90999. * @param fileToLoad defines the blob to use
  91000. * @param callback defines the callback to call when data is loaded
  91001. * @param progressCallback defines the callback to call during loading process
  91002. * @returns a file request object
  91003. */
  91004. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91005. /**
  91006. * Loads a file
  91007. * @param fileToLoad defines the file to load
  91008. * @param callback defines the callback to call when data is loaded
  91009. * @param progressCallBack defines the callback to call during loading process
  91010. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91011. * @returns a file request object
  91012. */
  91013. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91014. /**
  91015. * Creates a data url from a given string content
  91016. * @param content defines the content to convert
  91017. * @returns the new data url link
  91018. */
  91019. static FileAsURL(content: string): string;
  91020. /**
  91021. * Format the given number to a specific decimal format
  91022. * @param value defines the number to format
  91023. * @param decimals defines the number of decimals to use
  91024. * @returns the formatted string
  91025. */
  91026. static Format(value: number, decimals?: number): string;
  91027. /**
  91028. * Checks if a given vector is inside a specific range
  91029. * @param v defines the vector to test
  91030. * @param min defines the minimum range
  91031. * @param max defines the maximum range
  91032. */
  91033. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91034. /**
  91035. * Tries to copy an object by duplicating every property
  91036. * @param source defines the source object
  91037. * @param destination defines the target object
  91038. * @param doNotCopyList defines a list of properties to avoid
  91039. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91040. */
  91041. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91042. /**
  91043. * Gets a boolean indicating if the given object has no own property
  91044. * @param obj defines the object to test
  91045. * @returns true if object has no own property
  91046. */
  91047. static IsEmpty(obj: any): boolean;
  91048. /**
  91049. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91050. * @param str Source string
  91051. * @param suffix Suffix to search for in the source string
  91052. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91053. */
  91054. static EndsWith(str: string, suffix: string): boolean;
  91055. /**
  91056. * Function used to register events at window level
  91057. * @param events defines the events to register
  91058. */
  91059. static RegisterTopRootEvents(events: {
  91060. name: string;
  91061. handler: Nullable<(e: FocusEvent) => any>;
  91062. }[]): void;
  91063. /**
  91064. * Function used to unregister events from window level
  91065. * @param events defines the events to unregister
  91066. */
  91067. static UnregisterTopRootEvents(events: {
  91068. name: string;
  91069. handler: Nullable<(e: FocusEvent) => any>;
  91070. }[]): void;
  91071. /**
  91072. * @ignore
  91073. */
  91074. static _ScreenshotCanvas: HTMLCanvasElement;
  91075. /**
  91076. * Dumps the current bound framebuffer
  91077. * @param width defines the rendering width
  91078. * @param height defines the rendering height
  91079. * @param engine defines the hosting engine
  91080. * @param successCallback defines the callback triggered once the data are available
  91081. * @param mimeType defines the mime type of the result
  91082. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91083. */
  91084. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91085. /**
  91086. * Converts the canvas data to blob.
  91087. * This acts as a polyfill for browsers not supporting the to blob function.
  91088. * @param canvas Defines the canvas to extract the data from
  91089. * @param successCallback Defines the callback triggered once the data are available
  91090. * @param mimeType Defines the mime type of the result
  91091. */
  91092. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91093. /**
  91094. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91095. * @param successCallback defines the callback triggered once the data are available
  91096. * @param mimeType defines the mime type of the result
  91097. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91098. */
  91099. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91100. /**
  91101. * Downloads a blob in the browser
  91102. * @param blob defines the blob to download
  91103. * @param fileName defines the name of the downloaded file
  91104. */
  91105. static Download(blob: Blob, fileName: string): void;
  91106. /**
  91107. * Captures a screenshot of the current rendering
  91108. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91109. * @param engine defines the rendering engine
  91110. * @param camera defines the source camera
  91111. * @param size This parameter can be set to a single number or to an object with the
  91112. * following (optional) properties: precision, width, height. If a single number is passed,
  91113. * it will be used for both width and height. If an object is passed, the screenshot size
  91114. * will be derived from the parameters. The precision property is a multiplier allowing
  91115. * rendering at a higher or lower resolution
  91116. * @param successCallback defines the callback receives a single parameter which contains the
  91117. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91118. * src parameter of an <img> to display it
  91119. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91120. * Check your browser for supported MIME types
  91121. */
  91122. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91123. /**
  91124. * Generates an image screenshot from the specified camera.
  91125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91126. * @param engine The engine to use for rendering
  91127. * @param camera The camera to use for rendering
  91128. * @param size This parameter can be set to a single number or to an object with the
  91129. * following (optional) properties: precision, width, height. If a single number is passed,
  91130. * it will be used for both width and height. If an object is passed, the screenshot size
  91131. * will be derived from the parameters. The precision property is a multiplier allowing
  91132. * rendering at a higher or lower resolution
  91133. * @param successCallback The callback receives a single parameter which contains the
  91134. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91135. * src parameter of an <img> to display it
  91136. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91137. * Check your browser for supported MIME types
  91138. * @param samples Texture samples (default: 1)
  91139. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91140. * @param fileName A name for for the downloaded file.
  91141. */
  91142. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91143. /**
  91144. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91145. * Be aware Math.random() could cause collisions, but:
  91146. * "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"
  91147. * @returns a pseudo random id
  91148. */
  91149. static RandomId(): string;
  91150. /**
  91151. * Test if the given uri is a base64 string
  91152. * @param uri The uri to test
  91153. * @return True if the uri is a base64 string or false otherwise
  91154. */
  91155. static IsBase64(uri: string): boolean;
  91156. /**
  91157. * Decode the given base64 uri.
  91158. * @param uri The uri to decode
  91159. * @return The decoded base64 data.
  91160. */
  91161. static DecodeBase64(uri: string): ArrayBuffer;
  91162. /**
  91163. * Gets the absolute url.
  91164. * @param url the input url
  91165. * @return the absolute url
  91166. */
  91167. static GetAbsoluteUrl(url: string): string;
  91168. /**
  91169. * No log
  91170. */
  91171. static readonly NoneLogLevel: number;
  91172. /**
  91173. * Only message logs
  91174. */
  91175. static readonly MessageLogLevel: number;
  91176. /**
  91177. * Only warning logs
  91178. */
  91179. static readonly WarningLogLevel: number;
  91180. /**
  91181. * Only error logs
  91182. */
  91183. static readonly ErrorLogLevel: number;
  91184. /**
  91185. * All logs
  91186. */
  91187. static readonly AllLogLevel: number;
  91188. /**
  91189. * Gets a value indicating the number of loading errors
  91190. * @ignorenaming
  91191. */
  91192. static readonly errorsCount: number;
  91193. /**
  91194. * Callback called when a new log is added
  91195. */
  91196. static OnNewCacheEntry: (entry: string) => void;
  91197. /**
  91198. * Log a message to the console
  91199. * @param message defines the message to log
  91200. */
  91201. static Log(message: string): void;
  91202. /**
  91203. * Write a warning message to the console
  91204. * @param message defines the message to log
  91205. */
  91206. static Warn(message: string): void;
  91207. /**
  91208. * Write an error message to the console
  91209. * @param message defines the message to log
  91210. */
  91211. static Error(message: string): void;
  91212. /**
  91213. * Gets current log cache (list of logs)
  91214. */
  91215. static readonly LogCache: string;
  91216. /**
  91217. * Clears the log cache
  91218. */
  91219. static ClearLogCache(): void;
  91220. /**
  91221. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91222. */
  91223. static LogLevels: number;
  91224. /**
  91225. * Checks if the loaded document was accessed via `file:`-Protocol.
  91226. * @returns boolean
  91227. */
  91228. static IsFileURL(): boolean;
  91229. /**
  91230. * Checks if the window object exists
  91231. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91232. */
  91233. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91234. /**
  91235. * No performance log
  91236. */
  91237. static readonly PerformanceNoneLogLevel: number;
  91238. /**
  91239. * Use user marks to log performance
  91240. */
  91241. static readonly PerformanceUserMarkLogLevel: number;
  91242. /**
  91243. * Log performance to the console
  91244. */
  91245. static readonly PerformanceConsoleLogLevel: number;
  91246. private static _performance;
  91247. /**
  91248. * Sets the current performance log level
  91249. */
  91250. static PerformanceLogLevel: number;
  91251. private static _StartPerformanceCounterDisabled;
  91252. private static _EndPerformanceCounterDisabled;
  91253. private static _StartUserMark;
  91254. private static _EndUserMark;
  91255. private static _StartPerformanceConsole;
  91256. private static _EndPerformanceConsole;
  91257. /**
  91258. * Starts a performance counter
  91259. */
  91260. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91261. /**
  91262. * Ends a specific performance coutner
  91263. */
  91264. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91265. /**
  91266. * Gets either window.performance.now() if supported or Date.now() else
  91267. */
  91268. static readonly Now: number;
  91269. /**
  91270. * This method will return the name of the class used to create the instance of the given object.
  91271. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91272. * @param object the object to get the class name from
  91273. * @param isType defines if the object is actually a type
  91274. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91275. */
  91276. static GetClassName(object: any, isType?: boolean): string;
  91277. /**
  91278. * Gets the first element of an array satisfying a given predicate
  91279. * @param array defines the array to browse
  91280. * @param predicate defines the predicate to use
  91281. * @returns null if not found or the element
  91282. */
  91283. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91284. /**
  91285. * This method will return the name of the full name of the class, including its owning module (if any).
  91286. * 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).
  91287. * @param object the object to get the class name from
  91288. * @param isType defines if the object is actually a type
  91289. * @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.
  91290. * @ignorenaming
  91291. */
  91292. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91293. /**
  91294. * Returns a promise that resolves after the given amount of time.
  91295. * @param delay Number of milliseconds to delay
  91296. * @returns Promise that resolves after the given amount of time
  91297. */
  91298. static DelayAsync(delay: number): Promise<void>;
  91299. /**
  91300. * Gets the current gradient from an array of IValueGradient
  91301. * @param ratio defines the current ratio to get
  91302. * @param gradients defines the array of IValueGradient
  91303. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91304. */
  91305. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91306. }
  91307. /**
  91308. * This class is used to track a performance counter which is number based.
  91309. * The user has access to many properties which give statistics of different nature.
  91310. *
  91311. * The implementer can track two kinds of Performance Counter: time and count.
  91312. * 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.
  91313. * 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.
  91314. */
  91315. export class PerfCounter {
  91316. /**
  91317. * Gets or sets a global boolean to turn on and off all the counters
  91318. */
  91319. static Enabled: boolean;
  91320. /**
  91321. * Returns the smallest value ever
  91322. */
  91323. readonly min: number;
  91324. /**
  91325. * Returns the biggest value ever
  91326. */
  91327. readonly max: number;
  91328. /**
  91329. * Returns the average value since the performance counter is running
  91330. */
  91331. readonly average: number;
  91332. /**
  91333. * Returns the average value of the last second the counter was monitored
  91334. */
  91335. readonly lastSecAverage: number;
  91336. /**
  91337. * Returns the current value
  91338. */
  91339. readonly current: number;
  91340. /**
  91341. * Gets the accumulated total
  91342. */
  91343. readonly total: number;
  91344. /**
  91345. * Gets the total value count
  91346. */
  91347. readonly count: number;
  91348. /**
  91349. * Creates a new counter
  91350. */
  91351. constructor();
  91352. /**
  91353. * Call this method to start monitoring a new frame.
  91354. * 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.
  91355. */
  91356. fetchNewFrame(): void;
  91357. /**
  91358. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91359. * @param newCount the count value to add to the monitored count
  91360. * @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.
  91361. */
  91362. addCount(newCount: number, fetchResult: boolean): void;
  91363. /**
  91364. * Start monitoring this performance counter
  91365. */
  91366. beginMonitoring(): void;
  91367. /**
  91368. * Compute the time lapsed since the previous beginMonitoring() call.
  91369. * @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
  91370. */
  91371. endMonitoring(newFrame?: boolean): void;
  91372. private _fetchResult;
  91373. private _startMonitoringTime;
  91374. private _min;
  91375. private _max;
  91376. private _average;
  91377. private _current;
  91378. private _totalValueCount;
  91379. private _totalAccumulated;
  91380. private _lastSecAverage;
  91381. private _lastSecAccumulated;
  91382. private _lastSecTime;
  91383. private _lastSecValueCount;
  91384. }
  91385. /**
  91386. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91387. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91388. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91389. * @param name The name of the class, case should be preserved
  91390. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91391. */
  91392. export function className(name: string, module?: string): (target: Object) => void;
  91393. /**
  91394. * An implementation of a loop for asynchronous functions.
  91395. */
  91396. export class AsyncLoop {
  91397. /**
  91398. * Defines the number of iterations for the loop
  91399. */
  91400. iterations: number;
  91401. /**
  91402. * Defines the current index of the loop.
  91403. */
  91404. index: number;
  91405. private _done;
  91406. private _fn;
  91407. private _successCallback;
  91408. /**
  91409. * Constructor.
  91410. * @param iterations the number of iterations.
  91411. * @param func the function to run each iteration
  91412. * @param successCallback the callback that will be called upon succesful execution
  91413. * @param offset starting offset.
  91414. */
  91415. constructor(
  91416. /**
  91417. * Defines the number of iterations for the loop
  91418. */
  91419. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91420. /**
  91421. * Execute the next iteration. Must be called after the last iteration was finished.
  91422. */
  91423. executeNext(): void;
  91424. /**
  91425. * Break the loop and run the success callback.
  91426. */
  91427. breakLoop(): void;
  91428. /**
  91429. * Create and run an async loop.
  91430. * @param iterations the number of iterations.
  91431. * @param fn the function to run each iteration
  91432. * @param successCallback the callback that will be called upon succesful execution
  91433. * @param offset starting offset.
  91434. * @returns the created async loop object
  91435. */
  91436. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91437. /**
  91438. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91439. * @param iterations total number of iterations
  91440. * @param syncedIterations number of synchronous iterations in each async iteration.
  91441. * @param fn the function to call each iteration.
  91442. * @param callback a success call back that will be called when iterating stops.
  91443. * @param breakFunction a break condition (optional)
  91444. * @param timeout timeout settings for the setTimeout function. default - 0.
  91445. * @returns the created async loop object
  91446. */
  91447. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91448. }
  91449. }
  91450. declare module BABYLON {
  91451. /** @hidden */
  91452. export interface ICollisionCoordinator {
  91453. createCollider(): Collider;
  91454. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91455. init(scene: Scene): void;
  91456. }
  91457. /** @hidden */
  91458. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91459. private _scene;
  91460. private _scaledPosition;
  91461. private _scaledVelocity;
  91462. private _finalPosition;
  91463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91464. createCollider(): Collider;
  91465. init(scene: Scene): void;
  91466. private _collideWithWorld;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /**
  91471. * Class used to manage all inputs for the scene.
  91472. */
  91473. export class InputManager {
  91474. /** The distance in pixel that you have to move to prevent some events */
  91475. static DragMovementThreshold: number;
  91476. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91477. static LongPressDelay: number;
  91478. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91479. static DoubleClickDelay: number;
  91480. /** If you need to check double click without raising a single click at first click, enable this flag */
  91481. static ExclusiveDoubleClickMode: boolean;
  91482. private _wheelEventName;
  91483. private _onPointerMove;
  91484. private _onPointerDown;
  91485. private _onPointerUp;
  91486. private _initClickEvent;
  91487. private _initActionManager;
  91488. private _delayedSimpleClick;
  91489. private _delayedSimpleClickTimeout;
  91490. private _previousDelayedSimpleClickTimeout;
  91491. private _meshPickProceed;
  91492. private _previousButtonPressed;
  91493. private _currentPickResult;
  91494. private _previousPickResult;
  91495. private _totalPointersPressed;
  91496. private _doubleClickOccured;
  91497. private _pointerOverMesh;
  91498. private _pickedDownMesh;
  91499. private _pickedUpMesh;
  91500. private _pointerX;
  91501. private _pointerY;
  91502. private _unTranslatedPointerX;
  91503. private _unTranslatedPointerY;
  91504. private _startingPointerPosition;
  91505. private _previousStartingPointerPosition;
  91506. private _startingPointerTime;
  91507. private _previousStartingPointerTime;
  91508. private _pointerCaptures;
  91509. private _onKeyDown;
  91510. private _onKeyUp;
  91511. private _onCanvasFocusObserver;
  91512. private _onCanvasBlurObserver;
  91513. private _scene;
  91514. /**
  91515. * Creates a new InputManager
  91516. * @param scene defines the hosting scene
  91517. */
  91518. constructor(scene: Scene);
  91519. /**
  91520. * Gets the mesh that is currently under the pointer
  91521. */
  91522. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91523. /**
  91524. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91525. */
  91526. readonly unTranslatedPointer: Vector2;
  91527. /**
  91528. * Gets or sets the current on-screen X position of the pointer
  91529. */
  91530. pointerX: number;
  91531. /**
  91532. * Gets or sets the current on-screen Y position of the pointer
  91533. */
  91534. pointerY: number;
  91535. private _updatePointerPosition;
  91536. private _processPointerMove;
  91537. private _setRayOnPointerInfo;
  91538. private _checkPrePointerObservable;
  91539. /**
  91540. * Use this method to simulate a pointer move on a mesh
  91541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91544. */
  91545. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91546. /**
  91547. * Use this method to simulate a pointer down on a mesh
  91548. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91549. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91550. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91551. */
  91552. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91553. private _processPointerDown;
  91554. /** @hidden */
  91555. _isPointerSwiping(): boolean;
  91556. /**
  91557. * Use this method to simulate a pointer up on a mesh
  91558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91561. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91562. */
  91563. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91564. private _processPointerUp;
  91565. /**
  91566. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91567. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91568. * @returns true if the pointer was captured
  91569. */
  91570. isPointerCaptured(pointerId?: number): boolean;
  91571. /**
  91572. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91573. * @param attachUp defines if you want to attach events to pointerup
  91574. * @param attachDown defines if you want to attach events to pointerdown
  91575. * @param attachMove defines if you want to attach events to pointermove
  91576. */
  91577. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91578. /**
  91579. * Detaches all event handlers
  91580. */
  91581. detachControl(): void;
  91582. /**
  91583. * Force the value of meshUnderPointer
  91584. * @param mesh defines the mesh to use
  91585. */
  91586. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91587. /**
  91588. * Gets the mesh under the pointer
  91589. * @returns a Mesh or null if no mesh is under the pointer
  91590. */
  91591. getPointerOverMesh(): Nullable<AbstractMesh>;
  91592. }
  91593. }
  91594. declare module BABYLON {
  91595. /**
  91596. * This class defines the direct association between an animation and a target
  91597. */
  91598. export class TargetedAnimation {
  91599. /**
  91600. * Animation to perform
  91601. */
  91602. animation: Animation;
  91603. /**
  91604. * Target to animate
  91605. */
  91606. target: any;
  91607. }
  91608. /**
  91609. * Use this class to create coordinated animations on multiple targets
  91610. */
  91611. export class AnimationGroup implements IDisposable {
  91612. /** The name of the animation group */
  91613. name: string;
  91614. private _scene;
  91615. private _targetedAnimations;
  91616. private _animatables;
  91617. private _from;
  91618. private _to;
  91619. private _isStarted;
  91620. private _isPaused;
  91621. private _speedRatio;
  91622. /**
  91623. * Gets or sets the unique id of the node
  91624. */
  91625. uniqueId: number;
  91626. /**
  91627. * This observable will notify when one animation have ended
  91628. */
  91629. onAnimationEndObservable: Observable<TargetedAnimation>;
  91630. /**
  91631. * Observer raised when one animation loops
  91632. */
  91633. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91634. /**
  91635. * This observable will notify when all animations have ended.
  91636. */
  91637. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91638. /**
  91639. * This observable will notify when all animations have paused.
  91640. */
  91641. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91642. /**
  91643. * This observable will notify when all animations are playing.
  91644. */
  91645. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91646. /**
  91647. * Gets the first frame
  91648. */
  91649. readonly from: number;
  91650. /**
  91651. * Gets the last frame
  91652. */
  91653. readonly to: number;
  91654. /**
  91655. * Define if the animations are started
  91656. */
  91657. readonly isStarted: boolean;
  91658. /**
  91659. * Gets a value indicating that the current group is playing
  91660. */
  91661. readonly isPlaying: boolean;
  91662. /**
  91663. * Gets or sets the speed ratio to use for all animations
  91664. */
  91665. /**
  91666. * Gets or sets the speed ratio to use for all animations
  91667. */
  91668. speedRatio: number;
  91669. /**
  91670. * Gets the targeted animations for this animation group
  91671. */
  91672. readonly targetedAnimations: Array<TargetedAnimation>;
  91673. /**
  91674. * returning the list of animatables controlled by this animation group.
  91675. */
  91676. readonly animatables: Array<Animatable>;
  91677. /**
  91678. * Instantiates a new Animation Group.
  91679. * This helps managing several animations at once.
  91680. * @see http://doc.babylonjs.com/how_to/group
  91681. * @param name Defines the name of the group
  91682. * @param scene Defines the scene the group belongs to
  91683. */
  91684. constructor(
  91685. /** The name of the animation group */
  91686. name: string, scene?: Nullable<Scene>);
  91687. /**
  91688. * Add an animation (with its target) in the group
  91689. * @param animation defines the animation we want to add
  91690. * @param target defines the target of the animation
  91691. * @returns the TargetedAnimation object
  91692. */
  91693. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91694. /**
  91695. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91696. * It can add constant keys at begin or end
  91697. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91698. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91699. * @returns the animation group
  91700. */
  91701. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91702. /**
  91703. * Start all animations on given targets
  91704. * @param loop defines if animations must loop
  91705. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91706. * @param from defines the from key (optional)
  91707. * @param to defines the to key (optional)
  91708. * @returns the current animation group
  91709. */
  91710. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91711. /**
  91712. * Pause all animations
  91713. * @returns the animation group
  91714. */
  91715. pause(): AnimationGroup;
  91716. /**
  91717. * Play all animations to initial state
  91718. * This function will start() the animations if they were not started or will restart() them if they were paused
  91719. * @param loop defines if animations must loop
  91720. * @returns the animation group
  91721. */
  91722. play(loop?: boolean): AnimationGroup;
  91723. /**
  91724. * Reset all animations to initial state
  91725. * @returns the animation group
  91726. */
  91727. reset(): AnimationGroup;
  91728. /**
  91729. * Restart animations from key 0
  91730. * @returns the animation group
  91731. */
  91732. restart(): AnimationGroup;
  91733. /**
  91734. * Stop all animations
  91735. * @returns the animation group
  91736. */
  91737. stop(): AnimationGroup;
  91738. /**
  91739. * Set animation weight for all animatables
  91740. * @param weight defines the weight to use
  91741. * @return the animationGroup
  91742. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91743. */
  91744. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91745. /**
  91746. * Synchronize and normalize all animatables with a source animatable
  91747. * @param root defines the root animatable to synchronize with
  91748. * @return the animationGroup
  91749. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91750. */
  91751. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91752. /**
  91753. * Goes to a specific frame in this animation group
  91754. * @param frame the frame number to go to
  91755. * @return the animationGroup
  91756. */
  91757. goToFrame(frame: number): AnimationGroup;
  91758. /**
  91759. * Dispose all associated resources
  91760. */
  91761. dispose(): void;
  91762. private _checkAnimationGroupEnded;
  91763. /**
  91764. * Clone the current animation group and returns a copy
  91765. * @param newName defines the name of the new group
  91766. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91767. * @returns the new aniamtion group
  91768. */
  91769. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91770. /**
  91771. * Returns a new AnimationGroup object parsed from the source provided.
  91772. * @param parsedAnimationGroup defines the source
  91773. * @param scene defines the scene that will receive the animationGroup
  91774. * @returns a new AnimationGroup
  91775. */
  91776. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91777. /**
  91778. * Returns the string "AnimationGroup"
  91779. * @returns "AnimationGroup"
  91780. */
  91781. getClassName(): string;
  91782. /**
  91783. * Creates a detailled string about the object
  91784. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91785. * @returns a string representing the object
  91786. */
  91787. toString(fullDetails?: boolean): string;
  91788. }
  91789. }
  91790. declare module BABYLON {
  91791. /**
  91792. * Define an interface for all classes that will hold resources
  91793. */
  91794. export interface IDisposable {
  91795. /**
  91796. * Releases all held resources
  91797. */
  91798. dispose(): void;
  91799. }
  91800. /** Interface defining initialization parameters for Scene class */
  91801. export interface SceneOptions {
  91802. /**
  91803. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91804. * It will improve performance when the number of geometries becomes important.
  91805. */
  91806. useGeometryUniqueIdsMap?: boolean;
  91807. /**
  91808. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91809. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91810. */
  91811. useMaterialMeshMap?: boolean;
  91812. /**
  91813. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91814. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91815. */
  91816. useClonedMeshhMap?: boolean;
  91817. }
  91818. /**
  91819. * Represents a scene to be rendered by the engine.
  91820. * @see http://doc.babylonjs.com/features/scene
  91821. */
  91822. export class Scene extends AbstractScene implements IAnimatable {
  91823. private static _uniqueIdCounter;
  91824. /** The fog is deactivated */
  91825. static readonly FOGMODE_NONE: number;
  91826. /** The fog density is following an exponential function */
  91827. static readonly FOGMODE_EXP: number;
  91828. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91829. static readonly FOGMODE_EXP2: number;
  91830. /** The fog density is following a linear function. */
  91831. static readonly FOGMODE_LINEAR: number;
  91832. /**
  91833. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91834. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91835. */
  91836. static MinDeltaTime: number;
  91837. /**
  91838. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91839. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91840. */
  91841. static MaxDeltaTime: number;
  91842. /**
  91843. * Factory used to create the default material.
  91844. * @param name The name of the material to create
  91845. * @param scene The scene to create the material for
  91846. * @returns The default material
  91847. */
  91848. static DefaultMaterialFactory(scene: Scene): Material;
  91849. /**
  91850. * Factory used to create the a collision coordinator.
  91851. * @returns The collision coordinator
  91852. */
  91853. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91854. /** @hidden */
  91855. _inputManager: InputManager;
  91856. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91857. cameraToUseForPointers: Nullable<Camera>;
  91858. /** @hidden */
  91859. readonly _isScene: boolean;
  91860. /**
  91861. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91862. */
  91863. autoClear: boolean;
  91864. /**
  91865. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91866. */
  91867. autoClearDepthAndStencil: boolean;
  91868. /**
  91869. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91870. */
  91871. clearColor: Color4;
  91872. /**
  91873. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91874. */
  91875. ambientColor: Color3;
  91876. /**
  91877. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91878. * It should only be one of the following (if not the default embedded one):
  91879. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91880. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91881. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91882. * The material properties need to be setup according to the type of texture in use.
  91883. */
  91884. environmentBRDFTexture: BaseTexture;
  91885. /** @hidden */
  91886. protected _environmentTexture: Nullable<BaseTexture>;
  91887. /**
  91888. * Texture used in all pbr material as the reflection texture.
  91889. * As in the majority of the scene they are the same (exception for multi room and so on),
  91890. * this is easier to reference from here than from all the materials.
  91891. */
  91892. /**
  91893. * Texture used in all pbr material as the reflection texture.
  91894. * As in the majority of the scene they are the same (exception for multi room and so on),
  91895. * this is easier to set here than in all the materials.
  91896. */
  91897. environmentTexture: Nullable<BaseTexture>;
  91898. /** @hidden */
  91899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91900. /**
  91901. * Default image processing configuration used either in the rendering
  91902. * Forward main pass or through the imageProcessingPostProcess if present.
  91903. * As in the majority of the scene they are the same (exception for multi camera),
  91904. * this is easier to reference from here than from all the materials and post process.
  91905. *
  91906. * No setter as we it is a shared configuration, you can set the values instead.
  91907. */
  91908. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91909. private _forceWireframe;
  91910. /**
  91911. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91912. */
  91913. forceWireframe: boolean;
  91914. private _forcePointsCloud;
  91915. /**
  91916. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91917. */
  91918. forcePointsCloud: boolean;
  91919. /**
  91920. * Gets or sets the active clipplane 1
  91921. */
  91922. clipPlane: Nullable<Plane>;
  91923. /**
  91924. * Gets or sets the active clipplane 2
  91925. */
  91926. clipPlane2: Nullable<Plane>;
  91927. /**
  91928. * Gets or sets the active clipplane 3
  91929. */
  91930. clipPlane3: Nullable<Plane>;
  91931. /**
  91932. * Gets or sets the active clipplane 4
  91933. */
  91934. clipPlane4: Nullable<Plane>;
  91935. /**
  91936. * Gets or sets a boolean indicating if animations are enabled
  91937. */
  91938. animationsEnabled: boolean;
  91939. private _animationPropertiesOverride;
  91940. /**
  91941. * Gets or sets the animation properties override
  91942. */
  91943. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91944. /**
  91945. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91946. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91947. */
  91948. useConstantAnimationDeltaTime: boolean;
  91949. /**
  91950. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91951. * Please note that it requires to run a ray cast through the scene on every frame
  91952. */
  91953. constantlyUpdateMeshUnderPointer: boolean;
  91954. /**
  91955. * Defines the HTML cursor to use when hovering over interactive elements
  91956. */
  91957. hoverCursor: string;
  91958. /**
  91959. * Defines the HTML default cursor to use (empty by default)
  91960. */
  91961. defaultCursor: string;
  91962. /**
  91963. * This is used to call preventDefault() on pointer down
  91964. * in order to block unwanted artifacts like system double clicks
  91965. */
  91966. preventDefaultOnPointerDown: boolean;
  91967. /**
  91968. * This is used to call preventDefault() on pointer up
  91969. * in order to block unwanted artifacts like system double clicks
  91970. */
  91971. preventDefaultOnPointerUp: boolean;
  91972. /**
  91973. * Gets or sets user defined metadata
  91974. */
  91975. metadata: any;
  91976. /**
  91977. * For internal use only. Please do not use.
  91978. */
  91979. reservedDataStore: any;
  91980. /**
  91981. * Gets the name of the plugin used to load this scene (null by default)
  91982. */
  91983. loadingPluginName: string;
  91984. /**
  91985. * Use this array to add regular expressions used to disable offline support for specific urls
  91986. */
  91987. disableOfflineSupportExceptionRules: RegExp[];
  91988. /**
  91989. * An event triggered when the scene is disposed.
  91990. */
  91991. onDisposeObservable: Observable<Scene>;
  91992. private _onDisposeObserver;
  91993. /** Sets a function to be executed when this scene is disposed. */
  91994. onDispose: () => void;
  91995. /**
  91996. * An event triggered before rendering the scene (right after animations and physics)
  91997. */
  91998. onBeforeRenderObservable: Observable<Scene>;
  91999. private _onBeforeRenderObserver;
  92000. /** Sets a function to be executed before rendering this scene */
  92001. beforeRender: Nullable<() => void>;
  92002. /**
  92003. * An event triggered after rendering the scene
  92004. */
  92005. onAfterRenderObservable: Observable<Scene>;
  92006. private _onAfterRenderObserver;
  92007. /** Sets a function to be executed after rendering this scene */
  92008. afterRender: Nullable<() => void>;
  92009. /**
  92010. * An event triggered before animating the scene
  92011. */
  92012. onBeforeAnimationsObservable: Observable<Scene>;
  92013. /**
  92014. * An event triggered after animations processing
  92015. */
  92016. onAfterAnimationsObservable: Observable<Scene>;
  92017. /**
  92018. * An event triggered before draw calls are ready to be sent
  92019. */
  92020. onBeforeDrawPhaseObservable: Observable<Scene>;
  92021. /**
  92022. * An event triggered after draw calls have been sent
  92023. */
  92024. onAfterDrawPhaseObservable: Observable<Scene>;
  92025. /**
  92026. * An event triggered when the scene is ready
  92027. */
  92028. onReadyObservable: Observable<Scene>;
  92029. /**
  92030. * An event triggered before rendering a camera
  92031. */
  92032. onBeforeCameraRenderObservable: Observable<Camera>;
  92033. private _onBeforeCameraRenderObserver;
  92034. /** Sets a function to be executed before rendering a camera*/
  92035. beforeCameraRender: () => void;
  92036. /**
  92037. * An event triggered after rendering a camera
  92038. */
  92039. onAfterCameraRenderObservable: Observable<Camera>;
  92040. private _onAfterCameraRenderObserver;
  92041. /** Sets a function to be executed after rendering a camera*/
  92042. afterCameraRender: () => void;
  92043. /**
  92044. * An event triggered when active meshes evaluation is about to start
  92045. */
  92046. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92047. /**
  92048. * An event triggered when active meshes evaluation is done
  92049. */
  92050. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92051. /**
  92052. * An event triggered when particles rendering is about to start
  92053. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92054. */
  92055. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92056. /**
  92057. * An event triggered when particles rendering is done
  92058. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92059. */
  92060. onAfterParticlesRenderingObservable: Observable<Scene>;
  92061. /**
  92062. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92063. */
  92064. onDataLoadedObservable: Observable<Scene>;
  92065. /**
  92066. * An event triggered when a camera is created
  92067. */
  92068. onNewCameraAddedObservable: Observable<Camera>;
  92069. /**
  92070. * An event triggered when a camera is removed
  92071. */
  92072. onCameraRemovedObservable: Observable<Camera>;
  92073. /**
  92074. * An event triggered when a light is created
  92075. */
  92076. onNewLightAddedObservable: Observable<Light>;
  92077. /**
  92078. * An event triggered when a light is removed
  92079. */
  92080. onLightRemovedObservable: Observable<Light>;
  92081. /**
  92082. * An event triggered when a geometry is created
  92083. */
  92084. onNewGeometryAddedObservable: Observable<Geometry>;
  92085. /**
  92086. * An event triggered when a geometry is removed
  92087. */
  92088. onGeometryRemovedObservable: Observable<Geometry>;
  92089. /**
  92090. * An event triggered when a transform node is created
  92091. */
  92092. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92093. /**
  92094. * An event triggered when a transform node is removed
  92095. */
  92096. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92097. /**
  92098. * An event triggered when a mesh is created
  92099. */
  92100. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92101. /**
  92102. * An event triggered when a mesh is removed
  92103. */
  92104. onMeshRemovedObservable: Observable<AbstractMesh>;
  92105. /**
  92106. * An event triggered when a skeleton is created
  92107. */
  92108. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92109. /**
  92110. * An event triggered when a skeleton is removed
  92111. */
  92112. onSkeletonRemovedObservable: Observable<Skeleton>;
  92113. /**
  92114. * An event triggered when a material is created
  92115. */
  92116. onNewMaterialAddedObservable: Observable<Material>;
  92117. /**
  92118. * An event triggered when a material is removed
  92119. */
  92120. onMaterialRemovedObservable: Observable<Material>;
  92121. /**
  92122. * An event triggered when a texture is created
  92123. */
  92124. onNewTextureAddedObservable: Observable<BaseTexture>;
  92125. /**
  92126. * An event triggered when a texture is removed
  92127. */
  92128. onTextureRemovedObservable: Observable<BaseTexture>;
  92129. /**
  92130. * An event triggered when render targets are about to be rendered
  92131. * Can happen multiple times per frame.
  92132. */
  92133. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92134. /**
  92135. * An event triggered when render targets were rendered.
  92136. * Can happen multiple times per frame.
  92137. */
  92138. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92139. /**
  92140. * An event triggered before calculating deterministic simulation step
  92141. */
  92142. onBeforeStepObservable: Observable<Scene>;
  92143. /**
  92144. * An event triggered after calculating deterministic simulation step
  92145. */
  92146. onAfterStepObservable: Observable<Scene>;
  92147. /**
  92148. * An event triggered when the activeCamera property is updated
  92149. */
  92150. onActiveCameraChanged: Observable<Scene>;
  92151. /**
  92152. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92153. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92154. * 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)
  92155. */
  92156. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92157. /**
  92158. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92159. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92160. * 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)
  92161. */
  92162. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92163. /**
  92164. * This Observable will when a mesh has been imported into the scene.
  92165. */
  92166. onMeshImportedObservable: Observable<AbstractMesh>;
  92167. /**
  92168. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92169. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92170. */
  92171. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92172. /** @hidden */
  92173. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92174. /**
  92175. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92176. */
  92177. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92178. /**
  92179. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92180. */
  92181. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92182. /**
  92183. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92184. */
  92185. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92186. /** Callback called when a pointer move is detected */
  92187. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92188. /** Callback called when a pointer down is detected */
  92189. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92190. /** Callback called when a pointer up is detected */
  92191. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92192. /** Callback called when a pointer pick is detected */
  92193. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92194. /**
  92195. * 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).
  92196. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92197. */
  92198. onPrePointerObservable: Observable<PointerInfoPre>;
  92199. /**
  92200. * Observable event triggered each time an input event is received from the rendering canvas
  92201. */
  92202. onPointerObservable: Observable<PointerInfo>;
  92203. /**
  92204. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92205. */
  92206. readonly unTranslatedPointer: Vector2;
  92207. /**
  92208. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92209. */
  92210. static DragMovementThreshold: number;
  92211. /**
  92212. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92213. */
  92214. static LongPressDelay: number;
  92215. /**
  92216. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92217. */
  92218. static DoubleClickDelay: number;
  92219. /** If you need to check double click without raising a single click at first click, enable this flag */
  92220. static ExclusiveDoubleClickMode: boolean;
  92221. /** @hidden */
  92222. _mirroredCameraPosition: Nullable<Vector3>;
  92223. /**
  92224. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92225. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92226. */
  92227. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92228. /**
  92229. * Observable event triggered each time an keyboard event is received from the hosting window
  92230. */
  92231. onKeyboardObservable: Observable<KeyboardInfo>;
  92232. private _useRightHandedSystem;
  92233. /**
  92234. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92235. */
  92236. useRightHandedSystem: boolean;
  92237. private _timeAccumulator;
  92238. private _currentStepId;
  92239. private _currentInternalStep;
  92240. /**
  92241. * Sets the step Id used by deterministic lock step
  92242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92243. * @param newStepId defines the step Id
  92244. */
  92245. setStepId(newStepId: number): void;
  92246. /**
  92247. * Gets the step Id used by deterministic lock step
  92248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92249. * @returns the step Id
  92250. */
  92251. getStepId(): number;
  92252. /**
  92253. * Gets the internal step used by deterministic lock step
  92254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92255. * @returns the internal step
  92256. */
  92257. getInternalStep(): number;
  92258. private _fogEnabled;
  92259. /**
  92260. * Gets or sets a boolean indicating if fog is enabled on this scene
  92261. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92262. * (Default is true)
  92263. */
  92264. fogEnabled: boolean;
  92265. private _fogMode;
  92266. /**
  92267. * Gets or sets the fog mode to use
  92268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92269. * | mode | value |
  92270. * | --- | --- |
  92271. * | FOGMODE_NONE | 0 |
  92272. * | FOGMODE_EXP | 1 |
  92273. * | FOGMODE_EXP2 | 2 |
  92274. * | FOGMODE_LINEAR | 3 |
  92275. */
  92276. fogMode: number;
  92277. /**
  92278. * Gets or sets the fog color to use
  92279. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92280. * (Default is Color3(0.2, 0.2, 0.3))
  92281. */
  92282. fogColor: Color3;
  92283. /**
  92284. * Gets or sets the fog density to use
  92285. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92286. * (Default is 0.1)
  92287. */
  92288. fogDensity: number;
  92289. /**
  92290. * Gets or sets the fog start distance to use
  92291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92292. * (Default is 0)
  92293. */
  92294. fogStart: number;
  92295. /**
  92296. * Gets or sets the fog end distance to use
  92297. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92298. * (Default is 1000)
  92299. */
  92300. fogEnd: number;
  92301. private _shadowsEnabled;
  92302. /**
  92303. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92304. */
  92305. shadowsEnabled: boolean;
  92306. private _lightsEnabled;
  92307. /**
  92308. * Gets or sets a boolean indicating if lights are enabled on this scene
  92309. */
  92310. lightsEnabled: boolean;
  92311. /** All of the active cameras added to this scene. */
  92312. activeCameras: Camera[];
  92313. /** @hidden */
  92314. _activeCamera: Nullable<Camera>;
  92315. /** Gets or sets the current active camera */
  92316. activeCamera: Nullable<Camera>;
  92317. private _defaultMaterial;
  92318. /** The default material used on meshes when no material is affected */
  92319. /** The default material used on meshes when no material is affected */
  92320. defaultMaterial: Material;
  92321. private _texturesEnabled;
  92322. /**
  92323. * Gets or sets a boolean indicating if textures are enabled on this scene
  92324. */
  92325. texturesEnabled: boolean;
  92326. /**
  92327. * Gets or sets a boolean indicating if particles are enabled on this scene
  92328. */
  92329. particlesEnabled: boolean;
  92330. /**
  92331. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92332. */
  92333. spritesEnabled: boolean;
  92334. private _skeletonsEnabled;
  92335. /**
  92336. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92337. */
  92338. skeletonsEnabled: boolean;
  92339. /**
  92340. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92341. */
  92342. lensFlaresEnabled: boolean;
  92343. /**
  92344. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92346. */
  92347. collisionsEnabled: boolean;
  92348. private _collisionCoordinator;
  92349. /** @hidden */
  92350. readonly collisionCoordinator: ICollisionCoordinator;
  92351. /**
  92352. * Defines the gravity applied to this scene (used only for collisions)
  92353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92354. */
  92355. gravity: Vector3;
  92356. /**
  92357. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92358. */
  92359. postProcessesEnabled: boolean;
  92360. /**
  92361. * The list of postprocesses added to the scene
  92362. */
  92363. postProcesses: PostProcess[];
  92364. /**
  92365. * Gets the current postprocess manager
  92366. */
  92367. postProcessManager: PostProcessManager;
  92368. /**
  92369. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92370. */
  92371. renderTargetsEnabled: boolean;
  92372. /**
  92373. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92374. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92375. */
  92376. dumpNextRenderTargets: boolean;
  92377. /**
  92378. * The list of user defined render targets added to the scene
  92379. */
  92380. customRenderTargets: RenderTargetTexture[];
  92381. /**
  92382. * Defines if texture loading must be delayed
  92383. * If true, textures will only be loaded when they need to be rendered
  92384. */
  92385. useDelayedTextureLoading: boolean;
  92386. /**
  92387. * Gets the list of meshes imported to the scene through SceneLoader
  92388. */
  92389. importedMeshesFiles: String[];
  92390. /**
  92391. * Gets or sets a boolean indicating if probes are enabled on this scene
  92392. */
  92393. probesEnabled: boolean;
  92394. /**
  92395. * Gets or sets the current offline provider to use to store scene data
  92396. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92397. */
  92398. offlineProvider: IOfflineProvider;
  92399. /**
  92400. * Gets or sets the action manager associated with the scene
  92401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92402. */
  92403. actionManager: AbstractActionManager;
  92404. private _meshesForIntersections;
  92405. /**
  92406. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92407. */
  92408. proceduralTexturesEnabled: boolean;
  92409. private _engine;
  92410. private _totalVertices;
  92411. /** @hidden */
  92412. _activeIndices: PerfCounter;
  92413. /** @hidden */
  92414. _activeParticles: PerfCounter;
  92415. /** @hidden */
  92416. _activeBones: PerfCounter;
  92417. private _animationRatio;
  92418. /** @hidden */
  92419. _animationTimeLast: number;
  92420. /** @hidden */
  92421. _animationTime: number;
  92422. /**
  92423. * Gets or sets a general scale for animation speed
  92424. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92425. */
  92426. animationTimeScale: number;
  92427. /** @hidden */
  92428. _cachedMaterial: Nullable<Material>;
  92429. /** @hidden */
  92430. _cachedEffect: Nullable<Effect>;
  92431. /** @hidden */
  92432. _cachedVisibility: Nullable<number>;
  92433. private _renderId;
  92434. private _frameId;
  92435. private _executeWhenReadyTimeoutId;
  92436. private _intermediateRendering;
  92437. private _viewUpdateFlag;
  92438. private _projectionUpdateFlag;
  92439. /** @hidden */
  92440. _toBeDisposed: Nullable<IDisposable>[];
  92441. private _activeRequests;
  92442. /** @hidden */
  92443. _pendingData: any[];
  92444. private _isDisposed;
  92445. /**
  92446. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92447. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92448. */
  92449. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92450. private _activeMeshes;
  92451. private _processedMaterials;
  92452. private _renderTargets;
  92453. /** @hidden */
  92454. _activeParticleSystems: SmartArray<IParticleSystem>;
  92455. private _activeSkeletons;
  92456. private _softwareSkinnedMeshes;
  92457. private _renderingManager;
  92458. /** @hidden */
  92459. _activeAnimatables: Animatable[];
  92460. private _transformMatrix;
  92461. private _sceneUbo;
  92462. /** @hidden */
  92463. _viewMatrix: Matrix;
  92464. private _projectionMatrix;
  92465. /** @hidden */
  92466. _forcedViewPosition: Nullable<Vector3>;
  92467. /** @hidden */
  92468. _frustumPlanes: Plane[];
  92469. /**
  92470. * Gets the list of frustum planes (built from the active camera)
  92471. */
  92472. readonly frustumPlanes: Plane[];
  92473. /**
  92474. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92475. * This is useful if there are more lights that the maximum simulteanous authorized
  92476. */
  92477. requireLightSorting: boolean;
  92478. /** @hidden */
  92479. readonly useMaterialMeshMap: boolean;
  92480. /** @hidden */
  92481. readonly useClonedMeshhMap: boolean;
  92482. private _externalData;
  92483. private _uid;
  92484. /**
  92485. * @hidden
  92486. * Backing store of defined scene components.
  92487. */
  92488. _components: ISceneComponent[];
  92489. /**
  92490. * @hidden
  92491. * Backing store of defined scene components.
  92492. */
  92493. _serializableComponents: ISceneSerializableComponent[];
  92494. /**
  92495. * List of components to register on the next registration step.
  92496. */
  92497. private _transientComponents;
  92498. /**
  92499. * Registers the transient components if needed.
  92500. */
  92501. private _registerTransientComponents;
  92502. /**
  92503. * @hidden
  92504. * Add a component to the scene.
  92505. * Note that the ccomponent could be registered on th next frame if this is called after
  92506. * the register component stage.
  92507. * @param component Defines the component to add to the scene
  92508. */
  92509. _addComponent(component: ISceneComponent): void;
  92510. /**
  92511. * @hidden
  92512. * Gets a component from the scene.
  92513. * @param name defines the name of the component to retrieve
  92514. * @returns the component or null if not present
  92515. */
  92516. _getComponent(name: string): Nullable<ISceneComponent>;
  92517. /**
  92518. * @hidden
  92519. * Defines the actions happening before camera updates.
  92520. */
  92521. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92522. /**
  92523. * @hidden
  92524. * Defines the actions happening before clear the canvas.
  92525. */
  92526. _beforeClearStage: Stage<SimpleStageAction>;
  92527. /**
  92528. * @hidden
  92529. * Defines the actions when collecting render targets for the frame.
  92530. */
  92531. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92532. /**
  92533. * @hidden
  92534. * Defines the actions happening for one camera in the frame.
  92535. */
  92536. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92537. /**
  92538. * @hidden
  92539. * Defines the actions happening during the per mesh ready checks.
  92540. */
  92541. _isReadyForMeshStage: Stage<MeshStageAction>;
  92542. /**
  92543. * @hidden
  92544. * Defines the actions happening before evaluate active mesh checks.
  92545. */
  92546. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92547. /**
  92548. * @hidden
  92549. * Defines the actions happening during the evaluate sub mesh checks.
  92550. */
  92551. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92552. /**
  92553. * @hidden
  92554. * Defines the actions happening during the active mesh stage.
  92555. */
  92556. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92557. /**
  92558. * @hidden
  92559. * Defines the actions happening during the per camera render target step.
  92560. */
  92561. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92562. /**
  92563. * @hidden
  92564. * Defines the actions happening just before the active camera is drawing.
  92565. */
  92566. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92567. /**
  92568. * @hidden
  92569. * Defines the actions happening just before a render target is drawing.
  92570. */
  92571. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92572. /**
  92573. * @hidden
  92574. * Defines the actions happening just before a rendering group is drawing.
  92575. */
  92576. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92577. /**
  92578. * @hidden
  92579. * Defines the actions happening just before a mesh is drawing.
  92580. */
  92581. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92582. /**
  92583. * @hidden
  92584. * Defines the actions happening just after a mesh has been drawn.
  92585. */
  92586. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92587. /**
  92588. * @hidden
  92589. * Defines the actions happening just after a rendering group has been drawn.
  92590. */
  92591. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92592. /**
  92593. * @hidden
  92594. * Defines the actions happening just after the active camera has been drawn.
  92595. */
  92596. _afterCameraDrawStage: Stage<CameraStageAction>;
  92597. /**
  92598. * @hidden
  92599. * Defines the actions happening just after a render target has been drawn.
  92600. */
  92601. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92602. /**
  92603. * @hidden
  92604. * Defines the actions happening just after rendering all cameras and computing intersections.
  92605. */
  92606. _afterRenderStage: Stage<SimpleStageAction>;
  92607. /**
  92608. * @hidden
  92609. * Defines the actions happening when a pointer move event happens.
  92610. */
  92611. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92612. /**
  92613. * @hidden
  92614. * Defines the actions happening when a pointer down event happens.
  92615. */
  92616. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92617. /**
  92618. * @hidden
  92619. * Defines the actions happening when a pointer up event happens.
  92620. */
  92621. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92622. /**
  92623. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92624. */
  92625. private geometriesByUniqueId;
  92626. /**
  92627. * Creates a new Scene
  92628. * @param engine defines the engine to use to render this scene
  92629. * @param options defines the scene options
  92630. */
  92631. constructor(engine: Engine, options?: SceneOptions);
  92632. /**
  92633. * Gets a string idenfifying the name of the class
  92634. * @returns "Scene" string
  92635. */
  92636. getClassName(): string;
  92637. private _defaultMeshCandidates;
  92638. /**
  92639. * @hidden
  92640. */
  92641. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92642. private _defaultSubMeshCandidates;
  92643. /**
  92644. * @hidden
  92645. */
  92646. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92647. /**
  92648. * Sets the default candidate providers for the scene.
  92649. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92650. * and getCollidingSubMeshCandidates to their default function
  92651. */
  92652. setDefaultCandidateProviders(): void;
  92653. /**
  92654. * Gets the mesh that is currently under the pointer
  92655. */
  92656. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92657. /**
  92658. * Gets or sets the current on-screen X position of the pointer
  92659. */
  92660. pointerX: number;
  92661. /**
  92662. * Gets or sets the current on-screen Y position of the pointer
  92663. */
  92664. pointerY: number;
  92665. /**
  92666. * Gets the cached material (ie. the latest rendered one)
  92667. * @returns the cached material
  92668. */
  92669. getCachedMaterial(): Nullable<Material>;
  92670. /**
  92671. * Gets the cached effect (ie. the latest rendered one)
  92672. * @returns the cached effect
  92673. */
  92674. getCachedEffect(): Nullable<Effect>;
  92675. /**
  92676. * Gets the cached visibility state (ie. the latest rendered one)
  92677. * @returns the cached visibility state
  92678. */
  92679. getCachedVisibility(): Nullable<number>;
  92680. /**
  92681. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92682. * @param material defines the current material
  92683. * @param effect defines the current effect
  92684. * @param visibility defines the current visibility state
  92685. * @returns true if one parameter is not cached
  92686. */
  92687. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92688. /**
  92689. * Gets the engine associated with the scene
  92690. * @returns an Engine
  92691. */
  92692. getEngine(): Engine;
  92693. /**
  92694. * Gets the total number of vertices rendered per frame
  92695. * @returns the total number of vertices rendered per frame
  92696. */
  92697. getTotalVertices(): number;
  92698. /**
  92699. * Gets the performance counter for total vertices
  92700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92701. */
  92702. readonly totalVerticesPerfCounter: PerfCounter;
  92703. /**
  92704. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92705. * @returns the total number of active indices rendered per frame
  92706. */
  92707. getActiveIndices(): number;
  92708. /**
  92709. * Gets the performance counter for active indices
  92710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92711. */
  92712. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92713. /**
  92714. * Gets the total number of active particles rendered per frame
  92715. * @returns the total number of active particles rendered per frame
  92716. */
  92717. getActiveParticles(): number;
  92718. /**
  92719. * Gets the performance counter for active particles
  92720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92721. */
  92722. readonly activeParticlesPerfCounter: PerfCounter;
  92723. /**
  92724. * Gets the total number of active bones rendered per frame
  92725. * @returns the total number of active bones rendered per frame
  92726. */
  92727. getActiveBones(): number;
  92728. /**
  92729. * Gets the performance counter for active bones
  92730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92731. */
  92732. readonly activeBonesPerfCounter: PerfCounter;
  92733. /**
  92734. * Gets the array of active meshes
  92735. * @returns an array of AbstractMesh
  92736. */
  92737. getActiveMeshes(): SmartArray<AbstractMesh>;
  92738. /**
  92739. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92740. * @returns a number
  92741. */
  92742. getAnimationRatio(): number;
  92743. /**
  92744. * Gets an unique Id for the current render phase
  92745. * @returns a number
  92746. */
  92747. getRenderId(): number;
  92748. /**
  92749. * Gets an unique Id for the current frame
  92750. * @returns a number
  92751. */
  92752. getFrameId(): number;
  92753. /** Call this function if you want to manually increment the render Id*/
  92754. incrementRenderId(): void;
  92755. private _createUbo;
  92756. /**
  92757. * Use this method to simulate a pointer move on a mesh
  92758. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92759. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92760. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92761. * @returns the current scene
  92762. */
  92763. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92764. /**
  92765. * Use this method to simulate a pointer down on a mesh
  92766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92769. * @returns the current scene
  92770. */
  92771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92772. /**
  92773. * Use this method to simulate a pointer up on a mesh
  92774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92777. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92778. * @returns the current scene
  92779. */
  92780. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92781. /**
  92782. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92783. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92784. * @returns true if the pointer was captured
  92785. */
  92786. isPointerCaptured(pointerId?: number): boolean;
  92787. /**
  92788. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92789. * @param attachUp defines if you want to attach events to pointerup
  92790. * @param attachDown defines if you want to attach events to pointerdown
  92791. * @param attachMove defines if you want to attach events to pointermove
  92792. */
  92793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92794. /** Detaches all event handlers*/
  92795. detachControl(): void;
  92796. /**
  92797. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92798. * Delay loaded resources are not taking in account
  92799. * @return true if all required resources are ready
  92800. */
  92801. isReady(): boolean;
  92802. /** Resets all cached information relative to material (including effect and visibility) */
  92803. resetCachedMaterial(): void;
  92804. /**
  92805. * Registers a function to be called before every frame render
  92806. * @param func defines the function to register
  92807. */
  92808. registerBeforeRender(func: () => void): void;
  92809. /**
  92810. * Unregisters a function called before every frame render
  92811. * @param func defines the function to unregister
  92812. */
  92813. unregisterBeforeRender(func: () => void): void;
  92814. /**
  92815. * Registers a function to be called after every frame render
  92816. * @param func defines the function to register
  92817. */
  92818. registerAfterRender(func: () => void): void;
  92819. /**
  92820. * Unregisters a function called after every frame render
  92821. * @param func defines the function to unregister
  92822. */
  92823. unregisterAfterRender(func: () => void): void;
  92824. private _executeOnceBeforeRender;
  92825. /**
  92826. * The provided function will run before render once and will be disposed afterwards.
  92827. * A timeout delay can be provided so that the function will be executed in N ms.
  92828. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92829. * @param func The function to be executed.
  92830. * @param timeout optional delay in ms
  92831. */
  92832. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92833. /** @hidden */
  92834. _addPendingData(data: any): void;
  92835. /** @hidden */
  92836. _removePendingData(data: any): void;
  92837. /**
  92838. * Returns the number of items waiting to be loaded
  92839. * @returns the number of items waiting to be loaded
  92840. */
  92841. getWaitingItemsCount(): number;
  92842. /**
  92843. * Returns a boolean indicating if the scene is still loading data
  92844. */
  92845. readonly isLoading: boolean;
  92846. /**
  92847. * Registers a function to be executed when the scene is ready
  92848. * @param {Function} func - the function to be executed
  92849. */
  92850. executeWhenReady(func: () => void): void;
  92851. /**
  92852. * Returns a promise that resolves when the scene is ready
  92853. * @returns A promise that resolves when the scene is ready
  92854. */
  92855. whenReadyAsync(): Promise<void>;
  92856. /** @hidden */
  92857. _checkIsReady(): void;
  92858. /**
  92859. * Gets all animatable attached to the scene
  92860. */
  92861. readonly animatables: Animatable[];
  92862. /**
  92863. * Resets the last animation time frame.
  92864. * Useful to override when animations start running when loading a scene for the first time.
  92865. */
  92866. resetLastAnimationTimeFrame(): void;
  92867. /**
  92868. * Gets the current view matrix
  92869. * @returns a Matrix
  92870. */
  92871. getViewMatrix(): Matrix;
  92872. /**
  92873. * Gets the current projection matrix
  92874. * @returns a Matrix
  92875. */
  92876. getProjectionMatrix(): Matrix;
  92877. /**
  92878. * Gets the current transform matrix
  92879. * @returns a Matrix made of View * Projection
  92880. */
  92881. getTransformMatrix(): Matrix;
  92882. /**
  92883. * Sets the current transform matrix
  92884. * @param viewL defines the View matrix to use
  92885. * @param projectionL defines the Projection matrix to use
  92886. * @param viewR defines the right View matrix to use (if provided)
  92887. * @param projectionR defines the right Projection matrix to use (if provided)
  92888. */
  92889. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92890. /**
  92891. * Gets the uniform buffer used to store scene data
  92892. * @returns a UniformBuffer
  92893. */
  92894. getSceneUniformBuffer(): UniformBuffer;
  92895. /**
  92896. * Gets an unique (relatively to the current scene) Id
  92897. * @returns an unique number for the scene
  92898. */
  92899. getUniqueId(): number;
  92900. /**
  92901. * Add a mesh to the list of scene's meshes
  92902. * @param newMesh defines the mesh to add
  92903. * @param recursive if all child meshes should also be added to the scene
  92904. */
  92905. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92906. /**
  92907. * Remove a mesh for the list of scene's meshes
  92908. * @param toRemove defines the mesh to remove
  92909. * @param recursive if all child meshes should also be removed from the scene
  92910. * @returns the index where the mesh was in the mesh list
  92911. */
  92912. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92913. /**
  92914. * Add a transform node to the list of scene's transform nodes
  92915. * @param newTransformNode defines the transform node to add
  92916. */
  92917. addTransformNode(newTransformNode: TransformNode): void;
  92918. /**
  92919. * Remove a transform node for the list of scene's transform nodes
  92920. * @param toRemove defines the transform node to remove
  92921. * @returns the index where the transform node was in the transform node list
  92922. */
  92923. removeTransformNode(toRemove: TransformNode): number;
  92924. /**
  92925. * Remove a skeleton for the list of scene's skeletons
  92926. * @param toRemove defines the skeleton to remove
  92927. * @returns the index where the skeleton was in the skeleton list
  92928. */
  92929. removeSkeleton(toRemove: Skeleton): number;
  92930. /**
  92931. * Remove a morph target for the list of scene's morph targets
  92932. * @param toRemove defines the morph target to remove
  92933. * @returns the index where the morph target was in the morph target list
  92934. */
  92935. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92936. /**
  92937. * Remove a light for the list of scene's lights
  92938. * @param toRemove defines the light to remove
  92939. * @returns the index where the light was in the light list
  92940. */
  92941. removeLight(toRemove: Light): number;
  92942. /**
  92943. * Remove a camera for the list of scene's cameras
  92944. * @param toRemove defines the camera to remove
  92945. * @returns the index where the camera was in the camera list
  92946. */
  92947. removeCamera(toRemove: Camera): number;
  92948. /**
  92949. * Remove a particle system for the list of scene's particle systems
  92950. * @param toRemove defines the particle system to remove
  92951. * @returns the index where the particle system was in the particle system list
  92952. */
  92953. removeParticleSystem(toRemove: IParticleSystem): number;
  92954. /**
  92955. * Remove a animation for the list of scene's animations
  92956. * @param toRemove defines the animation to remove
  92957. * @returns the index where the animation was in the animation list
  92958. */
  92959. removeAnimation(toRemove: Animation): number;
  92960. /**
  92961. * Will stop the animation of the given target
  92962. * @param target - the target
  92963. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92964. * @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)
  92965. */
  92966. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92967. /**
  92968. * Removes the given animation group from this scene.
  92969. * @param toRemove The animation group to remove
  92970. * @returns The index of the removed animation group
  92971. */
  92972. removeAnimationGroup(toRemove: AnimationGroup): number;
  92973. /**
  92974. * Removes the given multi-material from this scene.
  92975. * @param toRemove The multi-material to remove
  92976. * @returns The index of the removed multi-material
  92977. */
  92978. removeMultiMaterial(toRemove: MultiMaterial): number;
  92979. /**
  92980. * Removes the given material from this scene.
  92981. * @param toRemove The material to remove
  92982. * @returns The index of the removed material
  92983. */
  92984. removeMaterial(toRemove: Material): number;
  92985. /**
  92986. * Removes the given action manager from this scene.
  92987. * @param toRemove The action manager to remove
  92988. * @returns The index of the removed action manager
  92989. */
  92990. removeActionManager(toRemove: AbstractActionManager): number;
  92991. /**
  92992. * Removes the given texture from this scene.
  92993. * @param toRemove The texture to remove
  92994. * @returns The index of the removed texture
  92995. */
  92996. removeTexture(toRemove: BaseTexture): number;
  92997. /**
  92998. * Adds the given light to this scene
  92999. * @param newLight The light to add
  93000. */
  93001. addLight(newLight: Light): void;
  93002. /**
  93003. * Sorts the list list based on light priorities
  93004. */
  93005. sortLightsByPriority(): void;
  93006. /**
  93007. * Adds the given camera to this scene
  93008. * @param newCamera The camera to add
  93009. */
  93010. addCamera(newCamera: Camera): void;
  93011. /**
  93012. * Adds the given skeleton to this scene
  93013. * @param newSkeleton The skeleton to add
  93014. */
  93015. addSkeleton(newSkeleton: Skeleton): void;
  93016. /**
  93017. * Adds the given particle system to this scene
  93018. * @param newParticleSystem The particle system to add
  93019. */
  93020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93021. /**
  93022. * Adds the given animation to this scene
  93023. * @param newAnimation The animation to add
  93024. */
  93025. addAnimation(newAnimation: Animation): void;
  93026. /**
  93027. * Adds the given animation group to this scene.
  93028. * @param newAnimationGroup The animation group to add
  93029. */
  93030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93031. /**
  93032. * Adds the given multi-material to this scene
  93033. * @param newMultiMaterial The multi-material to add
  93034. */
  93035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93036. /**
  93037. * Adds the given material to this scene
  93038. * @param newMaterial The material to add
  93039. */
  93040. addMaterial(newMaterial: Material): void;
  93041. /**
  93042. * Adds the given morph target to this scene
  93043. * @param newMorphTargetManager The morph target to add
  93044. */
  93045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93046. /**
  93047. * Adds the given geometry to this scene
  93048. * @param newGeometry The geometry to add
  93049. */
  93050. addGeometry(newGeometry: Geometry): void;
  93051. /**
  93052. * Adds the given action manager to this scene
  93053. * @param newActionManager The action manager to add
  93054. */
  93055. addActionManager(newActionManager: AbstractActionManager): void;
  93056. /**
  93057. * Adds the given texture to this scene.
  93058. * @param newTexture The texture to add
  93059. */
  93060. addTexture(newTexture: BaseTexture): void;
  93061. /**
  93062. * Switch active camera
  93063. * @param newCamera defines the new active camera
  93064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93065. */
  93066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93067. /**
  93068. * sets the active camera of the scene using its ID
  93069. * @param id defines the camera's ID
  93070. * @return the new active camera or null if none found.
  93071. */
  93072. setActiveCameraByID(id: string): Nullable<Camera>;
  93073. /**
  93074. * sets the active camera of the scene using its name
  93075. * @param name defines the camera's name
  93076. * @returns the new active camera or null if none found.
  93077. */
  93078. setActiveCameraByName(name: string): Nullable<Camera>;
  93079. /**
  93080. * get an animation group using its name
  93081. * @param name defines the material's name
  93082. * @return the animation group or null if none found.
  93083. */
  93084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93085. /**
  93086. * Get a material using its unique id
  93087. * @param uniqueId defines the material's unique id
  93088. * @return the material or null if none found.
  93089. */
  93090. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93091. /**
  93092. * get a material using its id
  93093. * @param id defines the material's ID
  93094. * @return the material or null if none found.
  93095. */
  93096. getMaterialByID(id: string): Nullable<Material>;
  93097. /**
  93098. * Gets a material using its name
  93099. * @param name defines the material's name
  93100. * @return the material or null if none found.
  93101. */
  93102. getMaterialByName(name: string): Nullable<Material>;
  93103. /**
  93104. * Gets a camera using its id
  93105. * @param id defines the id to look for
  93106. * @returns the camera or null if not found
  93107. */
  93108. getCameraByID(id: string): Nullable<Camera>;
  93109. /**
  93110. * Gets a camera using its unique id
  93111. * @param uniqueId defines the unique id to look for
  93112. * @returns the camera or null if not found
  93113. */
  93114. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93115. /**
  93116. * Gets a camera using its name
  93117. * @param name defines the camera's name
  93118. * @return the camera or null if none found.
  93119. */
  93120. getCameraByName(name: string): Nullable<Camera>;
  93121. /**
  93122. * Gets a bone using its id
  93123. * @param id defines the bone's id
  93124. * @return the bone or null if not found
  93125. */
  93126. getBoneByID(id: string): Nullable<Bone>;
  93127. /**
  93128. * Gets a bone using its id
  93129. * @param name defines the bone's name
  93130. * @return the bone or null if not found
  93131. */
  93132. getBoneByName(name: string): Nullable<Bone>;
  93133. /**
  93134. * Gets a light node using its name
  93135. * @param name defines the the light's name
  93136. * @return the light or null if none found.
  93137. */
  93138. getLightByName(name: string): Nullable<Light>;
  93139. /**
  93140. * Gets a light node using its id
  93141. * @param id defines the light's id
  93142. * @return the light or null if none found.
  93143. */
  93144. getLightByID(id: string): Nullable<Light>;
  93145. /**
  93146. * Gets a light node using its scene-generated unique ID
  93147. * @param uniqueId defines the light's unique id
  93148. * @return the light or null if none found.
  93149. */
  93150. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93151. /**
  93152. * Gets a particle system by id
  93153. * @param id defines the particle system id
  93154. * @return the corresponding system or null if none found
  93155. */
  93156. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93157. /**
  93158. * Gets a geometry using its ID
  93159. * @param id defines the geometry's id
  93160. * @return the geometry or null if none found.
  93161. */
  93162. getGeometryByID(id: string): Nullable<Geometry>;
  93163. private _getGeometryByUniqueID;
  93164. /**
  93165. * Add a new geometry to this scene
  93166. * @param geometry defines the geometry to be added to the scene.
  93167. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93168. * @return a boolean defining if the geometry was added or not
  93169. */
  93170. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93171. /**
  93172. * Removes an existing geometry
  93173. * @param geometry defines the geometry to be removed from the scene
  93174. * @return a boolean defining if the geometry was removed or not
  93175. */
  93176. removeGeometry(geometry: Geometry): boolean;
  93177. /**
  93178. * Gets the list of geometries attached to the scene
  93179. * @returns an array of Geometry
  93180. */
  93181. getGeometries(): Geometry[];
  93182. /**
  93183. * Gets the first added mesh found of a given ID
  93184. * @param id defines the id to search for
  93185. * @return the mesh found or null if not found at all
  93186. */
  93187. getMeshByID(id: string): Nullable<AbstractMesh>;
  93188. /**
  93189. * Gets a list of meshes using their id
  93190. * @param id defines the id to search for
  93191. * @returns a list of meshes
  93192. */
  93193. getMeshesByID(id: string): Array<AbstractMesh>;
  93194. /**
  93195. * Gets the first added transform node found of a given ID
  93196. * @param id defines the id to search for
  93197. * @return the found transform node or null if not found at all.
  93198. */
  93199. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93200. /**
  93201. * Gets a transform node with its auto-generated unique id
  93202. * @param uniqueId efines the unique id to search for
  93203. * @return the found transform node or null if not found at all.
  93204. */
  93205. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93206. /**
  93207. * Gets a list of transform nodes using their id
  93208. * @param id defines the id to search for
  93209. * @returns a list of transform nodes
  93210. */
  93211. getTransformNodesByID(id: string): Array<TransformNode>;
  93212. /**
  93213. * Gets a mesh with its auto-generated unique id
  93214. * @param uniqueId defines the unique id to search for
  93215. * @return the found mesh or null if not found at all.
  93216. */
  93217. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93218. /**
  93219. * Gets a the last added mesh using a given id
  93220. * @param id defines the id to search for
  93221. * @return the found mesh or null if not found at all.
  93222. */
  93223. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93224. /**
  93225. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93226. * @param id defines the id to search for
  93227. * @return the found node or null if not found at all
  93228. */
  93229. getLastEntryByID(id: string): Nullable<Node>;
  93230. /**
  93231. * Gets a node (Mesh, Camera, Light) using a given id
  93232. * @param id defines the id to search for
  93233. * @return the found node or null if not found at all
  93234. */
  93235. getNodeByID(id: string): Nullable<Node>;
  93236. /**
  93237. * Gets a node (Mesh, Camera, Light) using a given name
  93238. * @param name defines the name to search for
  93239. * @return the found node or null if not found at all.
  93240. */
  93241. getNodeByName(name: string): Nullable<Node>;
  93242. /**
  93243. * Gets a mesh using a given name
  93244. * @param name defines the name to search for
  93245. * @return the found mesh or null if not found at all.
  93246. */
  93247. getMeshByName(name: string): Nullable<AbstractMesh>;
  93248. /**
  93249. * Gets a transform node using a given name
  93250. * @param name defines the name to search for
  93251. * @return the found transform node or null if not found at all.
  93252. */
  93253. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93254. /**
  93255. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93256. * @param id defines the id to search for
  93257. * @return the found skeleton or null if not found at all.
  93258. */
  93259. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93260. /**
  93261. * Gets a skeleton using a given auto generated unique id
  93262. * @param uniqueId defines the unique id to search for
  93263. * @return the found skeleton or null if not found at all.
  93264. */
  93265. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93266. /**
  93267. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93268. * @param id defines the id to search for
  93269. * @return the found skeleton or null if not found at all.
  93270. */
  93271. getSkeletonById(id: string): Nullable<Skeleton>;
  93272. /**
  93273. * Gets a skeleton using a given name
  93274. * @param name defines the name to search for
  93275. * @return the found skeleton or null if not found at all.
  93276. */
  93277. getSkeletonByName(name: string): Nullable<Skeleton>;
  93278. /**
  93279. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93280. * @param id defines the id to search for
  93281. * @return the found morph target manager or null if not found at all.
  93282. */
  93283. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93284. /**
  93285. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93286. * @param id defines the id to search for
  93287. * @return the found morph target or null if not found at all.
  93288. */
  93289. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93290. /**
  93291. * Gets a boolean indicating if the given mesh is active
  93292. * @param mesh defines the mesh to look for
  93293. * @returns true if the mesh is in the active list
  93294. */
  93295. isActiveMesh(mesh: AbstractMesh): boolean;
  93296. /**
  93297. * Return a unique id as a string which can serve as an identifier for the scene
  93298. */
  93299. readonly uid: string;
  93300. /**
  93301. * Add an externaly attached data from its key.
  93302. * This method call will fail and return false, if such key already exists.
  93303. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93304. * @param key the unique key that identifies the data
  93305. * @param data the data object to associate to the key for this Engine instance
  93306. * @return true if no such key were already present and the data was added successfully, false otherwise
  93307. */
  93308. addExternalData<T>(key: string, data: T): boolean;
  93309. /**
  93310. * Get an externaly attached data from its key
  93311. * @param key the unique key that identifies the data
  93312. * @return the associated data, if present (can be null), or undefined if not present
  93313. */
  93314. getExternalData<T>(key: string): Nullable<T>;
  93315. /**
  93316. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93317. * @param key the unique key that identifies the data
  93318. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93319. * @return the associated data, can be null if the factory returned null.
  93320. */
  93321. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93322. /**
  93323. * Remove an externaly attached data from the Engine instance
  93324. * @param key the unique key that identifies the data
  93325. * @return true if the data was successfully removed, false if it doesn't exist
  93326. */
  93327. removeExternalData(key: string): boolean;
  93328. private _evaluateSubMesh;
  93329. /**
  93330. * Clear the processed materials smart array preventing retention point in material dispose.
  93331. */
  93332. freeProcessedMaterials(): void;
  93333. private _preventFreeActiveMeshesAndRenderingGroups;
  93334. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93335. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93336. * when disposing several meshes in a row or a hierarchy of meshes.
  93337. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93338. */
  93339. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93340. /**
  93341. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93342. */
  93343. freeActiveMeshes(): void;
  93344. /**
  93345. * Clear the info related to rendering groups preventing retention points during dispose.
  93346. */
  93347. freeRenderingGroups(): void;
  93348. /** @hidden */
  93349. _isInIntermediateRendering(): boolean;
  93350. /**
  93351. * Lambda returning the list of potentially active meshes.
  93352. */
  93353. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93354. /**
  93355. * Lambda returning the list of potentially active sub meshes.
  93356. */
  93357. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93358. /**
  93359. * Lambda returning the list of potentially intersecting sub meshes.
  93360. */
  93361. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93362. /**
  93363. * Lambda returning the list of potentially colliding sub meshes.
  93364. */
  93365. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93366. private _activeMeshesFrozen;
  93367. /**
  93368. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93369. * @returns the current scene
  93370. */
  93371. freezeActiveMeshes(): Scene;
  93372. /**
  93373. * Use this function to restart evaluating active meshes on every frame
  93374. * @returns the current scene
  93375. */
  93376. unfreezeActiveMeshes(): Scene;
  93377. private _evaluateActiveMeshes;
  93378. private _activeMesh;
  93379. /**
  93380. * Update the transform matrix to update from the current active camera
  93381. * @param force defines a boolean used to force the update even if cache is up to date
  93382. */
  93383. updateTransformMatrix(force?: boolean): void;
  93384. private _bindFrameBuffer;
  93385. /** @hidden */
  93386. _allowPostProcessClearColor: boolean;
  93387. /** @hidden */
  93388. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93389. private _processSubCameras;
  93390. private _checkIntersections;
  93391. /** @hidden */
  93392. _advancePhysicsEngineStep(step: number): void;
  93393. /**
  93394. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93395. */
  93396. getDeterministicFrameTime: () => number;
  93397. /** @hidden */
  93398. _animate(): void;
  93399. /** Execute all animations (for a frame) */
  93400. animate(): void;
  93401. /**
  93402. * Render the scene
  93403. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93404. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93405. */
  93406. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93407. /**
  93408. * Freeze all materials
  93409. * A frozen material will not be updatable but should be faster to render
  93410. */
  93411. freezeMaterials(): void;
  93412. /**
  93413. * Unfreeze all materials
  93414. * A frozen material will not be updatable but should be faster to render
  93415. */
  93416. unfreezeMaterials(): void;
  93417. /**
  93418. * Releases all held ressources
  93419. */
  93420. dispose(): void;
  93421. /**
  93422. * Gets if the scene is already disposed
  93423. */
  93424. readonly isDisposed: boolean;
  93425. /**
  93426. * Call this function to reduce memory footprint of the scene.
  93427. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93428. */
  93429. clearCachedVertexData(): void;
  93430. /**
  93431. * This function will remove the local cached buffer data from texture.
  93432. * It will save memory but will prevent the texture from being rebuilt
  93433. */
  93434. cleanCachedTextureBuffer(): void;
  93435. /**
  93436. * Get the world extend vectors with an optional filter
  93437. *
  93438. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93439. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93440. */
  93441. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93442. min: Vector3;
  93443. max: Vector3;
  93444. };
  93445. /**
  93446. * Creates a ray that can be used to pick in the scene
  93447. * @param x defines the x coordinate of the origin (on-screen)
  93448. * @param y defines the y coordinate of the origin (on-screen)
  93449. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93450. * @param camera defines the camera to use for the picking
  93451. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93452. * @returns a Ray
  93453. */
  93454. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93455. /**
  93456. * Creates a ray that can be used to pick in the scene
  93457. * @param x defines the x coordinate of the origin (on-screen)
  93458. * @param y defines the y coordinate of the origin (on-screen)
  93459. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93460. * @param result defines the ray where to store the picking ray
  93461. * @param camera defines the camera to use for the picking
  93462. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93463. * @returns the current scene
  93464. */
  93465. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93466. /**
  93467. * Creates a ray that can be used to pick in the scene
  93468. * @param x defines the x coordinate of the origin (on-screen)
  93469. * @param y defines the y coordinate of the origin (on-screen)
  93470. * @param camera defines the camera to use for the picking
  93471. * @returns a Ray
  93472. */
  93473. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93474. /**
  93475. * Creates a ray that can be used to pick in the scene
  93476. * @param x defines the x coordinate of the origin (on-screen)
  93477. * @param y defines the y coordinate of the origin (on-screen)
  93478. * @param result defines the ray where to store the picking ray
  93479. * @param camera defines the camera to use for the picking
  93480. * @returns the current scene
  93481. */
  93482. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93483. /** Launch a ray to try to pick a mesh in the scene
  93484. * @param x position on screen
  93485. * @param y position on screen
  93486. * @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
  93487. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93488. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93489. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93490. * @returns a PickingInfo
  93491. */
  93492. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93493. /** Use the given ray to pick a mesh in the scene
  93494. * @param ray The ray to use to pick meshes
  93495. * @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
  93496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93497. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93498. * @returns a PickingInfo
  93499. */
  93500. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93501. /**
  93502. * Launch a ray to try to pick a mesh in the scene
  93503. * @param x X position on screen
  93504. * @param y Y position on screen
  93505. * @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
  93506. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93507. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93508. * @returns an array of PickingInfo
  93509. */
  93510. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93511. /**
  93512. * Launch a ray to try to pick a mesh in the scene
  93513. * @param ray Ray to use
  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 trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93516. * @returns an array of PickingInfo
  93517. */
  93518. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93519. /**
  93520. * Force the value of meshUnderPointer
  93521. * @param mesh defines the mesh to use
  93522. */
  93523. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93524. /**
  93525. * Gets the mesh under the pointer
  93526. * @returns a Mesh or null if no mesh is under the pointer
  93527. */
  93528. getPointerOverMesh(): Nullable<AbstractMesh>;
  93529. /** @hidden */
  93530. _rebuildGeometries(): void;
  93531. /** @hidden */
  93532. _rebuildTextures(): void;
  93533. private _getByTags;
  93534. /**
  93535. * Get a list of meshes by tags
  93536. * @param tagsQuery defines the tags query to use
  93537. * @param forEach defines a predicate used to filter results
  93538. * @returns an array of Mesh
  93539. */
  93540. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93541. /**
  93542. * Get a list of cameras by tags
  93543. * @param tagsQuery defines the tags query to use
  93544. * @param forEach defines a predicate used to filter results
  93545. * @returns an array of Camera
  93546. */
  93547. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93548. /**
  93549. * Get a list of lights by tags
  93550. * @param tagsQuery defines the tags query to use
  93551. * @param forEach defines a predicate used to filter results
  93552. * @returns an array of Light
  93553. */
  93554. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93555. /**
  93556. * Get a list of materials by tags
  93557. * @param tagsQuery defines the tags query to use
  93558. * @param forEach defines a predicate used to filter results
  93559. * @returns an array of Material
  93560. */
  93561. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93562. /**
  93563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93564. * This allowed control for front to back rendering or reversly depending of the special needs.
  93565. *
  93566. * @param renderingGroupId The rendering group id corresponding to its index
  93567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93570. */
  93571. 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;
  93572. /**
  93573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93574. *
  93575. * @param renderingGroupId The rendering group id corresponding to its index
  93576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93577. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93578. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93579. */
  93580. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93581. /**
  93582. * Gets the current auto clear configuration for one rendering group of the rendering
  93583. * manager.
  93584. * @param index the rendering group index to get the information for
  93585. * @returns The auto clear setup for the requested rendering group
  93586. */
  93587. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93588. private _blockMaterialDirtyMechanism;
  93589. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93590. blockMaterialDirtyMechanism: boolean;
  93591. /**
  93592. * Will flag all materials as dirty to trigger new shader compilation
  93593. * @param flag defines the flag used to specify which material part must be marked as dirty
  93594. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93595. */
  93596. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93597. /** @hidden */
  93598. _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;
  93599. /** @hidden */
  93600. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93601. }
  93602. }
  93603. declare module BABYLON {
  93604. /**
  93605. * Set of assets to keep when moving a scene into an asset container.
  93606. */
  93607. export class KeepAssets extends AbstractScene {
  93608. }
  93609. /**
  93610. * Container with a set of assets that can be added or removed from a scene.
  93611. */
  93612. export class AssetContainer extends AbstractScene {
  93613. /**
  93614. * The scene the AssetContainer belongs to.
  93615. */
  93616. scene: Scene;
  93617. /**
  93618. * Instantiates an AssetContainer.
  93619. * @param scene The scene the AssetContainer belongs to.
  93620. */
  93621. constructor(scene: Scene);
  93622. /**
  93623. * Adds all the assets from the container to the scene.
  93624. */
  93625. addAllToScene(): void;
  93626. /**
  93627. * Removes all the assets in the container from the scene
  93628. */
  93629. removeAllFromScene(): void;
  93630. /**
  93631. * Disposes all the assets in the container
  93632. */
  93633. dispose(): void;
  93634. private _moveAssets;
  93635. /**
  93636. * Removes all the assets contained in the scene and adds them to the container.
  93637. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93638. */
  93639. moveAllFromScene(keepAssets?: KeepAssets): void;
  93640. /**
  93641. * 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.
  93642. * @returns the root mesh
  93643. */
  93644. createRootMesh(): Mesh;
  93645. }
  93646. }
  93647. declare module BABYLON {
  93648. /**
  93649. * Defines how the parser contract is defined.
  93650. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93651. */
  93652. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93653. /**
  93654. * Defines how the individual parser contract is defined.
  93655. * These parser can parse an individual asset
  93656. */
  93657. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93658. /**
  93659. * Base class of the scene acting as a container for the different elements composing a scene.
  93660. * This class is dynamically extended by the different components of the scene increasing
  93661. * flexibility and reducing coupling
  93662. */
  93663. export abstract class AbstractScene {
  93664. /**
  93665. * Stores the list of available parsers in the application.
  93666. */
  93667. private static _BabylonFileParsers;
  93668. /**
  93669. * Stores the list of available individual parsers in the application.
  93670. */
  93671. private static _IndividualBabylonFileParsers;
  93672. /**
  93673. * Adds a parser in the list of available ones
  93674. * @param name Defines the name of the parser
  93675. * @param parser Defines the parser to add
  93676. */
  93677. static AddParser(name: string, parser: BabylonFileParser): void;
  93678. /**
  93679. * Gets a general parser from the list of avaialble ones
  93680. * @param name Defines the name of the parser
  93681. * @returns the requested parser or null
  93682. */
  93683. static GetParser(name: string): Nullable<BabylonFileParser>;
  93684. /**
  93685. * Adds n individual parser in the list of available ones
  93686. * @param name Defines the name of the parser
  93687. * @param parser Defines the parser to add
  93688. */
  93689. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93690. /**
  93691. * Gets an individual parser from the list of avaialble ones
  93692. * @param name Defines the name of the parser
  93693. * @returns the requested parser or null
  93694. */
  93695. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93696. /**
  93697. * Parser json data and populate both a scene and its associated container object
  93698. * @param jsonData Defines the data to parse
  93699. * @param scene Defines the scene to parse the data for
  93700. * @param container Defines the container attached to the parsing sequence
  93701. * @param rootUrl Defines the root url of the data
  93702. */
  93703. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93704. /**
  93705. * Gets the list of root nodes (ie. nodes with no parent)
  93706. */
  93707. rootNodes: Node[];
  93708. /** All of the cameras added to this scene
  93709. * @see http://doc.babylonjs.com/babylon101/cameras
  93710. */
  93711. cameras: Camera[];
  93712. /**
  93713. * All of the lights added to this scene
  93714. * @see http://doc.babylonjs.com/babylon101/lights
  93715. */
  93716. lights: Light[];
  93717. /**
  93718. * All of the (abstract) meshes added to this scene
  93719. */
  93720. meshes: AbstractMesh[];
  93721. /**
  93722. * The list of skeletons added to the scene
  93723. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93724. */
  93725. skeletons: Skeleton[];
  93726. /**
  93727. * All of the particle systems added to this scene
  93728. * @see http://doc.babylonjs.com/babylon101/particles
  93729. */
  93730. particleSystems: IParticleSystem[];
  93731. /**
  93732. * Gets a list of Animations associated with the scene
  93733. */
  93734. animations: Animation[];
  93735. /**
  93736. * All of the animation groups added to this scene
  93737. * @see http://doc.babylonjs.com/how_to/group
  93738. */
  93739. animationGroups: AnimationGroup[];
  93740. /**
  93741. * All of the multi-materials added to this scene
  93742. * @see http://doc.babylonjs.com/how_to/multi_materials
  93743. */
  93744. multiMaterials: MultiMaterial[];
  93745. /**
  93746. * All of the materials added to this scene
  93747. * In the context of a Scene, it is not supposed to be modified manually.
  93748. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93749. * Note also that the order of the Material wihin the array is not significant and might change.
  93750. * @see http://doc.babylonjs.com/babylon101/materials
  93751. */
  93752. materials: Material[];
  93753. /**
  93754. * The list of morph target managers added to the scene
  93755. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93756. */
  93757. morphTargetManagers: MorphTargetManager[];
  93758. /**
  93759. * The list of geometries used in the scene.
  93760. */
  93761. geometries: Geometry[];
  93762. /**
  93763. * All of the tranform nodes added to this scene
  93764. * In the context of a Scene, it is not supposed to be modified manually.
  93765. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93766. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93767. * @see http://doc.babylonjs.com/how_to/transformnode
  93768. */
  93769. transformNodes: TransformNode[];
  93770. /**
  93771. * ActionManagers available on the scene.
  93772. */
  93773. actionManagers: AbstractActionManager[];
  93774. /**
  93775. * Textures to keep.
  93776. */
  93777. textures: BaseTexture[];
  93778. /**
  93779. * Environment texture for the scene
  93780. */
  93781. environmentTexture: Nullable<BaseTexture>;
  93782. }
  93783. }
  93784. declare module BABYLON {
  93785. /**
  93786. * Defines a sound that can be played in the application.
  93787. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93789. */
  93790. export class Sound {
  93791. /**
  93792. * The name of the sound in the scene.
  93793. */
  93794. name: string;
  93795. /**
  93796. * Does the sound autoplay once loaded.
  93797. */
  93798. autoplay: boolean;
  93799. /**
  93800. * Does the sound loop after it finishes playing once.
  93801. */
  93802. loop: boolean;
  93803. /**
  93804. * Does the sound use a custom attenuation curve to simulate the falloff
  93805. * happening when the source gets further away from the camera.
  93806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93807. */
  93808. useCustomAttenuation: boolean;
  93809. /**
  93810. * The sound track id this sound belongs to.
  93811. */
  93812. soundTrackId: number;
  93813. /**
  93814. * Is this sound currently played.
  93815. */
  93816. isPlaying: boolean;
  93817. /**
  93818. * Is this sound currently paused.
  93819. */
  93820. isPaused: boolean;
  93821. /**
  93822. * Does this sound enables spatial sound.
  93823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93824. */
  93825. spatialSound: boolean;
  93826. /**
  93827. * Define the reference distance the sound should be heard perfectly.
  93828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93829. */
  93830. refDistance: number;
  93831. /**
  93832. * Define the roll off factor of spatial sounds.
  93833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93834. */
  93835. rolloffFactor: number;
  93836. /**
  93837. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93839. */
  93840. maxDistance: number;
  93841. /**
  93842. * Define the distance attenuation model the sound will follow.
  93843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93844. */
  93845. distanceModel: string;
  93846. /**
  93847. * @hidden
  93848. * Back Compat
  93849. **/
  93850. onended: () => any;
  93851. /**
  93852. * Observable event when the current playing sound finishes.
  93853. */
  93854. onEndedObservable: Observable<Sound>;
  93855. private _panningModel;
  93856. private _playbackRate;
  93857. private _streaming;
  93858. private _startTime;
  93859. private _startOffset;
  93860. private _position;
  93861. /** @hidden */
  93862. _positionInEmitterSpace: boolean;
  93863. private _localDirection;
  93864. private _volume;
  93865. private _isReadyToPlay;
  93866. private _isDirectional;
  93867. private _readyToPlayCallback;
  93868. private _audioBuffer;
  93869. private _soundSource;
  93870. private _streamingSource;
  93871. private _soundPanner;
  93872. private _soundGain;
  93873. private _inputAudioNode;
  93874. private _outputAudioNode;
  93875. private _coneInnerAngle;
  93876. private _coneOuterAngle;
  93877. private _coneOuterGain;
  93878. private _scene;
  93879. private _connectedTransformNode;
  93880. private _customAttenuationFunction;
  93881. private _registerFunc;
  93882. private _isOutputConnected;
  93883. private _htmlAudioElement;
  93884. private _urlType;
  93885. /** @hidden */
  93886. static _SceneComponentInitialization: (scene: Scene) => void;
  93887. /**
  93888. * Create a sound and attach it to a scene
  93889. * @param name Name of your sound
  93890. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93891. * @param scene defines the scene the sound belongs to
  93892. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93893. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93894. */
  93895. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93896. /**
  93897. * Release the sound and its associated resources
  93898. */
  93899. dispose(): void;
  93900. /**
  93901. * Gets if the sounds is ready to be played or not.
  93902. * @returns true if ready, otherwise false
  93903. */
  93904. isReady(): boolean;
  93905. private _soundLoaded;
  93906. /**
  93907. * Sets the data of the sound from an audiobuffer
  93908. * @param audioBuffer The audioBuffer containing the data
  93909. */
  93910. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93911. /**
  93912. * Updates the current sounds options such as maxdistance, loop...
  93913. * @param options A JSON object containing values named as the object properties
  93914. */
  93915. updateOptions(options: any): void;
  93916. private _createSpatialParameters;
  93917. private _updateSpatialParameters;
  93918. /**
  93919. * Switch the panning model to HRTF:
  93920. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93922. */
  93923. switchPanningModelToHRTF(): void;
  93924. /**
  93925. * Switch the panning model to Equal Power:
  93926. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93928. */
  93929. switchPanningModelToEqualPower(): void;
  93930. private _switchPanningModel;
  93931. /**
  93932. * Connect this sound to a sound track audio node like gain...
  93933. * @param soundTrackAudioNode the sound track audio node to connect to
  93934. */
  93935. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93936. /**
  93937. * Transform this sound into a directional source
  93938. * @param coneInnerAngle Size of the inner cone in degree
  93939. * @param coneOuterAngle Size of the outer cone in degree
  93940. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93941. */
  93942. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93943. /**
  93944. * Gets or sets the inner angle for the directional cone.
  93945. */
  93946. /**
  93947. * Gets or sets the inner angle for the directional cone.
  93948. */
  93949. directionalConeInnerAngle: number;
  93950. /**
  93951. * Gets or sets the outer angle for the directional cone.
  93952. */
  93953. /**
  93954. * Gets or sets the outer angle for the directional cone.
  93955. */
  93956. directionalConeOuterAngle: number;
  93957. /**
  93958. * Sets the position of the emitter if spatial sound is enabled
  93959. * @param newPosition Defines the new posisiton
  93960. */
  93961. setPosition(newPosition: Vector3): void;
  93962. /**
  93963. * Sets the local direction of the emitter if spatial sound is enabled
  93964. * @param newLocalDirection Defines the new local direction
  93965. */
  93966. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93967. private _updateDirection;
  93968. /** @hidden */
  93969. updateDistanceFromListener(): void;
  93970. /**
  93971. * Sets a new custom attenuation function for the sound.
  93972. * @param callback Defines the function used for the attenuation
  93973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93974. */
  93975. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93976. /**
  93977. * Play the sound
  93978. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93979. * @param offset (optional) Start the sound setting it at a specific time
  93980. */
  93981. play(time?: number, offset?: number): void;
  93982. private _onended;
  93983. /**
  93984. * Stop the sound
  93985. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93986. */
  93987. stop(time?: number): void;
  93988. /**
  93989. * Put the sound in pause
  93990. */
  93991. pause(): void;
  93992. /**
  93993. * Sets a dedicated volume for this sounds
  93994. * @param newVolume Define the new volume of the sound
  93995. * @param time Define in how long the sound should be at this value
  93996. */
  93997. setVolume(newVolume: number, time?: number): void;
  93998. /**
  93999. * Set the sound play back rate
  94000. * @param newPlaybackRate Define the playback rate the sound should be played at
  94001. */
  94002. setPlaybackRate(newPlaybackRate: number): void;
  94003. /**
  94004. * Gets the volume of the sound.
  94005. * @returns the volume of the sound
  94006. */
  94007. getVolume(): number;
  94008. /**
  94009. * Attach the sound to a dedicated mesh
  94010. * @param transformNode The transform node to connect the sound with
  94011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94012. */
  94013. attachToMesh(transformNode: TransformNode): void;
  94014. /**
  94015. * Detach the sound from the previously attached mesh
  94016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94017. */
  94018. detachFromMesh(): void;
  94019. private _onRegisterAfterWorldMatrixUpdate;
  94020. /**
  94021. * Clone the current sound in the scene.
  94022. * @returns the new sound clone
  94023. */
  94024. clone(): Nullable<Sound>;
  94025. /**
  94026. * Gets the current underlying audio buffer containing the data
  94027. * @returns the audio buffer
  94028. */
  94029. getAudioBuffer(): Nullable<AudioBuffer>;
  94030. /**
  94031. * Serializes the Sound in a JSON representation
  94032. * @returns the JSON representation of the sound
  94033. */
  94034. serialize(): any;
  94035. /**
  94036. * Parse a JSON representation of a sound to innstantiate in a given scene
  94037. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94038. * @param scene Define the scene the new parsed sound should be created in
  94039. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94040. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94041. * @returns the newly parsed sound
  94042. */
  94043. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94044. }
  94045. }
  94046. declare module BABYLON {
  94047. /**
  94048. * This defines an action helpful to play a defined sound on a triggered action.
  94049. */
  94050. export class PlaySoundAction extends Action {
  94051. private _sound;
  94052. /**
  94053. * Instantiate the action
  94054. * @param triggerOptions defines the trigger options
  94055. * @param sound defines the sound to play
  94056. * @param condition defines the trigger related conditions
  94057. */
  94058. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94059. /** @hidden */
  94060. _prepare(): void;
  94061. /**
  94062. * Execute the action and play the sound.
  94063. */
  94064. execute(): void;
  94065. /**
  94066. * Serializes the actions and its related information.
  94067. * @param parent defines the object to serialize in
  94068. * @returns the serialized object
  94069. */
  94070. serialize(parent: any): any;
  94071. }
  94072. /**
  94073. * This defines an action helpful to stop a defined sound on a triggered action.
  94074. */
  94075. export class StopSoundAction extends Action {
  94076. private _sound;
  94077. /**
  94078. * Instantiate the action
  94079. * @param triggerOptions defines the trigger options
  94080. * @param sound defines the sound to stop
  94081. * @param condition defines the trigger related conditions
  94082. */
  94083. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94084. /** @hidden */
  94085. _prepare(): void;
  94086. /**
  94087. * Execute the action and stop the sound.
  94088. */
  94089. execute(): void;
  94090. /**
  94091. * Serializes the actions and its related information.
  94092. * @param parent defines the object to serialize in
  94093. * @returns the serialized object
  94094. */
  94095. serialize(parent: any): any;
  94096. }
  94097. }
  94098. declare module BABYLON {
  94099. /**
  94100. * This defines an action responsible to change the value of a property
  94101. * by interpolating between its current value and the newly set one once triggered.
  94102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94103. */
  94104. export class InterpolateValueAction extends Action {
  94105. /**
  94106. * Defines the path of the property where the value should be interpolated
  94107. */
  94108. propertyPath: string;
  94109. /**
  94110. * Defines the target value at the end of the interpolation.
  94111. */
  94112. value: any;
  94113. /**
  94114. * Defines the time it will take for the property to interpolate to the value.
  94115. */
  94116. duration: number;
  94117. /**
  94118. * Defines if the other scene animations should be stopped when the action has been triggered
  94119. */
  94120. stopOtherAnimations?: boolean;
  94121. /**
  94122. * Defines a callback raised once the interpolation animation has been done.
  94123. */
  94124. onInterpolationDone?: () => void;
  94125. /**
  94126. * Observable triggered once the interpolation animation has been done.
  94127. */
  94128. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94129. private _target;
  94130. private _effectiveTarget;
  94131. private _property;
  94132. /**
  94133. * Instantiate the action
  94134. * @param triggerOptions defines the trigger options
  94135. * @param target defines the object containing the value to interpolate
  94136. * @param propertyPath defines the path to the property in the target object
  94137. * @param value defines the target value at the end of the interpolation
  94138. * @param duration deines the time it will take for the property to interpolate to the value.
  94139. * @param condition defines the trigger related conditions
  94140. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94141. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94142. */
  94143. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94144. /** @hidden */
  94145. _prepare(): void;
  94146. /**
  94147. * Execute the action starts the value interpolation.
  94148. */
  94149. execute(): void;
  94150. /**
  94151. * Serializes the actions and its related information.
  94152. * @param parent defines the object to serialize in
  94153. * @returns the serialized object
  94154. */
  94155. serialize(parent: any): any;
  94156. }
  94157. }
  94158. declare module BABYLON {
  94159. /**
  94160. * Options allowed during the creation of a sound track.
  94161. */
  94162. export interface ISoundTrackOptions {
  94163. /**
  94164. * The volume the sound track should take during creation
  94165. */
  94166. volume?: number;
  94167. /**
  94168. * Define if the sound track is the main sound track of the scene
  94169. */
  94170. mainTrack?: boolean;
  94171. }
  94172. /**
  94173. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94174. * It will be also used in a future release to apply effects on a specific track.
  94175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94176. */
  94177. export class SoundTrack {
  94178. /**
  94179. * The unique identifier of the sound track in the scene.
  94180. */
  94181. id: number;
  94182. /**
  94183. * The list of sounds included in the sound track.
  94184. */
  94185. soundCollection: Array<Sound>;
  94186. private _outputAudioNode;
  94187. private _scene;
  94188. private _isMainTrack;
  94189. private _connectedAnalyser;
  94190. private _options;
  94191. private _isInitialized;
  94192. /**
  94193. * Creates a new sound track.
  94194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94195. * @param scene Define the scene the sound track belongs to
  94196. * @param options
  94197. */
  94198. constructor(scene: Scene, options?: ISoundTrackOptions);
  94199. private _initializeSoundTrackAudioGraph;
  94200. /**
  94201. * Release the sound track and its associated resources
  94202. */
  94203. dispose(): void;
  94204. /**
  94205. * Adds a sound to this sound track
  94206. * @param sound define the cound to add
  94207. * @ignoreNaming
  94208. */
  94209. AddSound(sound: Sound): void;
  94210. /**
  94211. * Removes a sound to this sound track
  94212. * @param sound define the cound to remove
  94213. * @ignoreNaming
  94214. */
  94215. RemoveSound(sound: Sound): void;
  94216. /**
  94217. * Set a global volume for the full sound track.
  94218. * @param newVolume Define the new volume of the sound track
  94219. */
  94220. setVolume(newVolume: number): void;
  94221. /**
  94222. * Switch the panning model to HRTF:
  94223. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94225. */
  94226. switchPanningModelToHRTF(): void;
  94227. /**
  94228. * Switch the panning model to Equal Power:
  94229. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94231. */
  94232. switchPanningModelToEqualPower(): void;
  94233. /**
  94234. * Connect the sound track to an audio analyser allowing some amazing
  94235. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94237. * @param analyser The analyser to connect to the engine
  94238. */
  94239. connectToAnalyser(analyser: Analyser): void;
  94240. }
  94241. }
  94242. declare module BABYLON {
  94243. interface AbstractScene {
  94244. /**
  94245. * The list of sounds used in the scene.
  94246. */
  94247. sounds: Nullable<Array<Sound>>;
  94248. }
  94249. interface Scene {
  94250. /**
  94251. * @hidden
  94252. * Backing field
  94253. */
  94254. _mainSoundTrack: SoundTrack;
  94255. /**
  94256. * The main sound track played by the scene.
  94257. * It cotains your primary collection of sounds.
  94258. */
  94259. mainSoundTrack: SoundTrack;
  94260. /**
  94261. * The list of sound tracks added to the scene
  94262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94263. */
  94264. soundTracks: Nullable<Array<SoundTrack>>;
  94265. /**
  94266. * Gets a sound using a given name
  94267. * @param name defines the name to search for
  94268. * @return the found sound or null if not found at all.
  94269. */
  94270. getSoundByName(name: string): Nullable<Sound>;
  94271. /**
  94272. * Gets or sets if audio support is enabled
  94273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94274. */
  94275. audioEnabled: boolean;
  94276. /**
  94277. * Gets or sets if audio will be output to headphones
  94278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94279. */
  94280. headphone: boolean;
  94281. }
  94282. /**
  94283. * Defines the sound scene component responsible to manage any sounds
  94284. * in a given scene.
  94285. */
  94286. export class AudioSceneComponent implements ISceneSerializableComponent {
  94287. /**
  94288. * The component name helpfull to identify the component in the list of scene components.
  94289. */
  94290. readonly name: string;
  94291. /**
  94292. * The scene the component belongs to.
  94293. */
  94294. scene: Scene;
  94295. private _audioEnabled;
  94296. /**
  94297. * Gets whether audio is enabled or not.
  94298. * Please use related enable/disable method to switch state.
  94299. */
  94300. readonly audioEnabled: boolean;
  94301. private _headphone;
  94302. /**
  94303. * Gets whether audio is outputing to headphone or not.
  94304. * Please use the according Switch methods to change output.
  94305. */
  94306. readonly headphone: boolean;
  94307. /**
  94308. * Creates a new instance of the component for the given scene
  94309. * @param scene Defines the scene to register the component in
  94310. */
  94311. constructor(scene: Scene);
  94312. /**
  94313. * Registers the component in a given scene
  94314. */
  94315. register(): void;
  94316. /**
  94317. * Rebuilds the elements related to this component in case of
  94318. * context lost for instance.
  94319. */
  94320. rebuild(): void;
  94321. /**
  94322. * Serializes the component data to the specified json object
  94323. * @param serializationObject The object to serialize to
  94324. */
  94325. serialize(serializationObject: any): void;
  94326. /**
  94327. * Adds all the element from the container to the scene
  94328. * @param container the container holding the elements
  94329. */
  94330. addFromContainer(container: AbstractScene): void;
  94331. /**
  94332. * Removes all the elements in the container from the scene
  94333. * @param container contains the elements to remove
  94334. * @param dispose if the removed element should be disposed (default: false)
  94335. */
  94336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94337. /**
  94338. * Disposes the component and the associated ressources.
  94339. */
  94340. dispose(): void;
  94341. /**
  94342. * Disables audio in the associated scene.
  94343. */
  94344. disableAudio(): void;
  94345. /**
  94346. * Enables audio in the associated scene.
  94347. */
  94348. enableAudio(): void;
  94349. /**
  94350. * Switch audio to headphone output.
  94351. */
  94352. switchAudioModeForHeadphones(): void;
  94353. /**
  94354. * Switch audio to normal speakers.
  94355. */
  94356. switchAudioModeForNormalSpeakers(): void;
  94357. private _afterRender;
  94358. }
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * Wraps one or more Sound objects and selects one with random weight for playback.
  94363. */
  94364. export class WeightedSound {
  94365. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94366. loop: boolean;
  94367. private _coneInnerAngle;
  94368. private _coneOuterAngle;
  94369. private _volume;
  94370. /** A Sound is currently playing. */
  94371. isPlaying: boolean;
  94372. /** A Sound is currently paused. */
  94373. isPaused: boolean;
  94374. private _sounds;
  94375. private _weights;
  94376. private _currentIndex?;
  94377. /**
  94378. * Creates a new WeightedSound from the list of sounds given.
  94379. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94380. * @param sounds Array of Sounds that will be selected from.
  94381. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94382. */
  94383. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94384. /**
  94385. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94386. */
  94387. /**
  94388. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94389. */
  94390. directionalConeInnerAngle: number;
  94391. /**
  94392. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94393. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94394. */
  94395. /**
  94396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94398. */
  94399. directionalConeOuterAngle: number;
  94400. /**
  94401. * Playback volume.
  94402. */
  94403. /**
  94404. * Playback volume.
  94405. */
  94406. volume: number;
  94407. private _onended;
  94408. /**
  94409. * Suspend playback
  94410. */
  94411. pause(): void;
  94412. /**
  94413. * Stop playback
  94414. */
  94415. stop(): void;
  94416. /**
  94417. * Start playback.
  94418. * @param startOffset Position the clip head at a specific time in seconds.
  94419. */
  94420. play(startOffset?: number): void;
  94421. }
  94422. }
  94423. declare module BABYLON {
  94424. /**
  94425. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94427. */
  94428. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94429. /**
  94430. * Gets the name of the behavior.
  94431. */
  94432. readonly name: string;
  94433. /**
  94434. * The easing function used by animations
  94435. */
  94436. static EasingFunction: BackEase;
  94437. /**
  94438. * The easing mode used by animations
  94439. */
  94440. static EasingMode: number;
  94441. /**
  94442. * The duration of the animation, in milliseconds
  94443. */
  94444. transitionDuration: number;
  94445. /**
  94446. * Length of the distance animated by the transition when lower radius is reached
  94447. */
  94448. lowerRadiusTransitionRange: number;
  94449. /**
  94450. * Length of the distance animated by the transition when upper radius is reached
  94451. */
  94452. upperRadiusTransitionRange: number;
  94453. private _autoTransitionRange;
  94454. /**
  94455. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94456. */
  94457. /**
  94458. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94459. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94460. */
  94461. autoTransitionRange: boolean;
  94462. private _attachedCamera;
  94463. private _onAfterCheckInputsObserver;
  94464. private _onMeshTargetChangedObserver;
  94465. /**
  94466. * Initializes the behavior.
  94467. */
  94468. init(): void;
  94469. /**
  94470. * Attaches the behavior to its arc rotate camera.
  94471. * @param camera Defines the camera to attach the behavior to
  94472. */
  94473. attach(camera: ArcRotateCamera): void;
  94474. /**
  94475. * Detaches the behavior from its current arc rotate camera.
  94476. */
  94477. detach(): void;
  94478. private _radiusIsAnimating;
  94479. private _radiusBounceTransition;
  94480. private _animatables;
  94481. private _cachedWheelPrecision;
  94482. /**
  94483. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94484. * @param radiusLimit The limit to check against.
  94485. * @return Bool to indicate if at limit.
  94486. */
  94487. private _isRadiusAtLimit;
  94488. /**
  94489. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94490. * @param radiusDelta The delta by which to animate to. Can be negative.
  94491. */
  94492. private _applyBoundRadiusAnimation;
  94493. /**
  94494. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94495. */
  94496. protected _clearAnimationLocks(): void;
  94497. /**
  94498. * Stops and removes all animations that have been applied to the camera
  94499. */
  94500. stopAllAnimations(): void;
  94501. }
  94502. }
  94503. declare module BABYLON {
  94504. /**
  94505. * 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.
  94506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94507. */
  94508. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94509. /**
  94510. * Gets the name of the behavior.
  94511. */
  94512. readonly name: string;
  94513. private _mode;
  94514. private _radiusScale;
  94515. private _positionScale;
  94516. private _defaultElevation;
  94517. private _elevationReturnTime;
  94518. private _elevationReturnWaitTime;
  94519. private _zoomStopsAnimation;
  94520. private _framingTime;
  94521. /**
  94522. * The easing function used by animations
  94523. */
  94524. static EasingFunction: ExponentialEase;
  94525. /**
  94526. * The easing mode used by animations
  94527. */
  94528. static EasingMode: number;
  94529. /**
  94530. * Sets the current mode used by the behavior
  94531. */
  94532. /**
  94533. * Gets current mode used by the behavior.
  94534. */
  94535. mode: number;
  94536. /**
  94537. * Sets the scale applied to the radius (1 by default)
  94538. */
  94539. /**
  94540. * Gets the scale applied to the radius
  94541. */
  94542. radiusScale: number;
  94543. /**
  94544. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94545. */
  94546. /**
  94547. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94548. */
  94549. positionScale: number;
  94550. /**
  94551. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94552. * behaviour is triggered, in radians.
  94553. */
  94554. /**
  94555. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94556. * behaviour is triggered, in radians.
  94557. */
  94558. defaultElevation: number;
  94559. /**
  94560. * Sets the time (in milliseconds) taken to return to the default beta position.
  94561. * Negative value indicates camera should not return to default.
  94562. */
  94563. /**
  94564. * Gets the time (in milliseconds) taken to return to the default beta position.
  94565. * Negative value indicates camera should not return to default.
  94566. */
  94567. elevationReturnTime: number;
  94568. /**
  94569. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94570. */
  94571. /**
  94572. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94573. */
  94574. elevationReturnWaitTime: number;
  94575. /**
  94576. * Sets the flag that indicates if user zooming should stop animation.
  94577. */
  94578. /**
  94579. * Gets the flag that indicates if user zooming should stop animation.
  94580. */
  94581. zoomStopsAnimation: boolean;
  94582. /**
  94583. * Sets the transition time when framing the mesh, in milliseconds
  94584. */
  94585. /**
  94586. * Gets the transition time when framing the mesh, in milliseconds
  94587. */
  94588. framingTime: number;
  94589. /**
  94590. * Define if the behavior should automatically change the configured
  94591. * camera limits and sensibilities.
  94592. */
  94593. autoCorrectCameraLimitsAndSensibility: boolean;
  94594. private _onPrePointerObservableObserver;
  94595. private _onAfterCheckInputsObserver;
  94596. private _onMeshTargetChangedObserver;
  94597. private _attachedCamera;
  94598. private _isPointerDown;
  94599. private _lastInteractionTime;
  94600. /**
  94601. * Initializes the behavior.
  94602. */
  94603. init(): void;
  94604. /**
  94605. * Attaches the behavior to its arc rotate camera.
  94606. * @param camera Defines the camera to attach the behavior to
  94607. */
  94608. attach(camera: ArcRotateCamera): void;
  94609. /**
  94610. * Detaches the behavior from its current arc rotate camera.
  94611. */
  94612. detach(): void;
  94613. private _animatables;
  94614. private _betaIsAnimating;
  94615. private _betaTransition;
  94616. private _radiusTransition;
  94617. private _vectorTransition;
  94618. /**
  94619. * Targets the given mesh and updates zoom level accordingly.
  94620. * @param mesh The mesh to target.
  94621. * @param radius Optional. If a cached radius position already exists, overrides default.
  94622. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94623. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94624. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94625. */
  94626. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94627. /**
  94628. * Targets the given mesh with its children 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94636. /**
  94637. * Targets the given meshes with their children and updates zoom level accordingly.
  94638. * @param meshes 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. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94645. /**
  94646. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94647. * @param minimumWorld Determines the smaller position of the bounding box extend
  94648. * @param maximumWorld Determines the bigger position of the bounding box extend
  94649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94651. */
  94652. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94653. /**
  94654. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94655. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94656. * frustum width.
  94657. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94658. * to fully enclose the mesh in the viewing frustum.
  94659. */
  94660. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94661. /**
  94662. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94663. * is automatically returned to its default position (expected to be above ground plane).
  94664. */
  94665. private _maintainCameraAboveGround;
  94666. /**
  94667. * Returns the frustum slope based on the canvas ratio and camera FOV
  94668. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94669. */
  94670. private _getFrustumSlope;
  94671. /**
  94672. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94673. */
  94674. private _clearAnimationLocks;
  94675. /**
  94676. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94677. */
  94678. private _applyUserInteraction;
  94679. /**
  94680. * Stops and removes all animations that have been applied to the camera
  94681. */
  94682. stopAllAnimations(): void;
  94683. /**
  94684. * Gets a value indicating if the user is moving the camera
  94685. */
  94686. readonly isUserIsMoving: boolean;
  94687. /**
  94688. * The camera can move all the way towards the mesh.
  94689. */
  94690. static IgnoreBoundsSizeMode: number;
  94691. /**
  94692. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94693. */
  94694. static FitFrustumSidesMode: number;
  94695. }
  94696. }
  94697. declare module BABYLON {
  94698. /**
  94699. * Base class for Camera Pointer Inputs.
  94700. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94701. * for example usage.
  94702. */
  94703. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94704. /**
  94705. * Defines the camera the input is attached to.
  94706. */
  94707. abstract camera: Camera;
  94708. /**
  94709. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94710. */
  94711. protected _altKey: boolean;
  94712. protected _ctrlKey: boolean;
  94713. protected _metaKey: boolean;
  94714. protected _shiftKey: boolean;
  94715. /**
  94716. * Which mouse buttons were pressed at time of last mouse event.
  94717. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94718. */
  94719. protected _buttonsPressed: number;
  94720. /**
  94721. * Defines the buttons associated with the input to handle camera move.
  94722. */
  94723. buttons: number[];
  94724. /**
  94725. * Attach the input controls to a specific dom element to get the input from.
  94726. * @param element Defines the element the controls should be listened from
  94727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94728. */
  94729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94730. /**
  94731. * Detach the current controls from the specified dom element.
  94732. * @param element Defines the element to stop listening the inputs from
  94733. */
  94734. detachControl(element: Nullable<HTMLElement>): void;
  94735. /**
  94736. * Gets the class name of the current input.
  94737. * @returns the class name
  94738. */
  94739. getClassName(): string;
  94740. /**
  94741. * Get the friendly name associated with the input class.
  94742. * @returns the input friendly name
  94743. */
  94744. getSimpleName(): string;
  94745. /**
  94746. * Called on pointer POINTERDOUBLETAP event.
  94747. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94748. */
  94749. protected onDoubleTap(type: string): void;
  94750. /**
  94751. * Called on pointer POINTERMOVE event if only a single touch is active.
  94752. * Override this method to provide functionality.
  94753. */
  94754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94755. /**
  94756. * Called on pointer POINTERMOVE event if multiple touches are active.
  94757. * Override this method to provide functionality.
  94758. */
  94759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94760. /**
  94761. * Called on JS contextmenu event.
  94762. * Override this method to provide functionality.
  94763. */
  94764. protected onContextMenu(evt: PointerEvent): void;
  94765. /**
  94766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94767. * press.
  94768. * Override this method to provide functionality.
  94769. */
  94770. protected onButtonDown(evt: PointerEvent): void;
  94771. /**
  94772. * Called each time a new POINTERUP event occurs. Ie, for each button
  94773. * release.
  94774. * Override this method to provide functionality.
  94775. */
  94776. protected onButtonUp(evt: PointerEvent): void;
  94777. /**
  94778. * Called when window becomes inactive.
  94779. * Override this method to provide functionality.
  94780. */
  94781. protected onLostFocus(): void;
  94782. private _pointerInput;
  94783. private _observer;
  94784. private _onLostFocus;
  94785. private pointA;
  94786. private pointB;
  94787. }
  94788. }
  94789. declare module BABYLON {
  94790. /**
  94791. * Manage the pointers inputs to control an arc rotate camera.
  94792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94793. */
  94794. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94795. /**
  94796. * Defines the camera the input is attached to.
  94797. */
  94798. camera: ArcRotateCamera;
  94799. /**
  94800. * Gets the class name of the current input.
  94801. * @returns the class name
  94802. */
  94803. getClassName(): string;
  94804. /**
  94805. * Defines the buttons associated with the input to handle camera move.
  94806. */
  94807. buttons: number[];
  94808. /**
  94809. * Defines the pointer angular sensibility along the X axis or how fast is
  94810. * the camera rotating.
  94811. */
  94812. angularSensibilityX: number;
  94813. /**
  94814. * Defines the pointer angular sensibility along the Y axis or how fast is
  94815. * the camera rotating.
  94816. */
  94817. angularSensibilityY: number;
  94818. /**
  94819. * Defines the pointer pinch precision or how fast is the camera zooming.
  94820. */
  94821. pinchPrecision: number;
  94822. /**
  94823. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94824. * from 0.
  94825. * It defines the percentage of current camera.radius to use as delta when
  94826. * pinch zoom is used.
  94827. */
  94828. pinchDeltaPercentage: number;
  94829. /**
  94830. * Defines the pointer panning sensibility or how fast is the camera moving.
  94831. */
  94832. panningSensibility: number;
  94833. /**
  94834. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94835. */
  94836. multiTouchPanning: boolean;
  94837. /**
  94838. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94839. * zoom (pinch) through multitouch.
  94840. */
  94841. multiTouchPanAndZoom: boolean;
  94842. /**
  94843. * Revers pinch action direction.
  94844. */
  94845. pinchInwards: boolean;
  94846. private _isPanClick;
  94847. private _twoFingerActivityCount;
  94848. private _isPinching;
  94849. /**
  94850. * Called on pointer POINTERMOVE event if only a single touch is active.
  94851. */
  94852. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94853. /**
  94854. * Called on pointer POINTERDOUBLETAP event.
  94855. */
  94856. protected onDoubleTap(type: string): void;
  94857. /**
  94858. * Called on pointer POINTERMOVE event if multiple touches are active.
  94859. */
  94860. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94861. /**
  94862. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94863. * press.
  94864. */
  94865. protected onButtonDown(evt: PointerEvent): void;
  94866. /**
  94867. * Called each time a new POINTERUP event occurs. Ie, for each button
  94868. * release.
  94869. */
  94870. protected onButtonUp(evt: PointerEvent): void;
  94871. /**
  94872. * Called when window becomes inactive.
  94873. */
  94874. protected onLostFocus(): void;
  94875. }
  94876. }
  94877. declare module BABYLON {
  94878. /**
  94879. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94881. */
  94882. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94883. /**
  94884. * Defines the camera the input is attached to.
  94885. */
  94886. camera: ArcRotateCamera;
  94887. /**
  94888. * Defines the list of key codes associated with the up action (increase alpha)
  94889. */
  94890. keysUp: number[];
  94891. /**
  94892. * Defines the list of key codes associated with the down action (decrease alpha)
  94893. */
  94894. keysDown: number[];
  94895. /**
  94896. * Defines the list of key codes associated with the left action (increase beta)
  94897. */
  94898. keysLeft: number[];
  94899. /**
  94900. * Defines the list of key codes associated with the right action (decrease beta)
  94901. */
  94902. keysRight: number[];
  94903. /**
  94904. * Defines the list of key codes associated with the reset action.
  94905. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94906. */
  94907. keysReset: number[];
  94908. /**
  94909. * Defines the panning sensibility of the inputs.
  94910. * (How fast is the camera paning)
  94911. */
  94912. panningSensibility: number;
  94913. /**
  94914. * Defines the zooming sensibility of the inputs.
  94915. * (How fast is the camera zooming)
  94916. */
  94917. zoomingSensibility: number;
  94918. /**
  94919. * Defines wether maintaining the alt key down switch the movement mode from
  94920. * orientation to zoom.
  94921. */
  94922. useAltToZoom: boolean;
  94923. /**
  94924. * Rotation speed of the camera
  94925. */
  94926. angularSpeed: number;
  94927. private _keys;
  94928. private _ctrlPressed;
  94929. private _altPressed;
  94930. private _onCanvasBlurObserver;
  94931. private _onKeyboardObserver;
  94932. private _engine;
  94933. private _scene;
  94934. /**
  94935. * Attach the input controls to a specific dom element to get the input from.
  94936. * @param element Defines the element the controls should be listened from
  94937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94938. */
  94939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94940. /**
  94941. * Detach the current controls from the specified dom element.
  94942. * @param element Defines the element to stop listening the inputs from
  94943. */
  94944. detachControl(element: Nullable<HTMLElement>): void;
  94945. /**
  94946. * Update the current camera state depending on the inputs that have been used this frame.
  94947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94948. */
  94949. checkInputs(): void;
  94950. /**
  94951. * Gets the class name of the current intput.
  94952. * @returns the class name
  94953. */
  94954. getClassName(): string;
  94955. /**
  94956. * Get the friendly name associated with the input class.
  94957. * @returns the input friendly name
  94958. */
  94959. getSimpleName(): string;
  94960. }
  94961. }
  94962. declare module BABYLON {
  94963. /**
  94964. * Manage the mouse wheel inputs to control an arc rotate camera.
  94965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94966. */
  94967. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94968. /**
  94969. * Defines the camera the input is attached to.
  94970. */
  94971. camera: ArcRotateCamera;
  94972. /**
  94973. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94974. */
  94975. wheelPrecision: number;
  94976. /**
  94977. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94978. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94979. */
  94980. wheelDeltaPercentage: number;
  94981. private _wheel;
  94982. private _observer;
  94983. private computeDeltaFromMouseWheelLegacyEvent;
  94984. /**
  94985. * Attach the input controls to a specific dom element to get the input from.
  94986. * @param element Defines the element the controls should be listened from
  94987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94988. */
  94989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94990. /**
  94991. * Detach the current controls from the specified dom element.
  94992. * @param element Defines the element to stop listening the inputs from
  94993. */
  94994. detachControl(element: Nullable<HTMLElement>): void;
  94995. /**
  94996. * Gets the class name of the current intput.
  94997. * @returns the class name
  94998. */
  94999. getClassName(): string;
  95000. /**
  95001. * Get the friendly name associated with the input class.
  95002. * @returns the input friendly name
  95003. */
  95004. getSimpleName(): string;
  95005. }
  95006. }
  95007. declare module BABYLON {
  95008. /**
  95009. * Default Inputs manager for the ArcRotateCamera.
  95010. * It groups all the default supported inputs for ease of use.
  95011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95012. */
  95013. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95014. /**
  95015. * Instantiates a new ArcRotateCameraInputsManager.
  95016. * @param camera Defines the camera the inputs belong to
  95017. */
  95018. constructor(camera: ArcRotateCamera);
  95019. /**
  95020. * Add mouse wheel input support to the input manager.
  95021. * @returns the current input manager
  95022. */
  95023. addMouseWheel(): ArcRotateCameraInputsManager;
  95024. /**
  95025. * Add pointers input support to the input manager.
  95026. * @returns the current input manager
  95027. */
  95028. addPointers(): ArcRotateCameraInputsManager;
  95029. /**
  95030. * Add keyboard input support to the input manager.
  95031. * @returns the current input manager
  95032. */
  95033. addKeyboard(): ArcRotateCameraInputsManager;
  95034. }
  95035. }
  95036. declare module BABYLON {
  95037. /**
  95038. * This represents an orbital type of camera.
  95039. *
  95040. * 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.
  95041. * 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.
  95042. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95043. */
  95044. export class ArcRotateCamera extends TargetCamera {
  95045. /**
  95046. * Defines the rotation angle of the camera along the longitudinal axis.
  95047. */
  95048. alpha: number;
  95049. /**
  95050. * Defines the rotation angle of the camera along the latitudinal axis.
  95051. */
  95052. beta: number;
  95053. /**
  95054. * Defines the radius of the camera from it s target point.
  95055. */
  95056. radius: number;
  95057. protected _target: Vector3;
  95058. protected _targetHost: Nullable<AbstractMesh>;
  95059. /**
  95060. * Defines the target point of the camera.
  95061. * The camera looks towards it form the radius distance.
  95062. */
  95063. target: Vector3;
  95064. /**
  95065. * Define the current local position of the camera in the scene
  95066. */
  95067. position: Vector3;
  95068. protected _upVector: Vector3;
  95069. protected _upToYMatrix: Matrix;
  95070. protected _YToUpMatrix: Matrix;
  95071. /**
  95072. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95073. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95074. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95075. */
  95076. upVector: Vector3;
  95077. /**
  95078. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95079. */
  95080. setMatUp(): void;
  95081. /**
  95082. * Current inertia value on the longitudinal axis.
  95083. * The bigger this number the longer it will take for the camera to stop.
  95084. */
  95085. inertialAlphaOffset: number;
  95086. /**
  95087. * Current inertia value on the latitudinal axis.
  95088. * The bigger this number the longer it will take for the camera to stop.
  95089. */
  95090. inertialBetaOffset: number;
  95091. /**
  95092. * Current inertia value on the radius axis.
  95093. * The bigger this number the longer it will take for the camera to stop.
  95094. */
  95095. inertialRadiusOffset: number;
  95096. /**
  95097. * Minimum allowed angle on the longitudinal axis.
  95098. * This can help limiting how the Camera is able to move in the scene.
  95099. */
  95100. lowerAlphaLimit: Nullable<number>;
  95101. /**
  95102. * Maximum allowed angle on the longitudinal axis.
  95103. * This can help limiting how the Camera is able to move in the scene.
  95104. */
  95105. upperAlphaLimit: Nullable<number>;
  95106. /**
  95107. * Minimum allowed angle on the latitudinal axis.
  95108. * This can help limiting how the Camera is able to move in the scene.
  95109. */
  95110. lowerBetaLimit: number;
  95111. /**
  95112. * Maximum allowed angle on the latitudinal axis.
  95113. * This can help limiting how the Camera is able to move in the scene.
  95114. */
  95115. upperBetaLimit: number;
  95116. /**
  95117. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95118. * This can help limiting how the Camera is able to move in the scene.
  95119. */
  95120. lowerRadiusLimit: Nullable<number>;
  95121. /**
  95122. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95123. * This can help limiting how the Camera is able to move in the scene.
  95124. */
  95125. upperRadiusLimit: Nullable<number>;
  95126. /**
  95127. * Defines the current inertia value used during panning of the camera along the X axis.
  95128. */
  95129. inertialPanningX: number;
  95130. /**
  95131. * Defines the current inertia value used during panning of the camera along the Y axis.
  95132. */
  95133. inertialPanningY: number;
  95134. /**
  95135. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95136. * Basically if your fingers moves away from more than this distance you will be considered
  95137. * in pinch mode.
  95138. */
  95139. pinchToPanMaxDistance: number;
  95140. /**
  95141. * Defines the maximum distance the camera can pan.
  95142. * This could help keeping the cammera always in your scene.
  95143. */
  95144. panningDistanceLimit: Nullable<number>;
  95145. /**
  95146. * Defines the target of the camera before paning.
  95147. */
  95148. panningOriginTarget: Vector3;
  95149. /**
  95150. * Defines the value of the inertia used during panning.
  95151. * 0 would mean stop inertia and one would mean no decelleration at all.
  95152. */
  95153. panningInertia: number;
  95154. /**
  95155. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95156. */
  95157. angularSensibilityX: number;
  95158. /**
  95159. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95160. */
  95161. angularSensibilityY: number;
  95162. /**
  95163. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95164. */
  95165. pinchPrecision: number;
  95166. /**
  95167. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95168. * It will be used instead of pinchDeltaPrecision if different from 0.
  95169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95170. */
  95171. pinchDeltaPercentage: number;
  95172. /**
  95173. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95174. */
  95175. panningSensibility: number;
  95176. /**
  95177. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95178. */
  95179. keysUp: number[];
  95180. /**
  95181. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95182. */
  95183. keysDown: number[];
  95184. /**
  95185. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95186. */
  95187. keysLeft: number[];
  95188. /**
  95189. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95190. */
  95191. keysRight: number[];
  95192. /**
  95193. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95194. */
  95195. wheelPrecision: number;
  95196. /**
  95197. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95198. * It will be used instead of pinchDeltaPrecision if different from 0.
  95199. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95200. */
  95201. wheelDeltaPercentage: number;
  95202. /**
  95203. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95204. */
  95205. zoomOnFactor: number;
  95206. /**
  95207. * Defines a screen offset for the camera position.
  95208. */
  95209. targetScreenOffset: Vector2;
  95210. /**
  95211. * Allows the camera to be completely reversed.
  95212. * If false the camera can not arrive upside down.
  95213. */
  95214. allowUpsideDown: boolean;
  95215. /**
  95216. * Define if double tap/click is used to restore the previously saved state of the camera.
  95217. */
  95218. useInputToRestoreState: boolean;
  95219. /** @hidden */
  95220. _viewMatrix: Matrix;
  95221. /** @hidden */
  95222. _useCtrlForPanning: boolean;
  95223. /** @hidden */
  95224. _panningMouseButton: number;
  95225. /**
  95226. * Defines the input associated to the camera.
  95227. */
  95228. inputs: ArcRotateCameraInputsManager;
  95229. /** @hidden */
  95230. _reset: () => void;
  95231. /**
  95232. * Defines the allowed panning axis.
  95233. */
  95234. panningAxis: Vector3;
  95235. protected _localDirection: Vector3;
  95236. protected _transformedDirection: Vector3;
  95237. private _bouncingBehavior;
  95238. /**
  95239. * Gets the bouncing behavior of the camera if it has been enabled.
  95240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95241. */
  95242. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95243. /**
  95244. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95245. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95246. */
  95247. useBouncingBehavior: boolean;
  95248. private _framingBehavior;
  95249. /**
  95250. * Gets the framing behavior of the camera if it has been enabled.
  95251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95252. */
  95253. readonly framingBehavior: Nullable<FramingBehavior>;
  95254. /**
  95255. * Defines if the framing behavior of the camera is enabled on the camera.
  95256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95257. */
  95258. useFramingBehavior: boolean;
  95259. private _autoRotationBehavior;
  95260. /**
  95261. * Gets the auto rotation behavior of the camera if it has been enabled.
  95262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95263. */
  95264. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95265. /**
  95266. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95268. */
  95269. useAutoRotationBehavior: boolean;
  95270. /**
  95271. * Observable triggered when the mesh target has been changed on the camera.
  95272. */
  95273. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95274. /**
  95275. * Event raised when the camera is colliding with a mesh.
  95276. */
  95277. onCollide: (collidedMesh: AbstractMesh) => void;
  95278. /**
  95279. * Defines whether the camera should check collision with the objects oh the scene.
  95280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95281. */
  95282. checkCollisions: boolean;
  95283. /**
  95284. * Defines the collision radius of the camera.
  95285. * This simulates a sphere around the camera.
  95286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95287. */
  95288. collisionRadius: Vector3;
  95289. protected _collider: Collider;
  95290. protected _previousPosition: Vector3;
  95291. protected _collisionVelocity: Vector3;
  95292. protected _newPosition: Vector3;
  95293. protected _previousAlpha: number;
  95294. protected _previousBeta: number;
  95295. protected _previousRadius: number;
  95296. protected _collisionTriggered: boolean;
  95297. protected _targetBoundingCenter: Nullable<Vector3>;
  95298. private _computationVector;
  95299. /**
  95300. * Instantiates a new ArcRotateCamera in a given scene
  95301. * @param name Defines the name of the camera
  95302. * @param alpha Defines the camera rotation along the logitudinal axis
  95303. * @param beta Defines the camera rotation along the latitudinal axis
  95304. * @param radius Defines the camera distance from its target
  95305. * @param target Defines the camera target
  95306. * @param scene Defines the scene the camera belongs to
  95307. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95308. */
  95309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95310. /** @hidden */
  95311. _initCache(): void;
  95312. /** @hidden */
  95313. _updateCache(ignoreParentClass?: boolean): void;
  95314. protected _getTargetPosition(): Vector3;
  95315. private _storedAlpha;
  95316. private _storedBeta;
  95317. private _storedRadius;
  95318. private _storedTarget;
  95319. /**
  95320. * Stores the current state of the camera (alpha, beta, radius and target)
  95321. * @returns the camera itself
  95322. */
  95323. storeState(): Camera;
  95324. /**
  95325. * @hidden
  95326. * Restored camera state. You must call storeState() first
  95327. */
  95328. _restoreStateValues(): boolean;
  95329. /** @hidden */
  95330. _isSynchronizedViewMatrix(): boolean;
  95331. /**
  95332. * Attached controls to the current camera.
  95333. * @param element Defines the element the controls should be listened from
  95334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95335. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95336. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95337. */
  95338. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95339. /**
  95340. * Detach the current controls from the camera.
  95341. * The camera will stop reacting to inputs.
  95342. * @param element Defines the element to stop listening the inputs from
  95343. */
  95344. detachControl(element: HTMLElement): void;
  95345. /** @hidden */
  95346. _checkInputs(): void;
  95347. protected _checkLimits(): void;
  95348. /**
  95349. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95350. */
  95351. rebuildAnglesAndRadius(): void;
  95352. /**
  95353. * Use a position to define the current camera related information like aplha, beta and radius
  95354. * @param position Defines the position to set the camera at
  95355. */
  95356. setPosition(position: Vector3): void;
  95357. /**
  95358. * Defines the target the camera should look at.
  95359. * This will automatically adapt alpha beta and radius to fit within the new target.
  95360. * @param target Defines the new target as a Vector or a mesh
  95361. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95362. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95363. */
  95364. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95365. /** @hidden */
  95366. _getViewMatrix(): Matrix;
  95367. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95368. /**
  95369. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95370. * @param meshes Defines the mesh to zoom on
  95371. * @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)
  95372. */
  95373. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95374. /**
  95375. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95376. * The target will be changed but the radius
  95377. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95378. * @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)
  95379. */
  95380. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95381. min: Vector3;
  95382. max: Vector3;
  95383. distance: number;
  95384. }, doNotUpdateMaxZ?: boolean): void;
  95385. /**
  95386. * @override
  95387. * Override Camera.createRigCamera
  95388. */
  95389. createRigCamera(name: string, cameraIndex: number): Camera;
  95390. /**
  95391. * @hidden
  95392. * @override
  95393. * Override Camera._updateRigCameras
  95394. */
  95395. _updateRigCameras(): void;
  95396. /**
  95397. * Destroy the camera and release the current resources hold by it.
  95398. */
  95399. dispose(): void;
  95400. /**
  95401. * Gets the current object class name.
  95402. * @return the class name
  95403. */
  95404. getClassName(): string;
  95405. }
  95406. }
  95407. declare module BABYLON {
  95408. /**
  95409. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95410. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95411. */
  95412. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95413. /**
  95414. * Gets the name of the behavior.
  95415. */
  95416. readonly name: string;
  95417. private _zoomStopsAnimation;
  95418. private _idleRotationSpeed;
  95419. private _idleRotationWaitTime;
  95420. private _idleRotationSpinupTime;
  95421. /**
  95422. * Sets the flag that indicates if user zooming should stop animation.
  95423. */
  95424. /**
  95425. * Gets the flag that indicates if user zooming should stop animation.
  95426. */
  95427. zoomStopsAnimation: boolean;
  95428. /**
  95429. * Sets the default speed at which the camera rotates around the model.
  95430. */
  95431. /**
  95432. * Gets the default speed at which the camera rotates around the model.
  95433. */
  95434. idleRotationSpeed: number;
  95435. /**
  95436. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95437. */
  95438. /**
  95439. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95440. */
  95441. idleRotationWaitTime: number;
  95442. /**
  95443. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95444. */
  95445. /**
  95446. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95447. */
  95448. idleRotationSpinupTime: number;
  95449. /**
  95450. * Gets a value indicating if the camera is currently rotating because of this behavior
  95451. */
  95452. readonly rotationInProgress: boolean;
  95453. private _onPrePointerObservableObserver;
  95454. private _onAfterCheckInputsObserver;
  95455. private _attachedCamera;
  95456. private _isPointerDown;
  95457. private _lastFrameTime;
  95458. private _lastInteractionTime;
  95459. private _cameraRotationSpeed;
  95460. /**
  95461. * Initializes the behavior.
  95462. */
  95463. init(): void;
  95464. /**
  95465. * Attaches the behavior to its arc rotate camera.
  95466. * @param camera Defines the camera to attach the behavior to
  95467. */
  95468. attach(camera: ArcRotateCamera): void;
  95469. /**
  95470. * Detaches the behavior from its current arc rotate camera.
  95471. */
  95472. detach(): void;
  95473. /**
  95474. * Returns true if user is scrolling.
  95475. * @return true if user is scrolling.
  95476. */
  95477. private _userIsZooming;
  95478. private _lastFrameRadius;
  95479. private _shouldAnimationStopForInteraction;
  95480. /**
  95481. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95482. */
  95483. private _applyUserInteraction;
  95484. private _userIsMoving;
  95485. }
  95486. }
  95487. declare module BABYLON {
  95488. /**
  95489. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95490. */
  95491. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95492. private ui;
  95493. /**
  95494. * The name of the behavior
  95495. */
  95496. name: string;
  95497. /**
  95498. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95499. */
  95500. distanceAwayFromFace: number;
  95501. /**
  95502. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95503. */
  95504. distanceAwayFromBottomOfFace: number;
  95505. private _faceVectors;
  95506. private _target;
  95507. private _scene;
  95508. private _onRenderObserver;
  95509. private _tmpMatrix;
  95510. private _tmpVector;
  95511. /**
  95512. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95513. * @param ui The transform node that should be attched to the mesh
  95514. */
  95515. constructor(ui: TransformNode);
  95516. /**
  95517. * Initializes the behavior
  95518. */
  95519. init(): void;
  95520. private _closestFace;
  95521. private _zeroVector;
  95522. private _lookAtTmpMatrix;
  95523. private _lookAtToRef;
  95524. /**
  95525. * Attaches the AttachToBoxBehavior to the passed in mesh
  95526. * @param target The mesh that the specified node will be attached to
  95527. */
  95528. attach(target: Mesh): void;
  95529. /**
  95530. * Detaches the behavior from the mesh
  95531. */
  95532. detach(): void;
  95533. }
  95534. }
  95535. declare module BABYLON {
  95536. /**
  95537. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95538. */
  95539. export class FadeInOutBehavior implements Behavior<Mesh> {
  95540. /**
  95541. * Time in milliseconds to delay before fading in (Default: 0)
  95542. */
  95543. delay: number;
  95544. /**
  95545. * Time in milliseconds for the mesh to fade in (Default: 300)
  95546. */
  95547. fadeInTime: number;
  95548. private _millisecondsPerFrame;
  95549. private _hovered;
  95550. private _hoverValue;
  95551. private _ownerNode;
  95552. /**
  95553. * Instatiates the FadeInOutBehavior
  95554. */
  95555. constructor();
  95556. /**
  95557. * The name of the behavior
  95558. */
  95559. readonly name: string;
  95560. /**
  95561. * Initializes the behavior
  95562. */
  95563. init(): void;
  95564. /**
  95565. * Attaches the fade behavior on the passed in mesh
  95566. * @param ownerNode The mesh that will be faded in/out once attached
  95567. */
  95568. attach(ownerNode: Mesh): void;
  95569. /**
  95570. * Detaches the behavior from the mesh
  95571. */
  95572. detach(): void;
  95573. /**
  95574. * Triggers the mesh to begin fading in or out
  95575. * @param value if the object should fade in or out (true to fade in)
  95576. */
  95577. fadeIn(value: boolean): void;
  95578. private _update;
  95579. private _setAllVisibility;
  95580. }
  95581. }
  95582. declare module BABYLON {
  95583. /**
  95584. * Class containing a set of static utilities functions for managing Pivots
  95585. * @hidden
  95586. */
  95587. export class PivotTools {
  95588. private static _PivotCached;
  95589. private static _OldPivotPoint;
  95590. private static _PivotTranslation;
  95591. private static _PivotTmpVector;
  95592. /** @hidden */
  95593. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95594. /** @hidden */
  95595. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95596. }
  95597. }
  95598. declare module BABYLON {
  95599. /**
  95600. * Class containing static functions to help procedurally build meshes
  95601. */
  95602. export class PlaneBuilder {
  95603. /**
  95604. * Creates a plane mesh
  95605. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95606. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95607. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95611. * @param name defines the name of the mesh
  95612. * @param options defines the options used to create the mesh
  95613. * @param scene defines the hosting scene
  95614. * @returns the plane mesh
  95615. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95616. */
  95617. static CreatePlane(name: string, options: {
  95618. size?: number;
  95619. width?: number;
  95620. height?: number;
  95621. sideOrientation?: number;
  95622. frontUVs?: Vector4;
  95623. backUVs?: Vector4;
  95624. updatable?: boolean;
  95625. sourcePlane?: Plane;
  95626. }, scene?: Nullable<Scene>): Mesh;
  95627. }
  95628. }
  95629. declare module BABYLON {
  95630. /**
  95631. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95632. */
  95633. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95634. private static _AnyMouseID;
  95635. private _attachedNode;
  95636. private _dragPlane;
  95637. private _scene;
  95638. private _pointerObserver;
  95639. private _beforeRenderObserver;
  95640. private static _planeScene;
  95641. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95642. /**
  95643. * 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)
  95644. */
  95645. maxDragAngle: number;
  95646. /**
  95647. * @hidden
  95648. */
  95649. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95650. /**
  95651. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95652. */
  95653. currentDraggingPointerID: number;
  95654. /**
  95655. * The last position where the pointer hit the drag plane in world space
  95656. */
  95657. lastDragPosition: Vector3;
  95658. /**
  95659. * If the behavior is currently in a dragging state
  95660. */
  95661. dragging: boolean;
  95662. /**
  95663. * 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)
  95664. */
  95665. dragDeltaRatio: number;
  95666. /**
  95667. * If the drag plane orientation should be updated during the dragging (Default: true)
  95668. */
  95669. updateDragPlane: boolean;
  95670. private _debugMode;
  95671. private _moving;
  95672. /**
  95673. * Fires each time the attached mesh is dragged with the pointer
  95674. * * delta between last drag position and current drag position in world space
  95675. * * dragDistance along the drag axis
  95676. * * dragPlaneNormal normal of the current drag plane used during the drag
  95677. * * dragPlanePoint in world space where the drag intersects the drag plane
  95678. */
  95679. onDragObservable: Observable<{
  95680. delta: Vector3;
  95681. dragPlanePoint: Vector3;
  95682. dragPlaneNormal: Vector3;
  95683. dragDistance: number;
  95684. pointerId: number;
  95685. }>;
  95686. /**
  95687. * Fires each time a drag begins (eg. mouse down on mesh)
  95688. */
  95689. onDragStartObservable: Observable<{
  95690. dragPlanePoint: Vector3;
  95691. pointerId: number;
  95692. }>;
  95693. /**
  95694. * Fires each time a drag ends (eg. mouse release after drag)
  95695. */
  95696. onDragEndObservable: Observable<{
  95697. dragPlanePoint: Vector3;
  95698. pointerId: number;
  95699. }>;
  95700. /**
  95701. * If the attached mesh should be moved when dragged
  95702. */
  95703. moveAttached: boolean;
  95704. /**
  95705. * If the drag behavior will react to drag events (Default: true)
  95706. */
  95707. enabled: boolean;
  95708. /**
  95709. * If camera controls should be detached during the drag
  95710. */
  95711. detachCameraControls: boolean;
  95712. /**
  95713. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95714. */
  95715. useObjectOrienationForDragging: boolean;
  95716. private _options;
  95717. /**
  95718. * Creates a pointer drag behavior that can be attached to a mesh
  95719. * @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)
  95720. */
  95721. constructor(options?: {
  95722. dragAxis?: Vector3;
  95723. dragPlaneNormal?: Vector3;
  95724. });
  95725. /**
  95726. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95727. */
  95728. validateDrag: (targetPosition: Vector3) => boolean;
  95729. /**
  95730. * The name of the behavior
  95731. */
  95732. readonly name: string;
  95733. /**
  95734. * Initializes the behavior
  95735. */
  95736. init(): void;
  95737. private _tmpVector;
  95738. private _alternatePickedPoint;
  95739. private _worldDragAxis;
  95740. private _targetPosition;
  95741. private _attachedElement;
  95742. /**
  95743. * Attaches the drag behavior the passed in mesh
  95744. * @param ownerNode The mesh that will be dragged around once attached
  95745. */
  95746. attach(ownerNode: AbstractMesh): void;
  95747. /**
  95748. * Force relase the drag action by code.
  95749. */
  95750. releaseDrag(): void;
  95751. private _startDragRay;
  95752. private _lastPointerRay;
  95753. /**
  95754. * Simulates the start of a pointer drag event on the behavior
  95755. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95756. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95757. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95758. */
  95759. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95760. private _startDrag;
  95761. private _dragDelta;
  95762. private _moveDrag;
  95763. private _pickWithRayOnDragPlane;
  95764. private _pointA;
  95765. private _pointB;
  95766. private _pointC;
  95767. private _lineA;
  95768. private _lineB;
  95769. private _localAxis;
  95770. private _lookAt;
  95771. private _updateDragPlanePosition;
  95772. /**
  95773. * Detaches the behavior from the mesh
  95774. */
  95775. detach(): void;
  95776. }
  95777. }
  95778. declare module BABYLON {
  95779. /**
  95780. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95781. */
  95782. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95783. private _dragBehaviorA;
  95784. private _dragBehaviorB;
  95785. private _startDistance;
  95786. private _initialScale;
  95787. private _targetScale;
  95788. private _ownerNode;
  95789. private _sceneRenderObserver;
  95790. /**
  95791. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95792. */
  95793. constructor();
  95794. /**
  95795. * The name of the behavior
  95796. */
  95797. readonly name: string;
  95798. /**
  95799. * Initializes the behavior
  95800. */
  95801. init(): void;
  95802. private _getCurrentDistance;
  95803. /**
  95804. * Attaches the scale behavior the passed in mesh
  95805. * @param ownerNode The mesh that will be scaled around once attached
  95806. */
  95807. attach(ownerNode: Mesh): void;
  95808. /**
  95809. * Detaches the behavior from the mesh
  95810. */
  95811. detach(): void;
  95812. }
  95813. }
  95814. declare module BABYLON {
  95815. /**
  95816. * 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
  95817. */
  95818. export class SixDofDragBehavior implements Behavior<Mesh> {
  95819. private static _virtualScene;
  95820. private _ownerNode;
  95821. private _sceneRenderObserver;
  95822. private _scene;
  95823. private _targetPosition;
  95824. private _virtualOriginMesh;
  95825. private _virtualDragMesh;
  95826. private _pointerObserver;
  95827. private _moving;
  95828. private _startingOrientation;
  95829. /**
  95830. * 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)
  95831. */
  95832. private zDragFactor;
  95833. /**
  95834. * If the object should rotate to face the drag origin
  95835. */
  95836. rotateDraggedObject: boolean;
  95837. /**
  95838. * If the behavior is currently in a dragging state
  95839. */
  95840. dragging: boolean;
  95841. /**
  95842. * 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)
  95843. */
  95844. dragDeltaRatio: number;
  95845. /**
  95846. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95847. */
  95848. currentDraggingPointerID: number;
  95849. /**
  95850. * If camera controls should be detached during the drag
  95851. */
  95852. detachCameraControls: boolean;
  95853. /**
  95854. * Fires each time a drag starts
  95855. */
  95856. onDragStartObservable: Observable<{}>;
  95857. /**
  95858. * Fires each time a drag ends (eg. mouse release after drag)
  95859. */
  95860. onDragEndObservable: Observable<{}>;
  95861. /**
  95862. * 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
  95863. */
  95864. constructor();
  95865. /**
  95866. * The name of the behavior
  95867. */
  95868. readonly name: string;
  95869. /**
  95870. * Initializes the behavior
  95871. */
  95872. init(): void;
  95873. /**
  95874. * Attaches the scale behavior the passed in mesh
  95875. * @param ownerNode The mesh that will be scaled around once attached
  95876. */
  95877. attach(ownerNode: Mesh): void;
  95878. /**
  95879. * Detaches the behavior from the mesh
  95880. */
  95881. detach(): void;
  95882. }
  95883. }
  95884. declare module BABYLON {
  95885. /**
  95886. * Class used to apply inverse kinematics to bones
  95887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95888. */
  95889. export class BoneIKController {
  95890. private static _tmpVecs;
  95891. private static _tmpQuat;
  95892. private static _tmpMats;
  95893. /**
  95894. * Gets or sets the target mesh
  95895. */
  95896. targetMesh: AbstractMesh;
  95897. /** Gets or sets the mesh used as pole */
  95898. poleTargetMesh: AbstractMesh;
  95899. /**
  95900. * Gets or sets the bone used as pole
  95901. */
  95902. poleTargetBone: Nullable<Bone>;
  95903. /**
  95904. * Gets or sets the target position
  95905. */
  95906. targetPosition: Vector3;
  95907. /**
  95908. * Gets or sets the pole target position
  95909. */
  95910. poleTargetPosition: Vector3;
  95911. /**
  95912. * Gets or sets the pole target local offset
  95913. */
  95914. poleTargetLocalOffset: Vector3;
  95915. /**
  95916. * Gets or sets the pole angle
  95917. */
  95918. poleAngle: number;
  95919. /**
  95920. * Gets or sets the mesh associated with the controller
  95921. */
  95922. mesh: AbstractMesh;
  95923. /**
  95924. * 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)
  95925. */
  95926. slerpAmount: number;
  95927. private _bone1Quat;
  95928. private _bone1Mat;
  95929. private _bone2Ang;
  95930. private _bone1;
  95931. private _bone2;
  95932. private _bone1Length;
  95933. private _bone2Length;
  95934. private _maxAngle;
  95935. private _maxReach;
  95936. private _rightHandedSystem;
  95937. private _bendAxis;
  95938. private _slerping;
  95939. private _adjustRoll;
  95940. /**
  95941. * Gets or sets maximum allowed angle
  95942. */
  95943. maxAngle: number;
  95944. /**
  95945. * Creates a new BoneIKController
  95946. * @param mesh defines the mesh to control
  95947. * @param bone defines the bone to control
  95948. * @param options defines options to set up the controller
  95949. */
  95950. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95951. targetMesh?: AbstractMesh;
  95952. poleTargetMesh?: AbstractMesh;
  95953. poleTargetBone?: Bone;
  95954. poleTargetLocalOffset?: Vector3;
  95955. poleAngle?: number;
  95956. bendAxis?: Vector3;
  95957. maxAngle?: number;
  95958. slerpAmount?: number;
  95959. });
  95960. private _setMaxAngle;
  95961. /**
  95962. * Force the controller to update the bones
  95963. */
  95964. update(): void;
  95965. }
  95966. }
  95967. declare module BABYLON {
  95968. /**
  95969. * Class used to make a bone look toward a point in space
  95970. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95971. */
  95972. export class BoneLookController {
  95973. private static _tmpVecs;
  95974. private static _tmpQuat;
  95975. private static _tmpMats;
  95976. /**
  95977. * The target Vector3 that the bone will look at
  95978. */
  95979. target: Vector3;
  95980. /**
  95981. * The mesh that the bone is attached to
  95982. */
  95983. mesh: AbstractMesh;
  95984. /**
  95985. * The bone that will be looking to the target
  95986. */
  95987. bone: Bone;
  95988. /**
  95989. * The up axis of the coordinate system that is used when the bone is rotated
  95990. */
  95991. upAxis: Vector3;
  95992. /**
  95993. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95994. */
  95995. upAxisSpace: Space;
  95996. /**
  95997. * Used to make an adjustment to the yaw of the bone
  95998. */
  95999. adjustYaw: number;
  96000. /**
  96001. * Used to make an adjustment to the pitch of the bone
  96002. */
  96003. adjustPitch: number;
  96004. /**
  96005. * Used to make an adjustment to the roll of the bone
  96006. */
  96007. adjustRoll: number;
  96008. /**
  96009. * 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)
  96010. */
  96011. slerpAmount: number;
  96012. private _minYaw;
  96013. private _maxYaw;
  96014. private _minPitch;
  96015. private _maxPitch;
  96016. private _minYawSin;
  96017. private _minYawCos;
  96018. private _maxYawSin;
  96019. private _maxYawCos;
  96020. private _midYawConstraint;
  96021. private _minPitchTan;
  96022. private _maxPitchTan;
  96023. private _boneQuat;
  96024. private _slerping;
  96025. private _transformYawPitch;
  96026. private _transformYawPitchInv;
  96027. private _firstFrameSkipped;
  96028. private _yawRange;
  96029. private _fowardAxis;
  96030. /**
  96031. * Gets or sets the minimum yaw angle that the bone can look to
  96032. */
  96033. minYaw: number;
  96034. /**
  96035. * Gets or sets the maximum yaw angle that the bone can look to
  96036. */
  96037. maxYaw: number;
  96038. /**
  96039. * Gets or sets the minimum pitch angle that the bone can look to
  96040. */
  96041. minPitch: number;
  96042. /**
  96043. * Gets or sets the maximum pitch angle that the bone can look to
  96044. */
  96045. maxPitch: number;
  96046. /**
  96047. * Create a BoneLookController
  96048. * @param mesh the mesh that the bone belongs to
  96049. * @param bone the bone that will be looking to the target
  96050. * @param target the target Vector3 to look at
  96051. * @param options optional settings:
  96052. * * maxYaw: the maximum angle the bone will yaw to
  96053. * * minYaw: the minimum angle the bone will yaw to
  96054. * * maxPitch: the maximum angle the bone will pitch to
  96055. * * minPitch: the minimum angle the bone will yaw to
  96056. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96057. * * upAxis: the up axis of the coordinate system
  96058. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96059. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96060. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96061. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96062. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96063. * * adjustRoll: used to make an adjustment to the roll of the bone
  96064. **/
  96065. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96066. maxYaw?: number;
  96067. minYaw?: number;
  96068. maxPitch?: number;
  96069. minPitch?: number;
  96070. slerpAmount?: number;
  96071. upAxis?: Vector3;
  96072. upAxisSpace?: Space;
  96073. yawAxis?: Vector3;
  96074. pitchAxis?: Vector3;
  96075. adjustYaw?: number;
  96076. adjustPitch?: number;
  96077. adjustRoll?: number;
  96078. });
  96079. /**
  96080. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96081. */
  96082. update(): void;
  96083. private _getAngleDiff;
  96084. private _getAngleBetween;
  96085. private _isAngleBetween;
  96086. }
  96087. }
  96088. declare module BABYLON {
  96089. /**
  96090. * Manage the gamepad inputs to control an arc rotate camera.
  96091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96092. */
  96093. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96094. /**
  96095. * Defines the camera the input is attached to.
  96096. */
  96097. camera: ArcRotateCamera;
  96098. /**
  96099. * Defines the gamepad the input is gathering event from.
  96100. */
  96101. gamepad: Nullable<Gamepad>;
  96102. /**
  96103. * Defines the gamepad rotation sensiblity.
  96104. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96105. */
  96106. gamepadRotationSensibility: number;
  96107. /**
  96108. * Defines the gamepad move sensiblity.
  96109. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96110. */
  96111. gamepadMoveSensibility: number;
  96112. private _onGamepadConnectedObserver;
  96113. private _onGamepadDisconnectedObserver;
  96114. /**
  96115. * Attach the input controls to a specific dom element to get the input from.
  96116. * @param element Defines the element the controls should be listened from
  96117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96118. */
  96119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96120. /**
  96121. * Detach the current controls from the specified dom element.
  96122. * @param element Defines the element to stop listening the inputs from
  96123. */
  96124. detachControl(element: Nullable<HTMLElement>): void;
  96125. /**
  96126. * Update the current camera state depending on the inputs that have been used this frame.
  96127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96128. */
  96129. checkInputs(): void;
  96130. /**
  96131. * Gets the class name of the current intput.
  96132. * @returns the class name
  96133. */
  96134. getClassName(): string;
  96135. /**
  96136. * Get the friendly name associated with the input class.
  96137. * @returns the input friendly name
  96138. */
  96139. getSimpleName(): string;
  96140. }
  96141. }
  96142. declare module BABYLON {
  96143. interface ArcRotateCameraInputsManager {
  96144. /**
  96145. * Add orientation input support to the input manager.
  96146. * @returns the current input manager
  96147. */
  96148. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96149. }
  96150. /**
  96151. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96153. */
  96154. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96155. /**
  96156. * Defines the camera the input is attached to.
  96157. */
  96158. camera: ArcRotateCamera;
  96159. /**
  96160. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96161. */
  96162. alphaCorrection: number;
  96163. /**
  96164. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96165. */
  96166. gammaCorrection: number;
  96167. private _alpha;
  96168. private _gamma;
  96169. private _dirty;
  96170. private _deviceOrientationHandler;
  96171. /**
  96172. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96173. */
  96174. constructor();
  96175. /**
  96176. * Attach the input controls to a specific dom element to get the input from.
  96177. * @param element Defines the element the controls should be listened from
  96178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96179. */
  96180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96181. /** @hidden */
  96182. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96183. /**
  96184. * Update the current camera state depending on the inputs that have been used this frame.
  96185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96186. */
  96187. checkInputs(): void;
  96188. /**
  96189. * Detach the current controls from the specified dom element.
  96190. * @param element Defines the element to stop listening the inputs from
  96191. */
  96192. detachControl(element: Nullable<HTMLElement>): void;
  96193. /**
  96194. * Gets the class name of the current intput.
  96195. * @returns the class name
  96196. */
  96197. getClassName(): string;
  96198. /**
  96199. * Get the friendly name associated with the input class.
  96200. * @returns the input friendly name
  96201. */
  96202. getSimpleName(): string;
  96203. }
  96204. }
  96205. declare module BABYLON {
  96206. /**
  96207. * Listen to mouse events to control the camera.
  96208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96209. */
  96210. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96211. /**
  96212. * Defines the camera the input is attached to.
  96213. */
  96214. camera: FlyCamera;
  96215. /**
  96216. * Defines if touch is enabled. (Default is true.)
  96217. */
  96218. touchEnabled: boolean;
  96219. /**
  96220. * Defines the buttons associated with the input to handle camera rotation.
  96221. */
  96222. buttons: number[];
  96223. /**
  96224. * Assign buttons for Yaw control.
  96225. */
  96226. buttonsYaw: number[];
  96227. /**
  96228. * Assign buttons for Pitch control.
  96229. */
  96230. buttonsPitch: number[];
  96231. /**
  96232. * Assign buttons for Roll control.
  96233. */
  96234. buttonsRoll: number[];
  96235. /**
  96236. * Detect if any button is being pressed while mouse is moved.
  96237. * -1 = Mouse locked.
  96238. * 0 = Left button.
  96239. * 1 = Middle Button.
  96240. * 2 = Right Button.
  96241. */
  96242. activeButton: number;
  96243. /**
  96244. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96245. * Higher values reduce its sensitivity.
  96246. */
  96247. angularSensibility: number;
  96248. private _mousemoveCallback;
  96249. private _observer;
  96250. private _rollObserver;
  96251. private previousPosition;
  96252. private noPreventDefault;
  96253. private element;
  96254. /**
  96255. * Listen to mouse events to control the camera.
  96256. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96258. */
  96259. constructor(touchEnabled?: boolean);
  96260. /**
  96261. * Attach the mouse control to the HTML DOM element.
  96262. * @param element Defines the element that listens to the input events.
  96263. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96264. */
  96265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96266. /**
  96267. * Detach the current controls from the specified dom element.
  96268. * @param element Defines the element to stop listening the inputs from
  96269. */
  96270. detachControl(element: Nullable<HTMLElement>): void;
  96271. /**
  96272. * Gets the class name of the current input.
  96273. * @returns the class name.
  96274. */
  96275. getClassName(): string;
  96276. /**
  96277. * Get the friendly name associated with the input class.
  96278. * @returns the input's friendly name.
  96279. */
  96280. getSimpleName(): string;
  96281. private _pointerInput;
  96282. private _onMouseMove;
  96283. /**
  96284. * Rotate camera by mouse offset.
  96285. */
  96286. private rotateCamera;
  96287. }
  96288. }
  96289. declare module BABYLON {
  96290. /**
  96291. * Default Inputs manager for the FlyCamera.
  96292. * It groups all the default supported inputs for ease of use.
  96293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96294. */
  96295. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96296. /**
  96297. * Instantiates a new FlyCameraInputsManager.
  96298. * @param camera Defines the camera the inputs belong to.
  96299. */
  96300. constructor(camera: FlyCamera);
  96301. /**
  96302. * Add keyboard input support to the input manager.
  96303. * @returns the new FlyCameraKeyboardMoveInput().
  96304. */
  96305. addKeyboard(): FlyCameraInputsManager;
  96306. /**
  96307. * Add mouse input support to the input manager.
  96308. * @param touchEnabled Enable touch screen support.
  96309. * @returns the new FlyCameraMouseInput().
  96310. */
  96311. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96312. }
  96313. }
  96314. declare module BABYLON {
  96315. /**
  96316. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96317. * such as in a 3D Space Shooter or a Flight Simulator.
  96318. */
  96319. export class FlyCamera extends TargetCamera {
  96320. /**
  96321. * Define the collision ellipsoid of the camera.
  96322. * This is helpful for simulating a camera body, like a player's body.
  96323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96324. */
  96325. ellipsoid: Vector3;
  96326. /**
  96327. * Define an offset for the position of the ellipsoid around the camera.
  96328. * This can be helpful if the camera is attached away from the player's body center,
  96329. * such as at its head.
  96330. */
  96331. ellipsoidOffset: Vector3;
  96332. /**
  96333. * Enable or disable collisions of the camera with the rest of the scene objects.
  96334. */
  96335. checkCollisions: boolean;
  96336. /**
  96337. * Enable or disable gravity on the camera.
  96338. */
  96339. applyGravity: boolean;
  96340. /**
  96341. * Define the current direction the camera is moving to.
  96342. */
  96343. cameraDirection: Vector3;
  96344. /**
  96345. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96346. * This overrides and empties cameraRotation.
  96347. */
  96348. rotationQuaternion: Quaternion;
  96349. /**
  96350. * Track Roll to maintain the wanted Rolling when looking around.
  96351. */
  96352. _trackRoll: number;
  96353. /**
  96354. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96355. */
  96356. rollCorrect: number;
  96357. /**
  96358. * Mimic a banked turn, Rolling the camera when Yawing.
  96359. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96360. */
  96361. bankedTurn: boolean;
  96362. /**
  96363. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96364. */
  96365. bankedTurnLimit: number;
  96366. /**
  96367. * Value of 0 disables the banked Roll.
  96368. * Value of 1 is equal to the Yaw angle in radians.
  96369. */
  96370. bankedTurnMultiplier: number;
  96371. /**
  96372. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96373. */
  96374. inputs: FlyCameraInputsManager;
  96375. /**
  96376. * Gets the input sensibility for mouse input.
  96377. * Higher values reduce sensitivity.
  96378. */
  96379. /**
  96380. * Sets the input sensibility for a mouse input.
  96381. * Higher values reduce sensitivity.
  96382. */
  96383. angularSensibility: number;
  96384. /**
  96385. * Get the keys for camera movement forward.
  96386. */
  96387. /**
  96388. * Set the keys for camera movement forward.
  96389. */
  96390. keysForward: number[];
  96391. /**
  96392. * Get the keys for camera movement backward.
  96393. */
  96394. keysBackward: number[];
  96395. /**
  96396. * Get the keys for camera movement up.
  96397. */
  96398. /**
  96399. * Set the keys for camera movement up.
  96400. */
  96401. keysUp: number[];
  96402. /**
  96403. * Get the keys for camera movement down.
  96404. */
  96405. /**
  96406. * Set the keys for camera movement down.
  96407. */
  96408. keysDown: number[];
  96409. /**
  96410. * Get the keys for camera movement left.
  96411. */
  96412. /**
  96413. * Set the keys for camera movement left.
  96414. */
  96415. keysLeft: number[];
  96416. /**
  96417. * Set the keys for camera movement right.
  96418. */
  96419. /**
  96420. * Set the keys for camera movement right.
  96421. */
  96422. keysRight: number[];
  96423. /**
  96424. * Event raised when the camera collides with a mesh in the scene.
  96425. */
  96426. onCollide: (collidedMesh: AbstractMesh) => void;
  96427. private _collider;
  96428. private _needMoveForGravity;
  96429. private _oldPosition;
  96430. private _diffPosition;
  96431. private _newPosition;
  96432. /** @hidden */
  96433. _localDirection: Vector3;
  96434. /** @hidden */
  96435. _transformedDirection: Vector3;
  96436. /**
  96437. * Instantiates a FlyCamera.
  96438. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96439. * such as in a 3D Space Shooter or a Flight Simulator.
  96440. * @param name Define the name of the camera in the scene.
  96441. * @param position Define the starting position of the camera in the scene.
  96442. * @param scene Define the scene the camera belongs to.
  96443. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96444. */
  96445. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96446. /**
  96447. * Attach a control to the HTML DOM element.
  96448. * @param element Defines the element that listens to the input events.
  96449. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96450. */
  96451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96452. /**
  96453. * Detach a control from the HTML DOM element.
  96454. * The camera will stop reacting to that input.
  96455. * @param element Defines the element that listens to the input events.
  96456. */
  96457. detachControl(element: HTMLElement): void;
  96458. private _collisionMask;
  96459. /**
  96460. * Get the mask that the camera ignores in collision events.
  96461. */
  96462. /**
  96463. * Set the mask that the camera ignores in collision events.
  96464. */
  96465. collisionMask: number;
  96466. /** @hidden */
  96467. _collideWithWorld(displacement: Vector3): void;
  96468. /** @hidden */
  96469. private _onCollisionPositionChange;
  96470. /** @hidden */
  96471. _checkInputs(): void;
  96472. /** @hidden */
  96473. _decideIfNeedsToMove(): boolean;
  96474. /** @hidden */
  96475. _updatePosition(): void;
  96476. /**
  96477. * Restore the Roll to its target value at the rate specified.
  96478. * @param rate - Higher means slower restoring.
  96479. * @hidden
  96480. */
  96481. restoreRoll(rate: number): void;
  96482. /**
  96483. * Destroy the camera and release the current resources held by it.
  96484. */
  96485. dispose(): void;
  96486. /**
  96487. * Get the current object class name.
  96488. * @returns the class name.
  96489. */
  96490. getClassName(): string;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. /**
  96495. * Listen to keyboard events to control the camera.
  96496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96497. */
  96498. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96499. /**
  96500. * Defines the camera the input is attached to.
  96501. */
  96502. camera: FlyCamera;
  96503. /**
  96504. * The list of keyboard keys used to control the forward move of the camera.
  96505. */
  96506. keysForward: number[];
  96507. /**
  96508. * The list of keyboard keys used to control the backward move of the camera.
  96509. */
  96510. keysBackward: number[];
  96511. /**
  96512. * The list of keyboard keys used to control the forward move of the camera.
  96513. */
  96514. keysUp: number[];
  96515. /**
  96516. * The list of keyboard keys used to control the backward move of the camera.
  96517. */
  96518. keysDown: number[];
  96519. /**
  96520. * The list of keyboard keys used to control the right strafe move of the camera.
  96521. */
  96522. keysRight: number[];
  96523. /**
  96524. * The list of keyboard keys used to control the left strafe move of the camera.
  96525. */
  96526. keysLeft: number[];
  96527. private _keys;
  96528. private _onCanvasBlurObserver;
  96529. private _onKeyboardObserver;
  96530. private _engine;
  96531. private _scene;
  96532. /**
  96533. * Attach the input controls to a specific dom element to get the input from.
  96534. * @param element Defines the element the controls should be listened from
  96535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96536. */
  96537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96538. /**
  96539. * Detach the current controls from the specified dom element.
  96540. * @param element Defines the element to stop listening the inputs from
  96541. */
  96542. detachControl(element: Nullable<HTMLElement>): void;
  96543. /**
  96544. * Gets the class name of the current intput.
  96545. * @returns the class name
  96546. */
  96547. getClassName(): string;
  96548. /** @hidden */
  96549. _onLostFocus(e: FocusEvent): void;
  96550. /**
  96551. * Get the friendly name associated with the input class.
  96552. * @returns the input friendly name
  96553. */
  96554. getSimpleName(): string;
  96555. /**
  96556. * Update the current camera state depending on the inputs that have been used this frame.
  96557. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96558. */
  96559. checkInputs(): void;
  96560. }
  96561. }
  96562. declare module BABYLON {
  96563. /**
  96564. * Manage the mouse wheel inputs to control a follow camera.
  96565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96566. */
  96567. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96568. /**
  96569. * Defines the camera the input is attached to.
  96570. */
  96571. camera: FollowCamera;
  96572. /**
  96573. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96574. */
  96575. axisControlRadius: boolean;
  96576. /**
  96577. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96578. */
  96579. axisControlHeight: boolean;
  96580. /**
  96581. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96582. */
  96583. axisControlRotation: boolean;
  96584. /**
  96585. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96586. * relation to mouseWheel events.
  96587. */
  96588. wheelPrecision: number;
  96589. /**
  96590. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96591. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96592. */
  96593. wheelDeltaPercentage: number;
  96594. private _wheel;
  96595. private _observer;
  96596. /**
  96597. * Attach the input controls to a specific dom element to get the input from.
  96598. * @param element Defines the element the controls should be listened from
  96599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96600. */
  96601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96602. /**
  96603. * Detach the current controls from the specified dom element.
  96604. * @param element Defines the element to stop listening the inputs from
  96605. */
  96606. detachControl(element: Nullable<HTMLElement>): void;
  96607. /**
  96608. * Gets the class name of the current intput.
  96609. * @returns the class name
  96610. */
  96611. getClassName(): string;
  96612. /**
  96613. * Get the friendly name associated with the input class.
  96614. * @returns the input friendly name
  96615. */
  96616. getSimpleName(): string;
  96617. }
  96618. }
  96619. declare module BABYLON {
  96620. /**
  96621. * Manage the pointers inputs to control an follow camera.
  96622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96623. */
  96624. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96625. /**
  96626. * Defines the camera the input is attached to.
  96627. */
  96628. camera: FollowCamera;
  96629. /**
  96630. * Gets the class name of the current input.
  96631. * @returns the class name
  96632. */
  96633. getClassName(): string;
  96634. /**
  96635. * Defines the pointer angular sensibility along the X axis or how fast is
  96636. * the camera rotating.
  96637. * A negative number will reverse the axis direction.
  96638. */
  96639. angularSensibilityX: number;
  96640. /**
  96641. * Defines the pointer angular sensibility along the Y axis or how fast is
  96642. * the camera rotating.
  96643. * A negative number will reverse the axis direction.
  96644. */
  96645. angularSensibilityY: number;
  96646. /**
  96647. * Defines the pointer pinch precision or how fast is the camera zooming.
  96648. * A negative number will reverse the axis direction.
  96649. */
  96650. pinchPrecision: number;
  96651. /**
  96652. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96653. * from 0.
  96654. * It defines the percentage of current camera.radius to use as delta when
  96655. * pinch zoom is used.
  96656. */
  96657. pinchDeltaPercentage: number;
  96658. /**
  96659. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96660. */
  96661. axisXControlRadius: boolean;
  96662. /**
  96663. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96664. */
  96665. axisXControlHeight: boolean;
  96666. /**
  96667. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96668. */
  96669. axisXControlRotation: boolean;
  96670. /**
  96671. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96672. */
  96673. axisYControlRadius: boolean;
  96674. /**
  96675. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96676. */
  96677. axisYControlHeight: boolean;
  96678. /**
  96679. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96680. */
  96681. axisYControlRotation: boolean;
  96682. /**
  96683. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96684. */
  96685. axisPinchControlRadius: boolean;
  96686. /**
  96687. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96688. */
  96689. axisPinchControlHeight: boolean;
  96690. /**
  96691. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96692. */
  96693. axisPinchControlRotation: boolean;
  96694. /**
  96695. * Log error messages if basic misconfiguration has occurred.
  96696. */
  96697. warningEnable: boolean;
  96698. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96699. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96700. private _warningCounter;
  96701. private _warning;
  96702. }
  96703. }
  96704. declare module BABYLON {
  96705. /**
  96706. * Default Inputs manager for the FollowCamera.
  96707. * It groups all the default supported inputs for ease of use.
  96708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96709. */
  96710. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96711. /**
  96712. * Instantiates a new FollowCameraInputsManager.
  96713. * @param camera Defines the camera the inputs belong to
  96714. */
  96715. constructor(camera: FollowCamera);
  96716. /**
  96717. * Add keyboard input support to the input manager.
  96718. * @returns the current input manager
  96719. */
  96720. addKeyboard(): FollowCameraInputsManager;
  96721. /**
  96722. * Add mouse wheel input support to the input manager.
  96723. * @returns the current input manager
  96724. */
  96725. addMouseWheel(): FollowCameraInputsManager;
  96726. /**
  96727. * Add pointers input support to the input manager.
  96728. * @returns the current input manager
  96729. */
  96730. addPointers(): FollowCameraInputsManager;
  96731. /**
  96732. * Add orientation input support to the input manager.
  96733. * @returns the current input manager
  96734. */
  96735. addVRDeviceOrientation(): FollowCameraInputsManager;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96741. * an arc rotate version arcFollowCamera are available.
  96742. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96743. */
  96744. export class FollowCamera extends TargetCamera {
  96745. /**
  96746. * Distance the follow camera should follow an object at
  96747. */
  96748. radius: number;
  96749. /**
  96750. * Minimum allowed distance of the camera to the axis of rotation
  96751. * (The camera can not get closer).
  96752. * This can help limiting how the Camera is able to move in the scene.
  96753. */
  96754. lowerRadiusLimit: Nullable<number>;
  96755. /**
  96756. * Maximum allowed distance of the camera to the axis of rotation
  96757. * (The camera can not get further).
  96758. * This can help limiting how the Camera is able to move in the scene.
  96759. */
  96760. upperRadiusLimit: Nullable<number>;
  96761. /**
  96762. * Define a rotation offset between the camera and the object it follows
  96763. */
  96764. rotationOffset: number;
  96765. /**
  96766. * Minimum allowed angle to camera position relative to target object.
  96767. * This can help limiting how the Camera is able to move in the scene.
  96768. */
  96769. lowerRotationOffsetLimit: Nullable<number>;
  96770. /**
  96771. * Maximum allowed angle to camera position relative to target object.
  96772. * This can help limiting how the Camera is able to move in the scene.
  96773. */
  96774. upperRotationOffsetLimit: Nullable<number>;
  96775. /**
  96776. * Define a height offset between the camera and the object it follows.
  96777. * It can help following an object from the top (like a car chaing a plane)
  96778. */
  96779. heightOffset: number;
  96780. /**
  96781. * Minimum allowed height of camera position relative to target object.
  96782. * This can help limiting how the Camera is able to move in the scene.
  96783. */
  96784. lowerHeightOffsetLimit: Nullable<number>;
  96785. /**
  96786. * Maximum allowed height of camera position relative to target object.
  96787. * This can help limiting how the Camera is able to move in the scene.
  96788. */
  96789. upperHeightOffsetLimit: Nullable<number>;
  96790. /**
  96791. * Define how fast the camera can accelerate to follow it s target.
  96792. */
  96793. cameraAcceleration: number;
  96794. /**
  96795. * Define the speed limit of the camera following an object.
  96796. */
  96797. maxCameraSpeed: number;
  96798. /**
  96799. * Define the target of the camera.
  96800. */
  96801. lockedTarget: Nullable<AbstractMesh>;
  96802. /**
  96803. * Defines the input associated with the camera.
  96804. */
  96805. inputs: FollowCameraInputsManager;
  96806. /**
  96807. * Instantiates the follow camera.
  96808. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96809. * @param name Define the name of the camera in the scene
  96810. * @param position Define the position of the camera
  96811. * @param scene Define the scene the camera belong to
  96812. * @param lockedTarget Define the target of the camera
  96813. */
  96814. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96815. private _follow;
  96816. /**
  96817. * Attached controls to the current camera.
  96818. * @param element Defines the element the controls should be listened from
  96819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96820. */
  96821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96822. /**
  96823. * Detach the current controls from the camera.
  96824. * The camera will stop reacting to inputs.
  96825. * @param element Defines the element to stop listening the inputs from
  96826. */
  96827. detachControl(element: HTMLElement): void;
  96828. /** @hidden */
  96829. _checkInputs(): void;
  96830. private _checkLimits;
  96831. /**
  96832. * Gets the camera class name.
  96833. * @returns the class name
  96834. */
  96835. getClassName(): string;
  96836. }
  96837. /**
  96838. * Arc Rotate version of the follow camera.
  96839. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96840. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96841. */
  96842. export class ArcFollowCamera extends TargetCamera {
  96843. /** The longitudinal angle of the camera */
  96844. alpha: number;
  96845. /** The latitudinal angle of the camera */
  96846. beta: number;
  96847. /** The radius of the camera from its target */
  96848. radius: number;
  96849. /** Define the camera target (the messh it should follow) */
  96850. target: Nullable<AbstractMesh>;
  96851. private _cartesianCoordinates;
  96852. /**
  96853. * Instantiates a new ArcFollowCamera
  96854. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96855. * @param name Define the name of the camera
  96856. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96857. * @param beta Define the rotation angle of the camera around the elevation axis
  96858. * @param radius Define the radius of the camera from its target point
  96859. * @param target Define the target of the camera
  96860. * @param scene Define the scene the camera belongs to
  96861. */
  96862. constructor(name: string,
  96863. /** The longitudinal angle of the camera */
  96864. alpha: number,
  96865. /** The latitudinal angle of the camera */
  96866. beta: number,
  96867. /** The radius of the camera from its target */
  96868. radius: number,
  96869. /** Define the camera target (the messh it should follow) */
  96870. target: Nullable<AbstractMesh>, scene: Scene);
  96871. private _follow;
  96872. /** @hidden */
  96873. _checkInputs(): void;
  96874. /**
  96875. * Returns the class name of the object.
  96876. * It is mostly used internally for serialization purposes.
  96877. */
  96878. getClassName(): string;
  96879. }
  96880. }
  96881. declare module BABYLON {
  96882. /**
  96883. * Manage the keyboard inputs to control the movement of a follow camera.
  96884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96885. */
  96886. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96887. /**
  96888. * Defines the camera the input is attached to.
  96889. */
  96890. camera: FollowCamera;
  96891. /**
  96892. * Defines the list of key codes associated with the up action (increase heightOffset)
  96893. */
  96894. keysHeightOffsetIncr: number[];
  96895. /**
  96896. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96897. */
  96898. keysHeightOffsetDecr: number[];
  96899. /**
  96900. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96901. */
  96902. keysHeightOffsetModifierAlt: boolean;
  96903. /**
  96904. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96905. */
  96906. keysHeightOffsetModifierCtrl: boolean;
  96907. /**
  96908. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96909. */
  96910. keysHeightOffsetModifierShift: boolean;
  96911. /**
  96912. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96913. */
  96914. keysRotationOffsetIncr: number[];
  96915. /**
  96916. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96917. */
  96918. keysRotationOffsetDecr: number[];
  96919. /**
  96920. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96921. */
  96922. keysRotationOffsetModifierAlt: boolean;
  96923. /**
  96924. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96925. */
  96926. keysRotationOffsetModifierCtrl: boolean;
  96927. /**
  96928. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96929. */
  96930. keysRotationOffsetModifierShift: boolean;
  96931. /**
  96932. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96933. */
  96934. keysRadiusIncr: number[];
  96935. /**
  96936. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96937. */
  96938. keysRadiusDecr: number[];
  96939. /**
  96940. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96941. */
  96942. keysRadiusModifierAlt: boolean;
  96943. /**
  96944. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96945. */
  96946. keysRadiusModifierCtrl: boolean;
  96947. /**
  96948. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96949. */
  96950. keysRadiusModifierShift: boolean;
  96951. /**
  96952. * Defines the rate of change of heightOffset.
  96953. */
  96954. heightSensibility: number;
  96955. /**
  96956. * Defines the rate of change of rotationOffset.
  96957. */
  96958. rotationSensibility: number;
  96959. /**
  96960. * Defines the rate of change of radius.
  96961. */
  96962. radiusSensibility: number;
  96963. private _keys;
  96964. private _ctrlPressed;
  96965. private _altPressed;
  96966. private _shiftPressed;
  96967. private _onCanvasBlurObserver;
  96968. private _onKeyboardObserver;
  96969. private _engine;
  96970. private _scene;
  96971. /**
  96972. * Attach the input controls to a specific dom element to get the input from.
  96973. * @param element Defines the element the controls should be listened from
  96974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96975. */
  96976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96977. /**
  96978. * Detach the current controls from the specified dom element.
  96979. * @param element Defines the element to stop listening the inputs from
  96980. */
  96981. detachControl(element: Nullable<HTMLElement>): void;
  96982. /**
  96983. * Update the current camera state depending on the inputs that have been used this frame.
  96984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96985. */
  96986. checkInputs(): void;
  96987. /**
  96988. * Gets the class name of the current input.
  96989. * @returns the class name
  96990. */
  96991. getClassName(): string;
  96992. /**
  96993. * Get the friendly name associated with the input class.
  96994. * @returns the input friendly name
  96995. */
  96996. getSimpleName(): string;
  96997. /**
  96998. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96999. * allow modification of the heightOffset value.
  97000. */
  97001. private _modifierHeightOffset;
  97002. /**
  97003. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97004. * allow modification of the rotationOffset value.
  97005. */
  97006. private _modifierRotationOffset;
  97007. /**
  97008. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97009. * allow modification of the radius value.
  97010. */
  97011. private _modifierRadius;
  97012. }
  97013. }
  97014. declare module BABYLON {
  97015. interface FreeCameraInputsManager {
  97016. /**
  97017. * @hidden
  97018. */
  97019. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97020. /**
  97021. * Add orientation input support to the input manager.
  97022. * @returns the current input manager
  97023. */
  97024. addDeviceOrientation(): FreeCameraInputsManager;
  97025. }
  97026. /**
  97027. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97028. * Screen rotation is taken into account.
  97029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97030. */
  97031. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97032. private _camera;
  97033. private _screenOrientationAngle;
  97034. private _constantTranform;
  97035. private _screenQuaternion;
  97036. private _alpha;
  97037. private _beta;
  97038. private _gamma;
  97039. /**
  97040. * @hidden
  97041. */
  97042. _onDeviceOrientationChangedObservable: Observable<void>;
  97043. /**
  97044. * Instantiates a new input
  97045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97046. */
  97047. constructor();
  97048. /**
  97049. * Define the camera controlled by the input.
  97050. */
  97051. camera: FreeCamera;
  97052. /**
  97053. * Attach the input controls to a specific dom element to get the input from.
  97054. * @param element Defines the element the controls should be listened from
  97055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97056. */
  97057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97058. private _orientationChanged;
  97059. private _deviceOrientation;
  97060. /**
  97061. * Detach the current controls from the specified dom element.
  97062. * @param element Defines the element to stop listening the inputs from
  97063. */
  97064. detachControl(element: Nullable<HTMLElement>): void;
  97065. /**
  97066. * Update the current camera state depending on the inputs that have been used this frame.
  97067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97068. */
  97069. checkInputs(): void;
  97070. /**
  97071. * Gets the class name of the current intput.
  97072. * @returns the class name
  97073. */
  97074. getClassName(): string;
  97075. /**
  97076. * Get the friendly name associated with the input class.
  97077. * @returns the input friendly name
  97078. */
  97079. getSimpleName(): string;
  97080. }
  97081. }
  97082. declare module BABYLON {
  97083. /**
  97084. * Manage the gamepad inputs to control a free camera.
  97085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97086. */
  97087. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97088. /**
  97089. * Define the camera the input is attached to.
  97090. */
  97091. camera: FreeCamera;
  97092. /**
  97093. * Define the Gamepad controlling the input
  97094. */
  97095. gamepad: Nullable<Gamepad>;
  97096. /**
  97097. * Defines the gamepad rotation sensiblity.
  97098. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97099. */
  97100. gamepadAngularSensibility: number;
  97101. /**
  97102. * Defines the gamepad move sensiblity.
  97103. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97104. */
  97105. gamepadMoveSensibility: number;
  97106. private _onGamepadConnectedObserver;
  97107. private _onGamepadDisconnectedObserver;
  97108. private _cameraTransform;
  97109. private _deltaTransform;
  97110. private _vector3;
  97111. private _vector2;
  97112. /**
  97113. * Attach the input controls to a specific dom element to get the input from.
  97114. * @param element Defines the element the controls should be listened from
  97115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97116. */
  97117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97118. /**
  97119. * Detach the current controls from the specified dom element.
  97120. * @param element Defines the element to stop listening the inputs from
  97121. */
  97122. detachControl(element: Nullable<HTMLElement>): void;
  97123. /**
  97124. * Update the current camera state depending on the inputs that have been used this frame.
  97125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97126. */
  97127. checkInputs(): void;
  97128. /**
  97129. * Gets the class name of the current intput.
  97130. * @returns the class name
  97131. */
  97132. getClassName(): string;
  97133. /**
  97134. * Get the friendly name associated with the input class.
  97135. * @returns the input friendly name
  97136. */
  97137. getSimpleName(): string;
  97138. }
  97139. }
  97140. declare module BABYLON {
  97141. /**
  97142. * Defines the potential axis of a Joystick
  97143. */
  97144. export enum JoystickAxis {
  97145. /** X axis */
  97146. X = 0,
  97147. /** Y axis */
  97148. Y = 1,
  97149. /** Z axis */
  97150. Z = 2
  97151. }
  97152. /**
  97153. * Class used to define virtual joystick (used in touch mode)
  97154. */
  97155. export class VirtualJoystick {
  97156. /**
  97157. * Gets or sets a boolean indicating that left and right values must be inverted
  97158. */
  97159. reverseLeftRight: boolean;
  97160. /**
  97161. * Gets or sets a boolean indicating that up and down values must be inverted
  97162. */
  97163. reverseUpDown: boolean;
  97164. /**
  97165. * Gets the offset value for the position (ie. the change of the position value)
  97166. */
  97167. deltaPosition: Vector3;
  97168. /**
  97169. * Gets a boolean indicating if the virtual joystick was pressed
  97170. */
  97171. pressed: boolean;
  97172. /**
  97173. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97174. */
  97175. static Canvas: Nullable<HTMLCanvasElement>;
  97176. private static _globalJoystickIndex;
  97177. private static vjCanvasContext;
  97178. private static vjCanvasWidth;
  97179. private static vjCanvasHeight;
  97180. private static halfWidth;
  97181. private _action;
  97182. private _axisTargetedByLeftAndRight;
  97183. private _axisTargetedByUpAndDown;
  97184. private _joystickSensibility;
  97185. private _inversedSensibility;
  97186. private _joystickPointerID;
  97187. private _joystickColor;
  97188. private _joystickPointerPos;
  97189. private _joystickPreviousPointerPos;
  97190. private _joystickPointerStartPos;
  97191. private _deltaJoystickVector;
  97192. private _leftJoystick;
  97193. private _touches;
  97194. private _onPointerDownHandlerRef;
  97195. private _onPointerMoveHandlerRef;
  97196. private _onPointerUpHandlerRef;
  97197. private _onResize;
  97198. /**
  97199. * Creates a new virtual joystick
  97200. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97201. */
  97202. constructor(leftJoystick?: boolean);
  97203. /**
  97204. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97205. * @param newJoystickSensibility defines the new sensibility
  97206. */
  97207. setJoystickSensibility(newJoystickSensibility: number): void;
  97208. private _onPointerDown;
  97209. private _onPointerMove;
  97210. private _onPointerUp;
  97211. /**
  97212. * Change the color of the virtual joystick
  97213. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97214. */
  97215. setJoystickColor(newColor: string): void;
  97216. /**
  97217. * Defines a callback to call when the joystick is touched
  97218. * @param action defines the callback
  97219. */
  97220. setActionOnTouch(action: () => any): void;
  97221. /**
  97222. * Defines which axis you'd like to control for left & right
  97223. * @param axis defines the axis to use
  97224. */
  97225. setAxisForLeftRight(axis: JoystickAxis): void;
  97226. /**
  97227. * Defines which axis you'd like to control for up & down
  97228. * @param axis defines the axis to use
  97229. */
  97230. setAxisForUpDown(axis: JoystickAxis): void;
  97231. private _drawVirtualJoystick;
  97232. /**
  97233. * Release internal HTML canvas
  97234. */
  97235. releaseCanvas(): void;
  97236. }
  97237. }
  97238. declare module BABYLON {
  97239. interface FreeCameraInputsManager {
  97240. /**
  97241. * Add virtual joystick input support to the input manager.
  97242. * @returns the current input manager
  97243. */
  97244. addVirtualJoystick(): FreeCameraInputsManager;
  97245. }
  97246. /**
  97247. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97249. */
  97250. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97251. /**
  97252. * Defines the camera the input is attached to.
  97253. */
  97254. camera: FreeCamera;
  97255. private _leftjoystick;
  97256. private _rightjoystick;
  97257. /**
  97258. * Gets the left stick of the virtual joystick.
  97259. * @returns The virtual Joystick
  97260. */
  97261. getLeftJoystick(): VirtualJoystick;
  97262. /**
  97263. * Gets the right stick of the virtual joystick.
  97264. * @returns The virtual Joystick
  97265. */
  97266. getRightJoystick(): VirtualJoystick;
  97267. /**
  97268. * Update the current camera state depending on the inputs that have been used this frame.
  97269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97270. */
  97271. checkInputs(): void;
  97272. /**
  97273. * Attach the input controls to a specific dom element to get the input from.
  97274. * @param element Defines the element the controls should be listened from
  97275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97276. */
  97277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97278. /**
  97279. * Detach the current controls from the specified dom element.
  97280. * @param element Defines the element to stop listening the inputs from
  97281. */
  97282. detachControl(element: Nullable<HTMLElement>): void;
  97283. /**
  97284. * Gets the class name of the current intput.
  97285. * @returns the class name
  97286. */
  97287. getClassName(): string;
  97288. /**
  97289. * Get the friendly name associated with the input class.
  97290. * @returns the input friendly name
  97291. */
  97292. getSimpleName(): string;
  97293. }
  97294. }
  97295. declare module BABYLON {
  97296. /**
  97297. * This represents a FPS type of camera controlled by touch.
  97298. * This is like a universal camera minus the Gamepad controls.
  97299. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97300. */
  97301. export class TouchCamera extends FreeCamera {
  97302. /**
  97303. * Defines the touch sensibility for rotation.
  97304. * The higher the faster.
  97305. */
  97306. touchAngularSensibility: number;
  97307. /**
  97308. * Defines the touch sensibility for move.
  97309. * The higher the faster.
  97310. */
  97311. touchMoveSensibility: number;
  97312. /**
  97313. * Instantiates a new touch camera.
  97314. * This represents a FPS type of camera controlled by touch.
  97315. * This is like a universal camera minus the Gamepad controls.
  97316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97317. * @param name Define the name of the camera in the scene
  97318. * @param position Define the start position of the camera in the scene
  97319. * @param scene Define the scene the camera belongs to
  97320. */
  97321. constructor(name: string, position: Vector3, scene: Scene);
  97322. /**
  97323. * Gets the current object class name.
  97324. * @return the class name
  97325. */
  97326. getClassName(): string;
  97327. /** @hidden */
  97328. _setupInputs(): void;
  97329. }
  97330. }
  97331. declare module BABYLON {
  97332. /**
  97333. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97334. * being tilted forward or back and left or right.
  97335. */
  97336. export class DeviceOrientationCamera extends FreeCamera {
  97337. private _initialQuaternion;
  97338. private _quaternionCache;
  97339. private _tmpDragQuaternion;
  97340. /**
  97341. * Creates a new device orientation camera
  97342. * @param name The name of the camera
  97343. * @param position The start position camera
  97344. * @param scene The scene the camera belongs to
  97345. */
  97346. constructor(name: string, position: Vector3, scene: Scene);
  97347. /**
  97348. * @hidden
  97349. * Disabled pointer input on first orientation sensor update (Default: true)
  97350. */
  97351. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97352. private _dragFactor;
  97353. /**
  97354. * Enabled turning on the y axis when the orientation sensor is active
  97355. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97356. */
  97357. enableHorizontalDragging(dragFactor?: number): void;
  97358. /**
  97359. * Gets the current instance class name ("DeviceOrientationCamera").
  97360. * This helps avoiding instanceof at run time.
  97361. * @returns the class name
  97362. */
  97363. getClassName(): string;
  97364. /**
  97365. * @hidden
  97366. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97367. */
  97368. _checkInputs(): void;
  97369. /**
  97370. * Reset the camera to its default orientation on the specified axis only.
  97371. * @param axis The axis to reset
  97372. */
  97373. resetToCurrentRotation(axis?: Axis): void;
  97374. }
  97375. }
  97376. declare module BABYLON {
  97377. /**
  97378. * 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,
  97379. * which still works and will still be found in many Playgrounds.
  97380. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97381. */
  97382. export class UniversalCamera extends TouchCamera {
  97383. /**
  97384. * Defines the gamepad rotation sensiblity.
  97385. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97386. */
  97387. gamepadAngularSensibility: number;
  97388. /**
  97389. * Defines the gamepad move sensiblity.
  97390. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97391. */
  97392. gamepadMoveSensibility: number;
  97393. /**
  97394. * 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,
  97395. * which still works and will still be found in many Playgrounds.
  97396. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97397. * @param name Define the name of the camera in the scene
  97398. * @param position Define the start position of the camera in the scene
  97399. * @param scene Define the scene the camera belongs to
  97400. */
  97401. constructor(name: string, position: Vector3, scene: Scene);
  97402. /**
  97403. * Gets the current object class name.
  97404. * @return the class name
  97405. */
  97406. getClassName(): string;
  97407. }
  97408. }
  97409. declare module BABYLON {
  97410. /**
  97411. * This represents a FPS type of camera. This is only here for back compat purpose.
  97412. * Please use the UniversalCamera instead as both are identical.
  97413. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97414. */
  97415. export class GamepadCamera extends UniversalCamera {
  97416. /**
  97417. * Instantiates a new Gamepad Camera
  97418. * This represents a FPS type of camera. This is only here for back compat purpose.
  97419. * Please use the UniversalCamera instead as both are identical.
  97420. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97421. * @param name Define the name of the camera in the scene
  97422. * @param position Define the start position of the camera in the scene
  97423. * @param scene Define the scene the camera belongs to
  97424. */
  97425. constructor(name: string, position: Vector3, scene: Scene);
  97426. /**
  97427. * Gets the current object class name.
  97428. * @return the class name
  97429. */
  97430. getClassName(): string;
  97431. }
  97432. }
  97433. declare module BABYLON {
  97434. /** @hidden */
  97435. export var passPixelShader: {
  97436. name: string;
  97437. shader: string;
  97438. };
  97439. }
  97440. declare module BABYLON {
  97441. /** @hidden */
  97442. export var passCubePixelShader: {
  97443. name: string;
  97444. shader: string;
  97445. };
  97446. }
  97447. declare module BABYLON {
  97448. /**
  97449. * PassPostProcess which produces an output the same as it's input
  97450. */
  97451. export class PassPostProcess extends PostProcess {
  97452. /**
  97453. * Creates the PassPostProcess
  97454. * @param name The name of the effect.
  97455. * @param options The required width/height ratio to downsize to before computing the render pass.
  97456. * @param camera The camera to apply the render pass to.
  97457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97458. * @param engine The engine which the post process will be applied. (default: current engine)
  97459. * @param reusable If the post process can be reused on the same frame. (default: false)
  97460. * @param textureType The type of texture to be used when performing the post processing.
  97461. * @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)
  97462. */
  97463. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97464. }
  97465. /**
  97466. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97467. */
  97468. export class PassCubePostProcess extends PostProcess {
  97469. private _face;
  97470. /**
  97471. * Gets or sets the cube face to display.
  97472. * * 0 is +X
  97473. * * 1 is -X
  97474. * * 2 is +Y
  97475. * * 3 is -Y
  97476. * * 4 is +Z
  97477. * * 5 is -Z
  97478. */
  97479. face: number;
  97480. /**
  97481. * Creates the PassCubePostProcess
  97482. * @param name The name of the effect.
  97483. * @param options The required width/height ratio to downsize to before computing the render pass.
  97484. * @param camera The camera to apply the render pass to.
  97485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97486. * @param engine The engine which the post process will be applied. (default: current engine)
  97487. * @param reusable If the post process can be reused on the same frame. (default: false)
  97488. * @param textureType The type of texture to be used when performing the post processing.
  97489. * @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)
  97490. */
  97491. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97492. }
  97493. }
  97494. declare module BABYLON {
  97495. /** @hidden */
  97496. export var anaglyphPixelShader: {
  97497. name: string;
  97498. shader: string;
  97499. };
  97500. }
  97501. declare module BABYLON {
  97502. /**
  97503. * Postprocess used to generate anaglyphic rendering
  97504. */
  97505. export class AnaglyphPostProcess extends PostProcess {
  97506. private _passedProcess;
  97507. /**
  97508. * Creates a new AnaglyphPostProcess
  97509. * @param name defines postprocess name
  97510. * @param options defines creation options or target ratio scale
  97511. * @param rigCameras defines cameras using this postprocess
  97512. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97513. * @param engine defines hosting engine
  97514. * @param reusable defines if the postprocess will be reused multiple times per frame
  97515. */
  97516. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97517. }
  97518. }
  97519. declare module BABYLON {
  97520. /**
  97521. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97522. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97523. */
  97524. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97525. /**
  97526. * Creates a new AnaglyphArcRotateCamera
  97527. * @param name defines camera name
  97528. * @param alpha defines alpha angle (in radians)
  97529. * @param beta defines beta angle (in radians)
  97530. * @param radius defines radius
  97531. * @param target defines camera target
  97532. * @param interaxialDistance defines distance between each color axis
  97533. * @param scene defines the hosting scene
  97534. */
  97535. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97536. /**
  97537. * Gets camera class name
  97538. * @returns AnaglyphArcRotateCamera
  97539. */
  97540. getClassName(): string;
  97541. }
  97542. }
  97543. declare module BABYLON {
  97544. /**
  97545. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97546. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97547. */
  97548. export class AnaglyphFreeCamera extends FreeCamera {
  97549. /**
  97550. * Creates a new AnaglyphFreeCamera
  97551. * @param name defines camera name
  97552. * @param position defines initial position
  97553. * @param interaxialDistance defines distance between each color axis
  97554. * @param scene defines the hosting scene
  97555. */
  97556. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97557. /**
  97558. * Gets camera class name
  97559. * @returns AnaglyphFreeCamera
  97560. */
  97561. getClassName(): string;
  97562. }
  97563. }
  97564. declare module BABYLON {
  97565. /**
  97566. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97567. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97568. */
  97569. export class AnaglyphGamepadCamera extends GamepadCamera {
  97570. /**
  97571. * Creates a new AnaglyphGamepadCamera
  97572. * @param name defines camera name
  97573. * @param position defines initial position
  97574. * @param interaxialDistance defines distance between each color axis
  97575. * @param scene defines the hosting scene
  97576. */
  97577. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97578. /**
  97579. * Gets camera class name
  97580. * @returns AnaglyphGamepadCamera
  97581. */
  97582. getClassName(): string;
  97583. }
  97584. }
  97585. declare module BABYLON {
  97586. /**
  97587. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97588. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97589. */
  97590. export class AnaglyphUniversalCamera extends UniversalCamera {
  97591. /**
  97592. * Creates a new AnaglyphUniversalCamera
  97593. * @param name defines camera name
  97594. * @param position defines initial position
  97595. * @param interaxialDistance defines distance between each color axis
  97596. * @param scene defines the hosting scene
  97597. */
  97598. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97599. /**
  97600. * Gets camera class name
  97601. * @returns AnaglyphUniversalCamera
  97602. */
  97603. getClassName(): string;
  97604. }
  97605. }
  97606. declare module BABYLON {
  97607. /** @hidden */
  97608. export var stereoscopicInterlacePixelShader: {
  97609. name: string;
  97610. shader: string;
  97611. };
  97612. }
  97613. declare module BABYLON {
  97614. /**
  97615. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97616. */
  97617. export class StereoscopicInterlacePostProcess extends PostProcess {
  97618. private _stepSize;
  97619. private _passedProcess;
  97620. /**
  97621. * Initializes a StereoscopicInterlacePostProcess
  97622. * @param name The name of the effect.
  97623. * @param rigCameras The rig cameras to be appled to the post process
  97624. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97626. * @param engine The engine which the post process will be applied. (default: current engine)
  97627. * @param reusable If the post process can be reused on the same frame. (default: false)
  97628. */
  97629. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97630. }
  97631. }
  97632. declare module BABYLON {
  97633. /**
  97634. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97635. * @see http://doc.babylonjs.com/features/cameras
  97636. */
  97637. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97638. /**
  97639. * Creates a new StereoscopicArcRotateCamera
  97640. * @param name defines camera name
  97641. * @param alpha defines alpha angle (in radians)
  97642. * @param beta defines beta angle (in radians)
  97643. * @param radius defines radius
  97644. * @param target defines camera target
  97645. * @param interaxialDistance defines distance between each color axis
  97646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97647. * @param scene defines the hosting scene
  97648. */
  97649. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97650. /**
  97651. * Gets camera class name
  97652. * @returns StereoscopicArcRotateCamera
  97653. */
  97654. getClassName(): string;
  97655. }
  97656. }
  97657. declare module BABYLON {
  97658. /**
  97659. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97660. * @see http://doc.babylonjs.com/features/cameras
  97661. */
  97662. export class StereoscopicFreeCamera extends FreeCamera {
  97663. /**
  97664. * Creates a new StereoscopicFreeCamera
  97665. * @param name defines camera name
  97666. * @param position defines initial position
  97667. * @param interaxialDistance defines distance between each color axis
  97668. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97669. * @param scene defines the hosting scene
  97670. */
  97671. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97672. /**
  97673. * Gets camera class name
  97674. * @returns StereoscopicFreeCamera
  97675. */
  97676. getClassName(): string;
  97677. }
  97678. }
  97679. declare module BABYLON {
  97680. /**
  97681. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97682. * @see http://doc.babylonjs.com/features/cameras
  97683. */
  97684. export class StereoscopicGamepadCamera extends GamepadCamera {
  97685. /**
  97686. * Creates a new StereoscopicGamepadCamera
  97687. * @param name defines camera name
  97688. * @param position defines initial position
  97689. * @param interaxialDistance defines distance between each color axis
  97690. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97691. * @param scene defines the hosting scene
  97692. */
  97693. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97694. /**
  97695. * Gets camera class name
  97696. * @returns StereoscopicGamepadCamera
  97697. */
  97698. getClassName(): string;
  97699. }
  97700. }
  97701. declare module BABYLON {
  97702. /**
  97703. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97704. * @see http://doc.babylonjs.com/features/cameras
  97705. */
  97706. export class StereoscopicUniversalCamera extends UniversalCamera {
  97707. /**
  97708. * Creates a new StereoscopicUniversalCamera
  97709. * @param name defines camera name
  97710. * @param position defines initial position
  97711. * @param interaxialDistance defines distance between each color axis
  97712. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97713. * @param scene defines the hosting scene
  97714. */
  97715. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97716. /**
  97717. * Gets camera class name
  97718. * @returns StereoscopicUniversalCamera
  97719. */
  97720. getClassName(): string;
  97721. }
  97722. }
  97723. declare module BABYLON {
  97724. /**
  97725. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97726. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97727. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97728. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97729. */
  97730. export class VirtualJoysticksCamera extends FreeCamera {
  97731. /**
  97732. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97733. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97734. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97735. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97736. * @param name Define the name of the camera in the scene
  97737. * @param position Define the start position of the camera in the scene
  97738. * @param scene Define the scene the camera belongs to
  97739. */
  97740. constructor(name: string, position: Vector3, scene: Scene);
  97741. /**
  97742. * Gets the current object class name.
  97743. * @return the class name
  97744. */
  97745. getClassName(): string;
  97746. }
  97747. }
  97748. declare module BABYLON {
  97749. /**
  97750. * This represents all the required metrics to create a VR camera.
  97751. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97752. */
  97753. export class VRCameraMetrics {
  97754. /**
  97755. * Define the horizontal resolution off the screen.
  97756. */
  97757. hResolution: number;
  97758. /**
  97759. * Define the vertical resolution off the screen.
  97760. */
  97761. vResolution: number;
  97762. /**
  97763. * Define the horizontal screen size.
  97764. */
  97765. hScreenSize: number;
  97766. /**
  97767. * Define the vertical screen size.
  97768. */
  97769. vScreenSize: number;
  97770. /**
  97771. * Define the vertical screen center position.
  97772. */
  97773. vScreenCenter: number;
  97774. /**
  97775. * Define the distance of the eyes to the screen.
  97776. */
  97777. eyeToScreenDistance: number;
  97778. /**
  97779. * Define the distance between both lenses
  97780. */
  97781. lensSeparationDistance: number;
  97782. /**
  97783. * Define the distance between both viewer's eyes.
  97784. */
  97785. interpupillaryDistance: number;
  97786. /**
  97787. * Define the distortion factor of the VR postprocess.
  97788. * Please, touch with care.
  97789. */
  97790. distortionK: number[];
  97791. /**
  97792. * Define the chromatic aberration correction factors for the VR post process.
  97793. */
  97794. chromaAbCorrection: number[];
  97795. /**
  97796. * Define the scale factor of the post process.
  97797. * The smaller the better but the slower.
  97798. */
  97799. postProcessScaleFactor: number;
  97800. /**
  97801. * Define an offset for the lens center.
  97802. */
  97803. lensCenterOffset: number;
  97804. /**
  97805. * Define if the current vr camera should compensate the distortion of the lense or not.
  97806. */
  97807. compensateDistortion: boolean;
  97808. /**
  97809. * Defines if multiview should be enabled when rendering (Default: false)
  97810. */
  97811. multiviewEnabled: boolean;
  97812. /**
  97813. * Gets the rendering aspect ratio based on the provided resolutions.
  97814. */
  97815. readonly aspectRatio: number;
  97816. /**
  97817. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97818. */
  97819. readonly aspectRatioFov: number;
  97820. /**
  97821. * @hidden
  97822. */
  97823. readonly leftHMatrix: Matrix;
  97824. /**
  97825. * @hidden
  97826. */
  97827. readonly rightHMatrix: Matrix;
  97828. /**
  97829. * @hidden
  97830. */
  97831. readonly leftPreViewMatrix: Matrix;
  97832. /**
  97833. * @hidden
  97834. */
  97835. readonly rightPreViewMatrix: Matrix;
  97836. /**
  97837. * Get the default VRMetrics based on the most generic setup.
  97838. * @returns the default vr metrics
  97839. */
  97840. static GetDefault(): VRCameraMetrics;
  97841. }
  97842. }
  97843. declare module BABYLON {
  97844. /** @hidden */
  97845. export var vrDistortionCorrectionPixelShader: {
  97846. name: string;
  97847. shader: string;
  97848. };
  97849. }
  97850. declare module BABYLON {
  97851. /**
  97852. * VRDistortionCorrectionPostProcess used for mobile VR
  97853. */
  97854. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97855. private _isRightEye;
  97856. private _distortionFactors;
  97857. private _postProcessScaleFactor;
  97858. private _lensCenterOffset;
  97859. private _scaleIn;
  97860. private _scaleFactor;
  97861. private _lensCenter;
  97862. /**
  97863. * Initializes the VRDistortionCorrectionPostProcess
  97864. * @param name The name of the effect.
  97865. * @param camera The camera to apply the render pass to.
  97866. * @param isRightEye If this is for the right eye distortion
  97867. * @param vrMetrics All the required metrics for the VR camera
  97868. */
  97869. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97870. }
  97871. }
  97872. declare module BABYLON {
  97873. /**
  97874. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97875. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97876. */
  97877. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97878. /**
  97879. * Creates a new VRDeviceOrientationArcRotateCamera
  97880. * @param name defines camera name
  97881. * @param alpha defines the camera rotation along the logitudinal axis
  97882. * @param beta defines the camera rotation along the latitudinal axis
  97883. * @param radius defines the camera distance from its target
  97884. * @param target defines the camera target
  97885. * @param scene defines the scene the camera belongs to
  97886. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97887. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97888. */
  97889. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97890. /**
  97891. * Gets camera class name
  97892. * @returns VRDeviceOrientationArcRotateCamera
  97893. */
  97894. getClassName(): string;
  97895. }
  97896. }
  97897. declare module BABYLON {
  97898. /**
  97899. * Camera used to simulate VR rendering (based on FreeCamera)
  97900. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97901. */
  97902. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97903. /**
  97904. * Creates a new VRDeviceOrientationFreeCamera
  97905. * @param name defines camera name
  97906. * @param position defines the start position of the camera
  97907. * @param scene defines the scene the camera belongs to
  97908. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97909. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97910. */
  97911. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97912. /**
  97913. * Gets camera class name
  97914. * @returns VRDeviceOrientationFreeCamera
  97915. */
  97916. getClassName(): string;
  97917. }
  97918. }
  97919. declare module BABYLON {
  97920. /**
  97921. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97922. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97923. */
  97924. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97925. /**
  97926. * Creates a new VRDeviceOrientationGamepadCamera
  97927. * @param name defines camera name
  97928. * @param position defines the start position of the camera
  97929. * @param scene defines the scene the camera belongs to
  97930. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97931. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97932. */
  97933. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97934. /**
  97935. * Gets camera class name
  97936. * @returns VRDeviceOrientationGamepadCamera
  97937. */
  97938. getClassName(): string;
  97939. }
  97940. }
  97941. declare module BABYLON {
  97942. /**
  97943. * Defines supported buttons for XBox360 compatible gamepads
  97944. */
  97945. export enum Xbox360Button {
  97946. /** A */
  97947. A = 0,
  97948. /** B */
  97949. B = 1,
  97950. /** X */
  97951. X = 2,
  97952. /** Y */
  97953. Y = 3,
  97954. /** Start */
  97955. Start = 4,
  97956. /** Back */
  97957. Back = 5,
  97958. /** Left button */
  97959. LB = 6,
  97960. /** Right button */
  97961. RB = 7,
  97962. /** Left stick */
  97963. LeftStick = 8,
  97964. /** Right stick */
  97965. RightStick = 9
  97966. }
  97967. /** Defines values for XBox360 DPad */
  97968. export enum Xbox360Dpad {
  97969. /** Up */
  97970. Up = 0,
  97971. /** Down */
  97972. Down = 1,
  97973. /** Left */
  97974. Left = 2,
  97975. /** Right */
  97976. Right = 3
  97977. }
  97978. /**
  97979. * Defines a XBox360 gamepad
  97980. */
  97981. export class Xbox360Pad extends Gamepad {
  97982. private _leftTrigger;
  97983. private _rightTrigger;
  97984. private _onlefttriggerchanged;
  97985. private _onrighttriggerchanged;
  97986. private _onbuttondown;
  97987. private _onbuttonup;
  97988. private _ondpaddown;
  97989. private _ondpadup;
  97990. /** Observable raised when a button is pressed */
  97991. onButtonDownObservable: Observable<Xbox360Button>;
  97992. /** Observable raised when a button is released */
  97993. onButtonUpObservable: Observable<Xbox360Button>;
  97994. /** Observable raised when a pad is pressed */
  97995. onPadDownObservable: Observable<Xbox360Dpad>;
  97996. /** Observable raised when a pad is released */
  97997. onPadUpObservable: Observable<Xbox360Dpad>;
  97998. private _buttonA;
  97999. private _buttonB;
  98000. private _buttonX;
  98001. private _buttonY;
  98002. private _buttonBack;
  98003. private _buttonStart;
  98004. private _buttonLB;
  98005. private _buttonRB;
  98006. private _buttonLeftStick;
  98007. private _buttonRightStick;
  98008. private _dPadUp;
  98009. private _dPadDown;
  98010. private _dPadLeft;
  98011. private _dPadRight;
  98012. private _isXboxOnePad;
  98013. /**
  98014. * Creates a new XBox360 gamepad object
  98015. * @param id defines the id of this gamepad
  98016. * @param index defines its index
  98017. * @param gamepad defines the internal HTML gamepad object
  98018. * @param xboxOne defines if it is a XBox One gamepad
  98019. */
  98020. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98021. /**
  98022. * Defines the callback to call when left trigger is pressed
  98023. * @param callback defines the callback to use
  98024. */
  98025. onlefttriggerchanged(callback: (value: number) => void): void;
  98026. /**
  98027. * Defines the callback to call when right trigger is pressed
  98028. * @param callback defines the callback to use
  98029. */
  98030. onrighttriggerchanged(callback: (value: number) => void): void;
  98031. /**
  98032. * Gets the left trigger value
  98033. */
  98034. /**
  98035. * Sets the left trigger value
  98036. */
  98037. leftTrigger: number;
  98038. /**
  98039. * Gets the right trigger value
  98040. */
  98041. /**
  98042. * Sets the right trigger value
  98043. */
  98044. rightTrigger: number;
  98045. /**
  98046. * Defines the callback to call when a button is pressed
  98047. * @param callback defines the callback to use
  98048. */
  98049. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98050. /**
  98051. * Defines the callback to call when a button is released
  98052. * @param callback defines the callback to use
  98053. */
  98054. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98055. /**
  98056. * Defines the callback to call when a pad is pressed
  98057. * @param callback defines the callback to use
  98058. */
  98059. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98060. /**
  98061. * Defines the callback to call when a pad is released
  98062. * @param callback defines the callback to use
  98063. */
  98064. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98065. private _setButtonValue;
  98066. private _setDPadValue;
  98067. /**
  98068. * Gets the value of the `A` button
  98069. */
  98070. /**
  98071. * Sets the value of the `A` button
  98072. */
  98073. buttonA: number;
  98074. /**
  98075. * Gets the value of the `B` button
  98076. */
  98077. /**
  98078. * Sets the value of the `B` button
  98079. */
  98080. buttonB: number;
  98081. /**
  98082. * Gets the value of the `X` button
  98083. */
  98084. /**
  98085. * Sets the value of the `X` button
  98086. */
  98087. buttonX: number;
  98088. /**
  98089. * Gets the value of the `Y` button
  98090. */
  98091. /**
  98092. * Sets the value of the `Y` button
  98093. */
  98094. buttonY: number;
  98095. /**
  98096. * Gets the value of the `Start` button
  98097. */
  98098. /**
  98099. * Sets the value of the `Start` button
  98100. */
  98101. buttonStart: number;
  98102. /**
  98103. * Gets the value of the `Back` button
  98104. */
  98105. /**
  98106. * Sets the value of the `Back` button
  98107. */
  98108. buttonBack: number;
  98109. /**
  98110. * Gets the value of the `Left` button
  98111. */
  98112. /**
  98113. * Sets the value of the `Left` button
  98114. */
  98115. buttonLB: number;
  98116. /**
  98117. * Gets the value of the `Right` button
  98118. */
  98119. /**
  98120. * Sets the value of the `Right` button
  98121. */
  98122. buttonRB: number;
  98123. /**
  98124. * Gets the value of the Left joystick
  98125. */
  98126. /**
  98127. * Sets the value of the Left joystick
  98128. */
  98129. buttonLeftStick: number;
  98130. /**
  98131. * Gets the value of the Right joystick
  98132. */
  98133. /**
  98134. * Sets the value of the Right joystick
  98135. */
  98136. buttonRightStick: number;
  98137. /**
  98138. * Gets the value of D-pad up
  98139. */
  98140. /**
  98141. * Sets the value of D-pad up
  98142. */
  98143. dPadUp: number;
  98144. /**
  98145. * Gets the value of D-pad down
  98146. */
  98147. /**
  98148. * Sets the value of D-pad down
  98149. */
  98150. dPadDown: number;
  98151. /**
  98152. * Gets the value of D-pad left
  98153. */
  98154. /**
  98155. * Sets the value of D-pad left
  98156. */
  98157. dPadLeft: number;
  98158. /**
  98159. * Gets the value of D-pad right
  98160. */
  98161. /**
  98162. * Sets the value of D-pad right
  98163. */
  98164. dPadRight: number;
  98165. /**
  98166. * Force the gamepad to synchronize with device values
  98167. */
  98168. update(): void;
  98169. /**
  98170. * Disposes the gamepad
  98171. */
  98172. dispose(): void;
  98173. }
  98174. }
  98175. declare module BABYLON {
  98176. /**
  98177. * Base class of materials working in push mode in babylon JS
  98178. * @hidden
  98179. */
  98180. export class PushMaterial extends Material {
  98181. protected _activeEffect: Effect;
  98182. protected _normalMatrix: Matrix;
  98183. /**
  98184. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98185. * This means that the material can keep using a previous shader while a new one is being compiled.
  98186. * This is mostly used when shader parallel compilation is supported (true by default)
  98187. */
  98188. allowShaderHotSwapping: boolean;
  98189. constructor(name: string, scene: Scene);
  98190. getEffect(): Effect;
  98191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98192. /**
  98193. * Binds the given world matrix to the active effect
  98194. *
  98195. * @param world the matrix to bind
  98196. */
  98197. bindOnlyWorldMatrix(world: Matrix): void;
  98198. /**
  98199. * Binds the given normal matrix to the active effect
  98200. *
  98201. * @param normalMatrix the matrix to bind
  98202. */
  98203. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98204. bind(world: Matrix, mesh?: Mesh): void;
  98205. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98206. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98207. }
  98208. }
  98209. declare module BABYLON {
  98210. /**
  98211. * This groups all the flags used to control the materials channel.
  98212. */
  98213. export class MaterialFlags {
  98214. private static _DiffuseTextureEnabled;
  98215. /**
  98216. * Are diffuse textures enabled in the application.
  98217. */
  98218. static DiffuseTextureEnabled: boolean;
  98219. private static _AmbientTextureEnabled;
  98220. /**
  98221. * Are ambient textures enabled in the application.
  98222. */
  98223. static AmbientTextureEnabled: boolean;
  98224. private static _OpacityTextureEnabled;
  98225. /**
  98226. * Are opacity textures enabled in the application.
  98227. */
  98228. static OpacityTextureEnabled: boolean;
  98229. private static _ReflectionTextureEnabled;
  98230. /**
  98231. * Are reflection textures enabled in the application.
  98232. */
  98233. static ReflectionTextureEnabled: boolean;
  98234. private static _EmissiveTextureEnabled;
  98235. /**
  98236. * Are emissive textures enabled in the application.
  98237. */
  98238. static EmissiveTextureEnabled: boolean;
  98239. private static _SpecularTextureEnabled;
  98240. /**
  98241. * Are specular textures enabled in the application.
  98242. */
  98243. static SpecularTextureEnabled: boolean;
  98244. private static _BumpTextureEnabled;
  98245. /**
  98246. * Are bump textures enabled in the application.
  98247. */
  98248. static BumpTextureEnabled: boolean;
  98249. private static _LightmapTextureEnabled;
  98250. /**
  98251. * Are lightmap textures enabled in the application.
  98252. */
  98253. static LightmapTextureEnabled: boolean;
  98254. private static _RefractionTextureEnabled;
  98255. /**
  98256. * Are refraction textures enabled in the application.
  98257. */
  98258. static RefractionTextureEnabled: boolean;
  98259. private static _ColorGradingTextureEnabled;
  98260. /**
  98261. * Are color grading textures enabled in the application.
  98262. */
  98263. static ColorGradingTextureEnabled: boolean;
  98264. private static _FresnelEnabled;
  98265. /**
  98266. * Are fresnels enabled in the application.
  98267. */
  98268. static FresnelEnabled: boolean;
  98269. private static _ClearCoatTextureEnabled;
  98270. /**
  98271. * Are clear coat textures enabled in the application.
  98272. */
  98273. static ClearCoatTextureEnabled: boolean;
  98274. private static _ClearCoatBumpTextureEnabled;
  98275. /**
  98276. * Are clear coat bump textures enabled in the application.
  98277. */
  98278. static ClearCoatBumpTextureEnabled: boolean;
  98279. private static _ClearCoatTintTextureEnabled;
  98280. /**
  98281. * Are clear coat tint textures enabled in the application.
  98282. */
  98283. static ClearCoatTintTextureEnabled: boolean;
  98284. private static _SheenTextureEnabled;
  98285. /**
  98286. * Are sheen textures enabled in the application.
  98287. */
  98288. static SheenTextureEnabled: boolean;
  98289. private static _AnisotropicTextureEnabled;
  98290. /**
  98291. * Are anisotropic textures enabled in the application.
  98292. */
  98293. static AnisotropicTextureEnabled: boolean;
  98294. private static _ThicknessTextureEnabled;
  98295. /**
  98296. * Are thickness textures enabled in the application.
  98297. */
  98298. static ThicknessTextureEnabled: boolean;
  98299. }
  98300. }
  98301. declare module BABYLON {
  98302. /** @hidden */
  98303. export var defaultFragmentDeclaration: {
  98304. name: string;
  98305. shader: string;
  98306. };
  98307. }
  98308. declare module BABYLON {
  98309. /** @hidden */
  98310. export var defaultUboDeclaration: {
  98311. name: string;
  98312. shader: string;
  98313. };
  98314. }
  98315. declare module BABYLON {
  98316. /** @hidden */
  98317. export var lightFragmentDeclaration: {
  98318. name: string;
  98319. shader: string;
  98320. };
  98321. }
  98322. declare module BABYLON {
  98323. /** @hidden */
  98324. export var lightUboDeclaration: {
  98325. name: string;
  98326. shader: string;
  98327. };
  98328. }
  98329. declare module BABYLON {
  98330. /** @hidden */
  98331. export var lightsFragmentFunctions: {
  98332. name: string;
  98333. shader: string;
  98334. };
  98335. }
  98336. declare module BABYLON {
  98337. /** @hidden */
  98338. export var shadowsFragmentFunctions: {
  98339. name: string;
  98340. shader: string;
  98341. };
  98342. }
  98343. declare module BABYLON {
  98344. /** @hidden */
  98345. export var fresnelFunction: {
  98346. name: string;
  98347. shader: string;
  98348. };
  98349. }
  98350. declare module BABYLON {
  98351. /** @hidden */
  98352. export var reflectionFunction: {
  98353. name: string;
  98354. shader: string;
  98355. };
  98356. }
  98357. declare module BABYLON {
  98358. /** @hidden */
  98359. export var bumpFragmentFunctions: {
  98360. name: string;
  98361. shader: string;
  98362. };
  98363. }
  98364. declare module BABYLON {
  98365. /** @hidden */
  98366. export var logDepthDeclaration: {
  98367. name: string;
  98368. shader: string;
  98369. };
  98370. }
  98371. declare module BABYLON {
  98372. /** @hidden */
  98373. export var bumpFragment: {
  98374. name: string;
  98375. shader: string;
  98376. };
  98377. }
  98378. declare module BABYLON {
  98379. /** @hidden */
  98380. export var depthPrePass: {
  98381. name: string;
  98382. shader: string;
  98383. };
  98384. }
  98385. declare module BABYLON {
  98386. /** @hidden */
  98387. export var lightFragment: {
  98388. name: string;
  98389. shader: string;
  98390. };
  98391. }
  98392. declare module BABYLON {
  98393. /** @hidden */
  98394. export var logDepthFragment: {
  98395. name: string;
  98396. shader: string;
  98397. };
  98398. }
  98399. declare module BABYLON {
  98400. /** @hidden */
  98401. export var defaultPixelShader: {
  98402. name: string;
  98403. shader: string;
  98404. };
  98405. }
  98406. declare module BABYLON {
  98407. /** @hidden */
  98408. export var defaultVertexDeclaration: {
  98409. name: string;
  98410. shader: string;
  98411. };
  98412. }
  98413. declare module BABYLON {
  98414. /** @hidden */
  98415. export var bumpVertexDeclaration: {
  98416. name: string;
  98417. shader: string;
  98418. };
  98419. }
  98420. declare module BABYLON {
  98421. /** @hidden */
  98422. export var bumpVertex: {
  98423. name: string;
  98424. shader: string;
  98425. };
  98426. }
  98427. declare module BABYLON {
  98428. /** @hidden */
  98429. export var fogVertex: {
  98430. name: string;
  98431. shader: string;
  98432. };
  98433. }
  98434. declare module BABYLON {
  98435. /** @hidden */
  98436. export var shadowsVertex: {
  98437. name: string;
  98438. shader: string;
  98439. };
  98440. }
  98441. declare module BABYLON {
  98442. /** @hidden */
  98443. export var pointCloudVertex: {
  98444. name: string;
  98445. shader: string;
  98446. };
  98447. }
  98448. declare module BABYLON {
  98449. /** @hidden */
  98450. export var logDepthVertex: {
  98451. name: string;
  98452. shader: string;
  98453. };
  98454. }
  98455. declare module BABYLON {
  98456. /** @hidden */
  98457. export var defaultVertexShader: {
  98458. name: string;
  98459. shader: string;
  98460. };
  98461. }
  98462. declare module BABYLON {
  98463. /** @hidden */
  98464. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98465. MAINUV1: boolean;
  98466. MAINUV2: boolean;
  98467. DIFFUSE: boolean;
  98468. DIFFUSEDIRECTUV: number;
  98469. AMBIENT: boolean;
  98470. AMBIENTDIRECTUV: number;
  98471. OPACITY: boolean;
  98472. OPACITYDIRECTUV: number;
  98473. OPACITYRGB: boolean;
  98474. REFLECTION: boolean;
  98475. EMISSIVE: boolean;
  98476. EMISSIVEDIRECTUV: number;
  98477. SPECULAR: boolean;
  98478. SPECULARDIRECTUV: number;
  98479. BUMP: boolean;
  98480. BUMPDIRECTUV: number;
  98481. PARALLAX: boolean;
  98482. PARALLAXOCCLUSION: boolean;
  98483. SPECULAROVERALPHA: boolean;
  98484. CLIPPLANE: boolean;
  98485. CLIPPLANE2: boolean;
  98486. CLIPPLANE3: boolean;
  98487. CLIPPLANE4: boolean;
  98488. ALPHATEST: boolean;
  98489. DEPTHPREPASS: boolean;
  98490. ALPHAFROMDIFFUSE: boolean;
  98491. POINTSIZE: boolean;
  98492. FOG: boolean;
  98493. SPECULARTERM: boolean;
  98494. DIFFUSEFRESNEL: boolean;
  98495. OPACITYFRESNEL: boolean;
  98496. REFLECTIONFRESNEL: boolean;
  98497. REFRACTIONFRESNEL: boolean;
  98498. EMISSIVEFRESNEL: boolean;
  98499. FRESNEL: boolean;
  98500. NORMAL: boolean;
  98501. UV1: boolean;
  98502. UV2: boolean;
  98503. VERTEXCOLOR: boolean;
  98504. VERTEXALPHA: boolean;
  98505. NUM_BONE_INFLUENCERS: number;
  98506. BonesPerMesh: number;
  98507. BONETEXTURE: boolean;
  98508. INSTANCES: boolean;
  98509. GLOSSINESS: boolean;
  98510. ROUGHNESS: boolean;
  98511. EMISSIVEASILLUMINATION: boolean;
  98512. LINKEMISSIVEWITHDIFFUSE: boolean;
  98513. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98514. LIGHTMAP: boolean;
  98515. LIGHTMAPDIRECTUV: number;
  98516. OBJECTSPACE_NORMALMAP: boolean;
  98517. USELIGHTMAPASSHADOWMAP: boolean;
  98518. REFLECTIONMAP_3D: boolean;
  98519. REFLECTIONMAP_SPHERICAL: boolean;
  98520. REFLECTIONMAP_PLANAR: boolean;
  98521. REFLECTIONMAP_CUBIC: boolean;
  98522. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98523. REFLECTIONMAP_PROJECTION: boolean;
  98524. REFLECTIONMAP_SKYBOX: boolean;
  98525. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98526. REFLECTIONMAP_EXPLICIT: boolean;
  98527. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98528. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98529. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98530. INVERTCUBICMAP: boolean;
  98531. LOGARITHMICDEPTH: boolean;
  98532. REFRACTION: boolean;
  98533. REFRACTIONMAP_3D: boolean;
  98534. REFLECTIONOVERALPHA: boolean;
  98535. TWOSIDEDLIGHTING: boolean;
  98536. SHADOWFLOAT: boolean;
  98537. MORPHTARGETS: boolean;
  98538. MORPHTARGETS_NORMAL: boolean;
  98539. MORPHTARGETS_TANGENT: boolean;
  98540. NUM_MORPH_INFLUENCERS: number;
  98541. NONUNIFORMSCALING: boolean;
  98542. PREMULTIPLYALPHA: boolean;
  98543. IMAGEPROCESSING: boolean;
  98544. VIGNETTE: boolean;
  98545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98546. VIGNETTEBLENDMODEOPAQUE: boolean;
  98547. TONEMAPPING: boolean;
  98548. TONEMAPPING_ACES: boolean;
  98549. CONTRAST: boolean;
  98550. COLORCURVES: boolean;
  98551. COLORGRADING: boolean;
  98552. COLORGRADING3D: boolean;
  98553. SAMPLER3DGREENDEPTH: boolean;
  98554. SAMPLER3DBGRMAP: boolean;
  98555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98556. MULTIVIEW: boolean;
  98557. /**
  98558. * If the reflection texture on this material is in linear color space
  98559. * @hidden
  98560. */
  98561. IS_REFLECTION_LINEAR: boolean;
  98562. /**
  98563. * If the refraction texture on this material is in linear color space
  98564. * @hidden
  98565. */
  98566. IS_REFRACTION_LINEAR: boolean;
  98567. EXPOSURE: boolean;
  98568. constructor();
  98569. setReflectionMode(modeToEnable: string): void;
  98570. }
  98571. /**
  98572. * This is the default material used in Babylon. It is the best trade off between quality
  98573. * and performances.
  98574. * @see http://doc.babylonjs.com/babylon101/materials
  98575. */
  98576. export class StandardMaterial extends PushMaterial {
  98577. private _diffuseTexture;
  98578. /**
  98579. * The basic texture of the material as viewed under a light.
  98580. */
  98581. diffuseTexture: Nullable<BaseTexture>;
  98582. private _ambientTexture;
  98583. /**
  98584. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98585. */
  98586. ambientTexture: Nullable<BaseTexture>;
  98587. private _opacityTexture;
  98588. /**
  98589. * Define the transparency of the material from a texture.
  98590. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98591. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98592. */
  98593. opacityTexture: Nullable<BaseTexture>;
  98594. private _reflectionTexture;
  98595. /**
  98596. * Define the texture used to display the reflection.
  98597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98598. */
  98599. reflectionTexture: Nullable<BaseTexture>;
  98600. private _emissiveTexture;
  98601. /**
  98602. * Define texture of the material as if self lit.
  98603. * This will be mixed in the final result even in the absence of light.
  98604. */
  98605. emissiveTexture: Nullable<BaseTexture>;
  98606. private _specularTexture;
  98607. /**
  98608. * Define how the color and intensity of the highlight given by the light in the material.
  98609. */
  98610. specularTexture: Nullable<BaseTexture>;
  98611. private _bumpTexture;
  98612. /**
  98613. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98614. * 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.
  98615. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98616. */
  98617. bumpTexture: Nullable<BaseTexture>;
  98618. private _lightmapTexture;
  98619. /**
  98620. * Complex lighting can be computationally expensive to compute at runtime.
  98621. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98622. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98623. */
  98624. lightmapTexture: Nullable<BaseTexture>;
  98625. private _refractionTexture;
  98626. /**
  98627. * Define the texture used to display the refraction.
  98628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98629. */
  98630. refractionTexture: Nullable<BaseTexture>;
  98631. /**
  98632. * The color of the material lit by the environmental background lighting.
  98633. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98634. */
  98635. ambientColor: Color3;
  98636. /**
  98637. * The basic color of the material as viewed under a light.
  98638. */
  98639. diffuseColor: Color3;
  98640. /**
  98641. * Define how the color and intensity of the highlight given by the light in the material.
  98642. */
  98643. specularColor: Color3;
  98644. /**
  98645. * Define the color of the material as if self lit.
  98646. * This will be mixed in the final result even in the absence of light.
  98647. */
  98648. emissiveColor: Color3;
  98649. /**
  98650. * Defines how sharp are the highlights in the material.
  98651. * The bigger the value the sharper giving a more glossy feeling to the result.
  98652. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98653. */
  98654. specularPower: number;
  98655. private _useAlphaFromDiffuseTexture;
  98656. /**
  98657. * Does the transparency come from the diffuse texture alpha channel.
  98658. */
  98659. useAlphaFromDiffuseTexture: boolean;
  98660. private _useEmissiveAsIllumination;
  98661. /**
  98662. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98663. */
  98664. useEmissiveAsIllumination: boolean;
  98665. private _linkEmissiveWithDiffuse;
  98666. /**
  98667. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98668. * the emissive level when the final color is close to one.
  98669. */
  98670. linkEmissiveWithDiffuse: boolean;
  98671. private _useSpecularOverAlpha;
  98672. /**
  98673. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98674. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98675. */
  98676. useSpecularOverAlpha: boolean;
  98677. private _useReflectionOverAlpha;
  98678. /**
  98679. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98680. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98681. */
  98682. useReflectionOverAlpha: boolean;
  98683. private _disableLighting;
  98684. /**
  98685. * Does lights from the scene impacts this material.
  98686. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98687. */
  98688. disableLighting: boolean;
  98689. private _useObjectSpaceNormalMap;
  98690. /**
  98691. * Allows using an object space normal map (instead of tangent space).
  98692. */
  98693. useObjectSpaceNormalMap: boolean;
  98694. private _useParallax;
  98695. /**
  98696. * Is parallax enabled or not.
  98697. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98698. */
  98699. useParallax: boolean;
  98700. private _useParallaxOcclusion;
  98701. /**
  98702. * Is parallax occlusion enabled or not.
  98703. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98704. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98705. */
  98706. useParallaxOcclusion: boolean;
  98707. /**
  98708. * 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.
  98709. */
  98710. parallaxScaleBias: number;
  98711. private _roughness;
  98712. /**
  98713. * Helps to define how blurry the reflections should appears in the material.
  98714. */
  98715. roughness: number;
  98716. /**
  98717. * In case of refraction, define the value of the indice of refraction.
  98718. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98719. */
  98720. indexOfRefraction: number;
  98721. /**
  98722. * Invert the refraction texture alongside the y axis.
  98723. * It can be useful with procedural textures or probe for instance.
  98724. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98725. */
  98726. invertRefractionY: boolean;
  98727. /**
  98728. * Defines the alpha limits in alpha test mode.
  98729. */
  98730. alphaCutOff: number;
  98731. private _useLightmapAsShadowmap;
  98732. /**
  98733. * In case of light mapping, define whether the map contains light or shadow informations.
  98734. */
  98735. useLightmapAsShadowmap: boolean;
  98736. private _diffuseFresnelParameters;
  98737. /**
  98738. * Define the diffuse fresnel parameters of the material.
  98739. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98740. */
  98741. diffuseFresnelParameters: FresnelParameters;
  98742. private _opacityFresnelParameters;
  98743. /**
  98744. * Define the opacity fresnel parameters of the material.
  98745. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98746. */
  98747. opacityFresnelParameters: FresnelParameters;
  98748. private _reflectionFresnelParameters;
  98749. /**
  98750. * Define the reflection fresnel parameters of the material.
  98751. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98752. */
  98753. reflectionFresnelParameters: FresnelParameters;
  98754. private _refractionFresnelParameters;
  98755. /**
  98756. * Define the refraction fresnel parameters of the material.
  98757. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98758. */
  98759. refractionFresnelParameters: FresnelParameters;
  98760. private _emissiveFresnelParameters;
  98761. /**
  98762. * Define the emissive fresnel parameters of the material.
  98763. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98764. */
  98765. emissiveFresnelParameters: FresnelParameters;
  98766. private _useReflectionFresnelFromSpecular;
  98767. /**
  98768. * If true automatically deducts the fresnels values from the material specularity.
  98769. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98770. */
  98771. useReflectionFresnelFromSpecular: boolean;
  98772. private _useGlossinessFromSpecularMapAlpha;
  98773. /**
  98774. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98775. */
  98776. useGlossinessFromSpecularMapAlpha: boolean;
  98777. private _maxSimultaneousLights;
  98778. /**
  98779. * Defines the maximum number of lights that can be used in the material
  98780. */
  98781. maxSimultaneousLights: number;
  98782. private _invertNormalMapX;
  98783. /**
  98784. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98785. */
  98786. invertNormalMapX: boolean;
  98787. private _invertNormalMapY;
  98788. /**
  98789. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98790. */
  98791. invertNormalMapY: boolean;
  98792. private _twoSidedLighting;
  98793. /**
  98794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98795. */
  98796. twoSidedLighting: boolean;
  98797. /**
  98798. * Default configuration related to image processing available in the standard Material.
  98799. */
  98800. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98801. /**
  98802. * Gets the image processing configuration used either in this material.
  98803. */
  98804. /**
  98805. * Sets the Default image processing configuration used either in the this material.
  98806. *
  98807. * If sets to null, the scene one is in use.
  98808. */
  98809. imageProcessingConfiguration: ImageProcessingConfiguration;
  98810. /**
  98811. * Keep track of the image processing observer to allow dispose and replace.
  98812. */
  98813. private _imageProcessingObserver;
  98814. /**
  98815. * Attaches a new image processing configuration to the Standard Material.
  98816. * @param configuration
  98817. */
  98818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98819. /**
  98820. * Gets wether the color curves effect is enabled.
  98821. */
  98822. /**
  98823. * Sets wether the color curves effect is enabled.
  98824. */
  98825. cameraColorCurvesEnabled: boolean;
  98826. /**
  98827. * Gets wether the color grading effect is enabled.
  98828. */
  98829. /**
  98830. * Gets wether the color grading effect is enabled.
  98831. */
  98832. cameraColorGradingEnabled: boolean;
  98833. /**
  98834. * Gets wether tonemapping is enabled or not.
  98835. */
  98836. /**
  98837. * Sets wether tonemapping is enabled or not
  98838. */
  98839. cameraToneMappingEnabled: boolean;
  98840. /**
  98841. * The camera exposure used on this material.
  98842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98843. * This corresponds to a photographic exposure.
  98844. */
  98845. /**
  98846. * The camera exposure used on this material.
  98847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98848. * This corresponds to a photographic exposure.
  98849. */
  98850. cameraExposure: number;
  98851. /**
  98852. * Gets The camera contrast used on this material.
  98853. */
  98854. /**
  98855. * Sets The camera contrast used on this material.
  98856. */
  98857. cameraContrast: number;
  98858. /**
  98859. * Gets the Color Grading 2D Lookup Texture.
  98860. */
  98861. /**
  98862. * Sets the Color Grading 2D Lookup Texture.
  98863. */
  98864. cameraColorGradingTexture: Nullable<BaseTexture>;
  98865. /**
  98866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98868. * 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;
  98869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98870. */
  98871. /**
  98872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98874. * 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;
  98875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98876. */
  98877. cameraColorCurves: Nullable<ColorCurves>;
  98878. /**
  98879. * Custom callback helping to override the default shader used in the material.
  98880. */
  98881. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98882. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98883. protected _worldViewProjectionMatrix: Matrix;
  98884. protected _globalAmbientColor: Color3;
  98885. protected _useLogarithmicDepth: boolean;
  98886. /**
  98887. * Instantiates a new standard material.
  98888. * This is the default material used in Babylon. It is the best trade off between quality
  98889. * and performances.
  98890. * @see http://doc.babylonjs.com/babylon101/materials
  98891. * @param name Define the name of the material in the scene
  98892. * @param scene Define the scene the material belong to
  98893. */
  98894. constructor(name: string, scene: Scene);
  98895. /**
  98896. * Gets a boolean indicating that current material needs to register RTT
  98897. */
  98898. readonly hasRenderTargetTextures: boolean;
  98899. /**
  98900. * Gets the current class name of the material e.g. "StandardMaterial"
  98901. * Mainly use in serialization.
  98902. * @returns the class name
  98903. */
  98904. getClassName(): string;
  98905. /**
  98906. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98907. * You can try switching to logarithmic depth.
  98908. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98909. */
  98910. useLogarithmicDepth: boolean;
  98911. /**
  98912. * Specifies if the material will require alpha blending
  98913. * @returns a boolean specifying if alpha blending is needed
  98914. */
  98915. needAlphaBlending(): boolean;
  98916. /**
  98917. * Specifies if this material should be rendered in alpha test mode
  98918. * @returns a boolean specifying if an alpha test is needed.
  98919. */
  98920. needAlphaTesting(): boolean;
  98921. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98922. /**
  98923. * Get the texture used for alpha test purpose.
  98924. * @returns the diffuse texture in case of the standard material.
  98925. */
  98926. getAlphaTestTexture(): Nullable<BaseTexture>;
  98927. /**
  98928. * Get if the submesh is ready to be used and all its information available.
  98929. * Child classes can use it to update shaders
  98930. * @param mesh defines the mesh to check
  98931. * @param subMesh defines which submesh to check
  98932. * @param useInstances specifies that instances should be used
  98933. * @returns a boolean indicating that the submesh is ready or not
  98934. */
  98935. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98936. /**
  98937. * Builds the material UBO layouts.
  98938. * Used internally during the effect preparation.
  98939. */
  98940. buildUniformLayout(): void;
  98941. /**
  98942. * Unbinds the material from the mesh
  98943. */
  98944. unbind(): void;
  98945. /**
  98946. * Binds the submesh to this material by preparing the effect and shader to draw
  98947. * @param world defines the world transformation matrix
  98948. * @param mesh defines the mesh containing the submesh
  98949. * @param subMesh defines the submesh to bind the material to
  98950. */
  98951. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98952. /**
  98953. * Get the list of animatables in the material.
  98954. * @returns the list of animatables object used in the material
  98955. */
  98956. getAnimatables(): IAnimatable[];
  98957. /**
  98958. * Gets the active textures from the material
  98959. * @returns an array of textures
  98960. */
  98961. getActiveTextures(): BaseTexture[];
  98962. /**
  98963. * Specifies if the material uses a texture
  98964. * @param texture defines the texture to check against the material
  98965. * @returns a boolean specifying if the material uses the texture
  98966. */
  98967. hasTexture(texture: BaseTexture): boolean;
  98968. /**
  98969. * Disposes the material
  98970. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98971. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98972. */
  98973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98974. /**
  98975. * Makes a duplicate of the material, and gives it a new name
  98976. * @param name defines the new name for the duplicated material
  98977. * @returns the cloned material
  98978. */
  98979. clone(name: string): StandardMaterial;
  98980. /**
  98981. * Serializes this material in a JSON representation
  98982. * @returns the serialized material object
  98983. */
  98984. serialize(): any;
  98985. /**
  98986. * Creates a standard material from parsed material data
  98987. * @param source defines the JSON representation of the material
  98988. * @param scene defines the hosting scene
  98989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98990. * @returns a new standard material
  98991. */
  98992. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98993. /**
  98994. * Are diffuse textures enabled in the application.
  98995. */
  98996. static DiffuseTextureEnabled: boolean;
  98997. /**
  98998. * Are ambient textures enabled in the application.
  98999. */
  99000. static AmbientTextureEnabled: boolean;
  99001. /**
  99002. * Are opacity textures enabled in the application.
  99003. */
  99004. static OpacityTextureEnabled: boolean;
  99005. /**
  99006. * Are reflection textures enabled in the application.
  99007. */
  99008. static ReflectionTextureEnabled: boolean;
  99009. /**
  99010. * Are emissive textures enabled in the application.
  99011. */
  99012. static EmissiveTextureEnabled: boolean;
  99013. /**
  99014. * Are specular textures enabled in the application.
  99015. */
  99016. static SpecularTextureEnabled: boolean;
  99017. /**
  99018. * Are bump textures enabled in the application.
  99019. */
  99020. static BumpTextureEnabled: boolean;
  99021. /**
  99022. * Are lightmap textures enabled in the application.
  99023. */
  99024. static LightmapTextureEnabled: boolean;
  99025. /**
  99026. * Are refraction textures enabled in the application.
  99027. */
  99028. static RefractionTextureEnabled: boolean;
  99029. /**
  99030. * Are color grading textures enabled in the application.
  99031. */
  99032. static ColorGradingTextureEnabled: boolean;
  99033. /**
  99034. * Are fresnels enabled in the application.
  99035. */
  99036. static FresnelEnabled: boolean;
  99037. }
  99038. }
  99039. declare module BABYLON {
  99040. /**
  99041. * A class extending Texture allowing drawing on a texture
  99042. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99043. */
  99044. export class DynamicTexture extends Texture {
  99045. private _generateMipMaps;
  99046. private _canvas;
  99047. private _context;
  99048. private _engine;
  99049. /**
  99050. * Creates a DynamicTexture
  99051. * @param name defines the name of the texture
  99052. * @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
  99053. * @param scene defines the scene where you want the texture
  99054. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99055. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99056. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99057. */
  99058. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99059. /**
  99060. * Get the current class name of the texture useful for serialization or dynamic coding.
  99061. * @returns "DynamicTexture"
  99062. */
  99063. getClassName(): string;
  99064. /**
  99065. * Gets the current state of canRescale
  99066. */
  99067. readonly canRescale: boolean;
  99068. private _recreate;
  99069. /**
  99070. * Scales the texture
  99071. * @param ratio the scale factor to apply to both width and height
  99072. */
  99073. scale(ratio: number): void;
  99074. /**
  99075. * Resizes the texture
  99076. * @param width the new width
  99077. * @param height the new height
  99078. */
  99079. scaleTo(width: number, height: number): void;
  99080. /**
  99081. * Gets the context of the canvas used by the texture
  99082. * @returns the canvas context of the dynamic texture
  99083. */
  99084. getContext(): CanvasRenderingContext2D;
  99085. /**
  99086. * Clears the texture
  99087. */
  99088. clear(): void;
  99089. /**
  99090. * Updates the texture
  99091. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99092. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99093. */
  99094. update(invertY?: boolean, premulAlpha?: boolean): void;
  99095. /**
  99096. * Draws text onto the texture
  99097. * @param text defines the text to be drawn
  99098. * @param x defines the placement of the text from the left
  99099. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99100. * @param font defines the font to be used with font-style, font-size, font-name
  99101. * @param color defines the color used for the text
  99102. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99103. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99104. * @param update defines whether texture is immediately update (default is true)
  99105. */
  99106. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99107. /**
  99108. * Clones the texture
  99109. * @returns the clone of the texture.
  99110. */
  99111. clone(): DynamicTexture;
  99112. /**
  99113. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99114. * @returns a serialized dynamic texture object
  99115. */
  99116. serialize(): any;
  99117. /** @hidden */
  99118. _rebuild(): void;
  99119. }
  99120. }
  99121. declare module BABYLON {
  99122. /** @hidden */
  99123. export var imageProcessingPixelShader: {
  99124. name: string;
  99125. shader: string;
  99126. };
  99127. }
  99128. declare module BABYLON {
  99129. /**
  99130. * ImageProcessingPostProcess
  99131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99132. */
  99133. export class ImageProcessingPostProcess extends PostProcess {
  99134. /**
  99135. * Default configuration related to image processing available in the PBR Material.
  99136. */
  99137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99138. /**
  99139. * Gets the image processing configuration used either in this material.
  99140. */
  99141. /**
  99142. * Sets the Default image processing configuration used either in the this material.
  99143. *
  99144. * If sets to null, the scene one is in use.
  99145. */
  99146. imageProcessingConfiguration: ImageProcessingConfiguration;
  99147. /**
  99148. * Keep track of the image processing observer to allow dispose and replace.
  99149. */
  99150. private _imageProcessingObserver;
  99151. /**
  99152. * Attaches a new image processing configuration to the PBR Material.
  99153. * @param configuration
  99154. */
  99155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99156. /**
  99157. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99158. */
  99159. /**
  99160. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99161. */
  99162. colorCurves: Nullable<ColorCurves>;
  99163. /**
  99164. * Gets wether the color curves effect is enabled.
  99165. */
  99166. /**
  99167. * Sets wether the color curves effect is enabled.
  99168. */
  99169. colorCurvesEnabled: boolean;
  99170. /**
  99171. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99172. */
  99173. /**
  99174. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99175. */
  99176. colorGradingTexture: Nullable<BaseTexture>;
  99177. /**
  99178. * Gets wether the color grading effect is enabled.
  99179. */
  99180. /**
  99181. * Gets wether the color grading effect is enabled.
  99182. */
  99183. colorGradingEnabled: boolean;
  99184. /**
  99185. * Gets exposure used in the effect.
  99186. */
  99187. /**
  99188. * Sets exposure used in the effect.
  99189. */
  99190. exposure: number;
  99191. /**
  99192. * Gets wether tonemapping is enabled or not.
  99193. */
  99194. /**
  99195. * Sets wether tonemapping is enabled or not
  99196. */
  99197. toneMappingEnabled: boolean;
  99198. /**
  99199. * Gets the type of tone mapping effect.
  99200. */
  99201. /**
  99202. * Sets the type of tone mapping effect.
  99203. */
  99204. toneMappingType: number;
  99205. /**
  99206. * Gets contrast used in the effect.
  99207. */
  99208. /**
  99209. * Sets contrast used in the effect.
  99210. */
  99211. contrast: number;
  99212. /**
  99213. * Gets Vignette stretch size.
  99214. */
  99215. /**
  99216. * Sets Vignette stretch size.
  99217. */
  99218. vignetteStretch: number;
  99219. /**
  99220. * Gets Vignette centre X Offset.
  99221. */
  99222. /**
  99223. * Sets Vignette centre X Offset.
  99224. */
  99225. vignetteCentreX: number;
  99226. /**
  99227. * Gets Vignette centre Y Offset.
  99228. */
  99229. /**
  99230. * Sets Vignette centre Y Offset.
  99231. */
  99232. vignetteCentreY: number;
  99233. /**
  99234. * Gets Vignette weight or intensity of the vignette effect.
  99235. */
  99236. /**
  99237. * Sets Vignette weight or intensity of the vignette effect.
  99238. */
  99239. vignetteWeight: number;
  99240. /**
  99241. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99242. * if vignetteEnabled is set to true.
  99243. */
  99244. /**
  99245. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99246. * if vignetteEnabled is set to true.
  99247. */
  99248. vignetteColor: Color4;
  99249. /**
  99250. * Gets Camera field of view used by the Vignette effect.
  99251. */
  99252. /**
  99253. * Sets Camera field of view used by the Vignette effect.
  99254. */
  99255. vignetteCameraFov: number;
  99256. /**
  99257. * Gets the vignette blend mode allowing different kind of effect.
  99258. */
  99259. /**
  99260. * Sets the vignette blend mode allowing different kind of effect.
  99261. */
  99262. vignetteBlendMode: number;
  99263. /**
  99264. * Gets wether the vignette effect is enabled.
  99265. */
  99266. /**
  99267. * Sets wether the vignette effect is enabled.
  99268. */
  99269. vignetteEnabled: boolean;
  99270. private _fromLinearSpace;
  99271. /**
  99272. * Gets wether the input of the processing is in Gamma or Linear Space.
  99273. */
  99274. /**
  99275. * Sets wether the input of the processing is in Gamma or Linear Space.
  99276. */
  99277. fromLinearSpace: boolean;
  99278. /**
  99279. * Defines cache preventing GC.
  99280. */
  99281. private _defines;
  99282. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99283. /**
  99284. * "ImageProcessingPostProcess"
  99285. * @returns "ImageProcessingPostProcess"
  99286. */
  99287. getClassName(): string;
  99288. protected _updateParameters(): void;
  99289. dispose(camera?: Camera): void;
  99290. }
  99291. }
  99292. declare module BABYLON {
  99293. /**
  99294. * Class containing static functions to help procedurally build meshes
  99295. */
  99296. export class GroundBuilder {
  99297. /**
  99298. * Creates a ground mesh
  99299. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99300. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99302. * @param name defines the name of the mesh
  99303. * @param options defines the options used to create the mesh
  99304. * @param scene defines the hosting scene
  99305. * @returns the ground mesh
  99306. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99307. */
  99308. static CreateGround(name: string, options: {
  99309. width?: number;
  99310. height?: number;
  99311. subdivisions?: number;
  99312. subdivisionsX?: number;
  99313. subdivisionsY?: number;
  99314. updatable?: boolean;
  99315. }, scene: any): Mesh;
  99316. /**
  99317. * Creates a tiled ground mesh
  99318. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99319. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99320. * * 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
  99321. * * 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
  99322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99323. * @param name defines the name of the mesh
  99324. * @param options defines the options used to create the mesh
  99325. * @param scene defines the hosting scene
  99326. * @returns the tiled ground mesh
  99327. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99328. */
  99329. static CreateTiledGround(name: string, options: {
  99330. xmin: number;
  99331. zmin: number;
  99332. xmax: number;
  99333. zmax: number;
  99334. subdivisions?: {
  99335. w: number;
  99336. h: number;
  99337. };
  99338. precision?: {
  99339. w: number;
  99340. h: number;
  99341. };
  99342. updatable?: boolean;
  99343. }, scene?: Nullable<Scene>): Mesh;
  99344. /**
  99345. * Creates a ground mesh from a height map
  99346. * * The parameter `url` sets the URL of the height map image resource.
  99347. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99348. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99349. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99350. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99351. * * 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.
  99352. * * 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).
  99353. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99355. * @param name defines the name of the mesh
  99356. * @param url defines the url to the height map
  99357. * @param options defines the options used to create the mesh
  99358. * @param scene defines the hosting scene
  99359. * @returns the ground mesh
  99360. * @see https://doc.babylonjs.com/babylon101/height_map
  99361. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99362. */
  99363. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99364. width?: number;
  99365. height?: number;
  99366. subdivisions?: number;
  99367. minHeight?: number;
  99368. maxHeight?: number;
  99369. colorFilter?: Color3;
  99370. alphaFilter?: number;
  99371. updatable?: boolean;
  99372. onReady?: (mesh: GroundMesh) => void;
  99373. }, scene?: Nullable<Scene>): GroundMesh;
  99374. }
  99375. }
  99376. declare module BABYLON {
  99377. /**
  99378. * Class containing static functions to help procedurally build meshes
  99379. */
  99380. export class TorusBuilder {
  99381. /**
  99382. * Creates a torus mesh
  99383. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99384. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99385. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99389. * @param name defines the name of the mesh
  99390. * @param options defines the options used to create the mesh
  99391. * @param scene defines the hosting scene
  99392. * @returns the torus mesh
  99393. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99394. */
  99395. static CreateTorus(name: string, options: {
  99396. diameter?: number;
  99397. thickness?: number;
  99398. tessellation?: number;
  99399. updatable?: boolean;
  99400. sideOrientation?: number;
  99401. frontUVs?: Vector4;
  99402. backUVs?: Vector4;
  99403. }, scene: any): Mesh;
  99404. }
  99405. }
  99406. declare module BABYLON {
  99407. /**
  99408. * Class containing static functions to help procedurally build meshes
  99409. */
  99410. export class CylinderBuilder {
  99411. /**
  99412. * Creates a cylinder or a cone mesh
  99413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99415. * * 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.
  99416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99420. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99421. * * 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).
  99422. * * 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
  99423. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99424. * * 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
  99425. * * 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.
  99426. * * If `enclose` is false, a ring surface is one element.
  99427. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99428. * * 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
  99429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99432. * @param name defines the name of the mesh
  99433. * @param options defines the options used to create the mesh
  99434. * @param scene defines the hosting scene
  99435. * @returns the cylinder mesh
  99436. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99437. */
  99438. static CreateCylinder(name: string, options: {
  99439. height?: number;
  99440. diameterTop?: number;
  99441. diameterBottom?: number;
  99442. diameter?: number;
  99443. tessellation?: number;
  99444. subdivisions?: number;
  99445. arc?: number;
  99446. faceColors?: Color4[];
  99447. faceUV?: Vector4[];
  99448. updatable?: boolean;
  99449. hasRings?: boolean;
  99450. enclose?: boolean;
  99451. sideOrientation?: number;
  99452. frontUVs?: Vector4;
  99453. backUVs?: Vector4;
  99454. }, scene: any): Mesh;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Manager for handling gamepads
  99460. */
  99461. export class GamepadManager {
  99462. private _scene?;
  99463. private _babylonGamepads;
  99464. private _oneGamepadConnected;
  99465. /** @hidden */
  99466. _isMonitoring: boolean;
  99467. private _gamepadEventSupported;
  99468. private _gamepadSupport;
  99469. /**
  99470. * observable to be triggered when the gamepad controller has been connected
  99471. */
  99472. onGamepadConnectedObservable: Observable<Gamepad>;
  99473. /**
  99474. * observable to be triggered when the gamepad controller has been disconnected
  99475. */
  99476. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99477. private _onGamepadConnectedEvent;
  99478. private _onGamepadDisconnectedEvent;
  99479. /**
  99480. * Initializes the gamepad manager
  99481. * @param _scene BabylonJS scene
  99482. */
  99483. constructor(_scene?: Scene | undefined);
  99484. /**
  99485. * The gamepads in the game pad manager
  99486. */
  99487. readonly gamepads: Gamepad[];
  99488. /**
  99489. * Get the gamepad controllers based on type
  99490. * @param type The type of gamepad controller
  99491. * @returns Nullable gamepad
  99492. */
  99493. getGamepadByType(type?: number): Nullable<Gamepad>;
  99494. /**
  99495. * Disposes the gamepad manager
  99496. */
  99497. dispose(): void;
  99498. private _addNewGamepad;
  99499. private _startMonitoringGamepads;
  99500. private _stopMonitoringGamepads;
  99501. /** @hidden */
  99502. _checkGamepadsStatus(): void;
  99503. private _updateGamepadObjects;
  99504. }
  99505. }
  99506. declare module BABYLON {
  99507. interface Scene {
  99508. /** @hidden */
  99509. _gamepadManager: Nullable<GamepadManager>;
  99510. /**
  99511. * Gets the gamepad manager associated with the scene
  99512. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99513. */
  99514. gamepadManager: GamepadManager;
  99515. }
  99516. /**
  99517. * Interface representing a free camera inputs manager
  99518. */
  99519. interface FreeCameraInputsManager {
  99520. /**
  99521. * Adds gamepad input support to the FreeCameraInputsManager.
  99522. * @returns the FreeCameraInputsManager
  99523. */
  99524. addGamepad(): FreeCameraInputsManager;
  99525. }
  99526. /**
  99527. * Interface representing an arc rotate camera inputs manager
  99528. */
  99529. interface ArcRotateCameraInputsManager {
  99530. /**
  99531. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99532. * @returns the camera inputs manager
  99533. */
  99534. addGamepad(): ArcRotateCameraInputsManager;
  99535. }
  99536. /**
  99537. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99538. */
  99539. export class GamepadSystemSceneComponent implements ISceneComponent {
  99540. /**
  99541. * The component name helpfull to identify the component in the list of scene components.
  99542. */
  99543. readonly name: string;
  99544. /**
  99545. * The scene the component belongs to.
  99546. */
  99547. scene: Scene;
  99548. /**
  99549. * Creates a new instance of the component for the given scene
  99550. * @param scene Defines the scene to register the component in
  99551. */
  99552. constructor(scene: Scene);
  99553. /**
  99554. * Registers the component in a given scene
  99555. */
  99556. register(): void;
  99557. /**
  99558. * Rebuilds the elements related to this component in case of
  99559. * context lost for instance.
  99560. */
  99561. rebuild(): void;
  99562. /**
  99563. * Disposes the component and the associated ressources
  99564. */
  99565. dispose(): void;
  99566. private _beforeCameraUpdate;
  99567. }
  99568. }
  99569. declare module BABYLON {
  99570. /**
  99571. * Options to modify the vr teleportation behavior.
  99572. */
  99573. export interface VRTeleportationOptions {
  99574. /**
  99575. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99576. */
  99577. floorMeshName?: string;
  99578. /**
  99579. * A list of meshes to be used as the teleportation floor. (default: empty)
  99580. */
  99581. floorMeshes?: Mesh[];
  99582. }
  99583. /**
  99584. * Options to modify the vr experience helper's behavior.
  99585. */
  99586. export interface VRExperienceHelperOptions extends WebVROptions {
  99587. /**
  99588. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99589. */
  99590. createDeviceOrientationCamera?: boolean;
  99591. /**
  99592. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99593. */
  99594. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99595. /**
  99596. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99597. */
  99598. laserToggle?: boolean;
  99599. /**
  99600. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99601. */
  99602. floorMeshes?: Mesh[];
  99603. /**
  99604. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99605. */
  99606. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99607. }
  99608. /**
  99609. * Event containing information after VR has been entered
  99610. */
  99611. export class OnAfterEnteringVRObservableEvent {
  99612. /**
  99613. * If entering vr was successful
  99614. */
  99615. success: boolean;
  99616. }
  99617. /**
  99618. * Helps to quickly add VR support to an existing scene.
  99619. * See http://doc.babylonjs.com/how_to/webvr_helper
  99620. */
  99621. export class VRExperienceHelper {
  99622. /** Options to modify the vr experience helper's behavior. */
  99623. webVROptions: VRExperienceHelperOptions;
  99624. private _scene;
  99625. private _position;
  99626. private _btnVR;
  99627. private _btnVRDisplayed;
  99628. private _webVRsupported;
  99629. private _webVRready;
  99630. private _webVRrequesting;
  99631. private _webVRpresenting;
  99632. private _hasEnteredVR;
  99633. private _fullscreenVRpresenting;
  99634. private _canvas;
  99635. private _webVRCamera;
  99636. private _vrDeviceOrientationCamera;
  99637. private _deviceOrientationCamera;
  99638. private _existingCamera;
  99639. private _onKeyDown;
  99640. private _onVrDisplayPresentChange;
  99641. private _onVRDisplayChanged;
  99642. private _onVRRequestPresentStart;
  99643. private _onVRRequestPresentComplete;
  99644. /**
  99645. * Observable raised right before entering VR.
  99646. */
  99647. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99648. /**
  99649. * Observable raised when entering VR has completed.
  99650. */
  99651. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99652. /**
  99653. * Observable raised when exiting VR.
  99654. */
  99655. onExitingVRObservable: Observable<VRExperienceHelper>;
  99656. /**
  99657. * Observable raised when controller mesh is loaded.
  99658. */
  99659. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99660. /** Return this.onEnteringVRObservable
  99661. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99662. */
  99663. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99664. /** Return this.onExitingVRObservable
  99665. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99666. */
  99667. readonly onExitingVR: Observable<VRExperienceHelper>;
  99668. /** Return this.onControllerMeshLoadedObservable
  99669. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99670. */
  99671. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99672. private _rayLength;
  99673. private _useCustomVRButton;
  99674. private _teleportationRequested;
  99675. private _teleportActive;
  99676. private _floorMeshName;
  99677. private _floorMeshesCollection;
  99678. private _rotationAllowed;
  99679. private _teleportBackwardsVector;
  99680. private _teleportationTarget;
  99681. private _isDefaultTeleportationTarget;
  99682. private _postProcessMove;
  99683. private _teleportationFillColor;
  99684. private _teleportationBorderColor;
  99685. private _rotationAngle;
  99686. private _haloCenter;
  99687. private _cameraGazer;
  99688. private _padSensibilityUp;
  99689. private _padSensibilityDown;
  99690. private _leftController;
  99691. private _rightController;
  99692. /**
  99693. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99694. */
  99695. onNewMeshSelected: Observable<AbstractMesh>;
  99696. /**
  99697. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99698. */
  99699. onNewMeshPicked: Observable<PickingInfo>;
  99700. private _circleEase;
  99701. /**
  99702. * Observable raised before camera teleportation
  99703. */
  99704. onBeforeCameraTeleport: Observable<Vector3>;
  99705. /**
  99706. * Observable raised after camera teleportation
  99707. */
  99708. onAfterCameraTeleport: Observable<Vector3>;
  99709. /**
  99710. * Observable raised when current selected mesh gets unselected
  99711. */
  99712. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99713. private _raySelectionPredicate;
  99714. /**
  99715. * To be optionaly changed by user to define custom ray selection
  99716. */
  99717. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99718. /**
  99719. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99720. */
  99721. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99722. /**
  99723. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99724. */
  99725. teleportationEnabled: boolean;
  99726. private _defaultHeight;
  99727. private _teleportationInitialized;
  99728. private _interactionsEnabled;
  99729. private _interactionsRequested;
  99730. private _displayGaze;
  99731. private _displayLaserPointer;
  99732. /**
  99733. * The mesh used to display where the user is going to teleport.
  99734. */
  99735. /**
  99736. * Sets the mesh to be used to display where the user is going to teleport.
  99737. */
  99738. teleportationTarget: Mesh;
  99739. /**
  99740. * 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
  99741. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99742. * See http://doc.babylonjs.com/resources/baking_transformations
  99743. */
  99744. gazeTrackerMesh: Mesh;
  99745. /**
  99746. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99747. */
  99748. updateGazeTrackerScale: boolean;
  99749. /**
  99750. * If the gaze trackers color should be updated when selecting meshes
  99751. */
  99752. updateGazeTrackerColor: boolean;
  99753. /**
  99754. * The gaze tracking mesh corresponding to the left controller
  99755. */
  99756. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99757. /**
  99758. * The gaze tracking mesh corresponding to the right controller
  99759. */
  99760. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99761. /**
  99762. * If the ray of the gaze should be displayed.
  99763. */
  99764. /**
  99765. * Sets if the ray of the gaze should be displayed.
  99766. */
  99767. displayGaze: boolean;
  99768. /**
  99769. * If the ray of the LaserPointer should be displayed.
  99770. */
  99771. /**
  99772. * Sets if the ray of the LaserPointer should be displayed.
  99773. */
  99774. displayLaserPointer: boolean;
  99775. /**
  99776. * The deviceOrientationCamera used as the camera when not in VR.
  99777. */
  99778. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99779. /**
  99780. * Based on the current WebVR support, returns the current VR camera used.
  99781. */
  99782. readonly currentVRCamera: Nullable<Camera>;
  99783. /**
  99784. * The webVRCamera which is used when in VR.
  99785. */
  99786. readonly webVRCamera: WebVRFreeCamera;
  99787. /**
  99788. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99789. */
  99790. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99791. private readonly _teleportationRequestInitiated;
  99792. /**
  99793. * Defines wether or not Pointer lock should be requested when switching to
  99794. * full screen.
  99795. */
  99796. requestPointerLockOnFullScreen: boolean;
  99797. /**
  99798. * Instantiates a VRExperienceHelper.
  99799. * Helps to quickly add VR support to an existing scene.
  99800. * @param scene The scene the VRExperienceHelper belongs to.
  99801. * @param webVROptions Options to modify the vr experience helper's behavior.
  99802. */
  99803. constructor(scene: Scene,
  99804. /** Options to modify the vr experience helper's behavior. */
  99805. webVROptions?: VRExperienceHelperOptions);
  99806. private _onDefaultMeshLoaded;
  99807. private _onResize;
  99808. private _onFullscreenChange;
  99809. /**
  99810. * Gets a value indicating if we are currently in VR mode.
  99811. */
  99812. readonly isInVRMode: boolean;
  99813. private onVrDisplayPresentChange;
  99814. private onVRDisplayChanged;
  99815. private moveButtonToBottomRight;
  99816. private displayVRButton;
  99817. private updateButtonVisibility;
  99818. private _cachedAngularSensibility;
  99819. /**
  99820. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99821. * Otherwise, will use the fullscreen API.
  99822. */
  99823. enterVR(): void;
  99824. /**
  99825. * Attempt to exit VR, or fullscreen.
  99826. */
  99827. exitVR(): void;
  99828. /**
  99829. * The position of the vr experience helper.
  99830. */
  99831. /**
  99832. * Sets the position of the vr experience helper.
  99833. */
  99834. position: Vector3;
  99835. /**
  99836. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99837. */
  99838. enableInteractions(): void;
  99839. private readonly _noControllerIsActive;
  99840. private beforeRender;
  99841. private _isTeleportationFloor;
  99842. /**
  99843. * Adds a floor mesh to be used for teleportation.
  99844. * @param floorMesh the mesh to be used for teleportation.
  99845. */
  99846. addFloorMesh(floorMesh: Mesh): void;
  99847. /**
  99848. * Removes a floor mesh from being used for teleportation.
  99849. * @param floorMesh the mesh to be removed.
  99850. */
  99851. removeFloorMesh(floorMesh: Mesh): void;
  99852. /**
  99853. * Enables interactions and teleportation using the VR controllers and gaze.
  99854. * @param vrTeleportationOptions options to modify teleportation behavior.
  99855. */
  99856. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99857. private _onNewGamepadConnected;
  99858. private _tryEnableInteractionOnController;
  99859. private _onNewGamepadDisconnected;
  99860. private _enableInteractionOnController;
  99861. private _checkTeleportWithRay;
  99862. private _checkRotate;
  99863. private _checkTeleportBackwards;
  99864. private _enableTeleportationOnController;
  99865. private _createTeleportationCircles;
  99866. private _displayTeleportationTarget;
  99867. private _hideTeleportationTarget;
  99868. private _rotateCamera;
  99869. private _moveTeleportationSelectorTo;
  99870. private _workingVector;
  99871. private _workingQuaternion;
  99872. private _workingMatrix;
  99873. /**
  99874. * Teleports the users feet to the desired location
  99875. * @param location The location where the user's feet should be placed
  99876. */
  99877. teleportCamera(location: Vector3): void;
  99878. private _convertNormalToDirectionOfRay;
  99879. private _castRayAndSelectObject;
  99880. private _notifySelectedMeshUnselected;
  99881. /**
  99882. * Sets the color of the laser ray from the vr controllers.
  99883. * @param color new color for the ray.
  99884. */
  99885. changeLaserColor(color: Color3): void;
  99886. /**
  99887. * Sets the color of the ray from the vr headsets gaze.
  99888. * @param color new color for the ray.
  99889. */
  99890. changeGazeColor(color: Color3): void;
  99891. /**
  99892. * Exits VR and disposes of the vr experience helper
  99893. */
  99894. dispose(): void;
  99895. /**
  99896. * Gets the name of the VRExperienceHelper class
  99897. * @returns "VRExperienceHelper"
  99898. */
  99899. getClassName(): string;
  99900. }
  99901. }
  99902. declare module BABYLON {
  99903. /**
  99904. * Manages an XRSession
  99905. * @see https://doc.babylonjs.com/how_to/webxr
  99906. */
  99907. export class WebXRSessionManager implements IDisposable {
  99908. private scene;
  99909. /**
  99910. * Fires every time a new xrFrame arrives which can be used to update the camera
  99911. */
  99912. onXRFrameObservable: Observable<any>;
  99913. /**
  99914. * Fires when the xr session is ended either by the device or manually done
  99915. */
  99916. onXRSessionEnded: Observable<any>;
  99917. /** @hidden */
  99918. _xrSession: XRSession;
  99919. /** @hidden */
  99920. _frameOfReference: XRFrameOfReference;
  99921. /** @hidden */
  99922. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99923. /** @hidden */
  99924. _currentXRFrame: Nullable<XRFrame>;
  99925. private _xrNavigator;
  99926. private _xrDevice;
  99927. private _tmpMatrix;
  99928. /**
  99929. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99930. * @param scene The scene which the session should be created for
  99931. */
  99932. constructor(scene: Scene);
  99933. /**
  99934. * Initializes the manager
  99935. * After initialization enterXR can be called to start an XR session
  99936. * @returns Promise which resolves after it is initialized
  99937. */
  99938. initializeAsync(): Promise<void>;
  99939. /**
  99940. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99941. * @param sessionCreationOptions xr options to create the session with
  99942. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99943. * @returns Promise which resolves after it enters XR
  99944. */
  99945. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99946. /**
  99947. * Stops the xrSession and restores the renderloop
  99948. * @returns Promise which resolves after it exits XR
  99949. */
  99950. exitXRAsync(): Promise<void>;
  99951. /**
  99952. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99953. * @param ray ray to cast into the environment
  99954. * @returns Promise which resolves with a collision point in the environment if it exists
  99955. */
  99956. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99957. /**
  99958. * Checks if a session would be supported for the creation options specified
  99959. * @param options creation options to check if they are supported
  99960. * @returns true if supported
  99961. */
  99962. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99963. /**
  99964. * @hidden
  99965. * Converts the render layer of xrSession to a render target
  99966. * @param session session to create render target for
  99967. * @param scene scene the new render target should be created for
  99968. */
  99969. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99970. /**
  99971. * Disposes of the session manager
  99972. */
  99973. dispose(): void;
  99974. }
  99975. }
  99976. declare module BABYLON {
  99977. /**
  99978. * WebXR Camera which holds the views for the xrSession
  99979. * @see https://doc.babylonjs.com/how_to/webxr
  99980. */
  99981. export class WebXRCamera extends FreeCamera {
  99982. private static _TmpMatrix;
  99983. /**
  99984. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99985. * @param name the name of the camera
  99986. * @param scene the scene to add the camera to
  99987. */
  99988. constructor(name: string, scene: Scene);
  99989. private _updateNumberOfRigCameras;
  99990. /** @hidden */
  99991. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99992. /**
  99993. * Updates the cameras position from the current pose information of the XR session
  99994. * @param xrSessionManager the session containing pose information
  99995. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99996. */
  99997. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99998. }
  99999. }
  100000. declare module BABYLON {
  100001. /**
  100002. * States of the webXR experience
  100003. */
  100004. export enum WebXRState {
  100005. /**
  100006. * Transitioning to being in XR mode
  100007. */
  100008. ENTERING_XR = 0,
  100009. /**
  100010. * Transitioning to non XR mode
  100011. */
  100012. EXITING_XR = 1,
  100013. /**
  100014. * In XR mode and presenting
  100015. */
  100016. IN_XR = 2,
  100017. /**
  100018. * Not entered XR mode
  100019. */
  100020. NOT_IN_XR = 3
  100021. }
  100022. /**
  100023. * Helper class used to enable XR
  100024. * @see https://doc.babylonjs.com/how_to/webxr
  100025. */
  100026. export class WebXRExperienceHelper implements IDisposable {
  100027. private scene;
  100028. /**
  100029. * 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
  100030. */
  100031. container: AbstractMesh;
  100032. /**
  100033. * Camera used to render xr content
  100034. */
  100035. camera: WebXRCamera;
  100036. /**
  100037. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100038. */
  100039. state: WebXRState;
  100040. private _setState;
  100041. private static _TmpVector;
  100042. /**
  100043. * Fires when the state of the experience helper has changed
  100044. */
  100045. onStateChangedObservable: Observable<WebXRState>;
  100046. /** @hidden */
  100047. _sessionManager: WebXRSessionManager;
  100048. private _nonVRCamera;
  100049. private _originalSceneAutoClear;
  100050. private _supported;
  100051. /**
  100052. * Creates the experience helper
  100053. * @param scene the scene to attach the experience helper to
  100054. * @returns a promise for the experience helper
  100055. */
  100056. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100057. /**
  100058. * Creates a WebXRExperienceHelper
  100059. * @param scene The scene the helper should be created in
  100060. */
  100061. private constructor();
  100062. /**
  100063. * Exits XR mode and returns the scene to its original state
  100064. * @returns promise that resolves after xr mode has exited
  100065. */
  100066. exitXRAsync(): Promise<void>;
  100067. /**
  100068. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100069. * @param sessionCreationOptions options for the XR session
  100070. * @param frameOfReference frame of reference of the XR session
  100071. * @returns promise that resolves after xr mode has entered
  100072. */
  100073. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100074. /**
  100075. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100076. * @param ray ray to cast into the environment
  100077. * @returns Promise which resolves with a collision point in the environment if it exists
  100078. */
  100079. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100080. /**
  100081. * Updates the global position of the camera by moving the camera's container
  100082. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100083. * @param position The desired global position of the camera
  100084. */
  100085. setPositionOfCameraUsingContainer(position: Vector3): void;
  100086. /**
  100087. * Rotates the xr camera by rotating the camera's container around the camera's position
  100088. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100089. * @param rotation the desired quaternion rotation to apply to the camera
  100090. */
  100091. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100092. /**
  100093. * Checks if the creation options are supported by the xr session
  100094. * @param options creation options
  100095. * @returns true if supported
  100096. */
  100097. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100098. /**
  100099. * Disposes of the experience helper
  100100. */
  100101. dispose(): void;
  100102. }
  100103. }
  100104. declare module BABYLON {
  100105. /**
  100106. * Button which can be used to enter a different mode of XR
  100107. */
  100108. export class WebXREnterExitUIButton {
  100109. /** button element */
  100110. element: HTMLElement;
  100111. /** XR initialization options for the button */
  100112. initializationOptions: XRSessionCreationOptions;
  100113. /**
  100114. * Creates a WebXREnterExitUIButton
  100115. * @param element button element
  100116. * @param initializationOptions XR initialization options for the button
  100117. */
  100118. constructor(
  100119. /** button element */
  100120. element: HTMLElement,
  100121. /** XR initialization options for the button */
  100122. initializationOptions: XRSessionCreationOptions);
  100123. /**
  100124. * Overwritable function which can be used to update the button's visuals when the state changes
  100125. * @param activeButton the current active button in the UI
  100126. */
  100127. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100128. }
  100129. /**
  100130. * Options to create the webXR UI
  100131. */
  100132. export class WebXREnterExitUIOptions {
  100133. /**
  100134. * Context to enter xr with
  100135. */
  100136. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100137. /**
  100138. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100139. */
  100140. customButtons?: Array<WebXREnterExitUIButton>;
  100141. }
  100142. /**
  100143. * UI to allow the user to enter/exit XR mode
  100144. */
  100145. export class WebXREnterExitUI implements IDisposable {
  100146. private scene;
  100147. private _overlay;
  100148. private _buttons;
  100149. private _activeButton;
  100150. /**
  100151. * Fired every time the active button is changed.
  100152. *
  100153. * When xr is entered via a button that launches xr that button will be the callback parameter
  100154. *
  100155. * When exiting xr the callback parameter will be null)
  100156. */
  100157. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100158. /**
  100159. * Creates UI to allow the user to enter/exit XR mode
  100160. * @param scene the scene to add the ui to
  100161. * @param helper the xr experience helper to enter/exit xr with
  100162. * @param options options to configure the UI
  100163. * @returns the created ui
  100164. */
  100165. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100166. private constructor();
  100167. private _updateButtons;
  100168. /**
  100169. * Disposes of the object
  100170. */
  100171. dispose(): void;
  100172. }
  100173. }
  100174. declare module BABYLON {
  100175. /**
  100176. * Represents an XR input
  100177. */
  100178. export class WebXRController {
  100179. /**
  100180. * 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
  100181. */
  100182. grip?: AbstractMesh;
  100183. /**
  100184. * Pointer which can be used to select objects or attach a visible laser to
  100185. */
  100186. pointer: AbstractMesh;
  100187. /**
  100188. * Creates the controller
  100189. * @see https://doc.babylonjs.com/how_to/webxr
  100190. * @param scene the scene which the controller should be associated to
  100191. */
  100192. constructor(scene: Scene);
  100193. /**
  100194. * Disposes of the object
  100195. */
  100196. dispose(): void;
  100197. }
  100198. /**
  100199. * XR input used to track XR inputs such as controllers/rays
  100200. */
  100201. export class WebXRInput implements IDisposable {
  100202. private helper;
  100203. /**
  100204. * XR controllers being tracked
  100205. */
  100206. controllers: Array<WebXRController>;
  100207. private _tmpMatrix;
  100208. private _frameObserver;
  100209. /**
  100210. * Initializes the WebXRInput
  100211. * @param helper experience helper which the input should be created for
  100212. */
  100213. constructor(helper: WebXRExperienceHelper);
  100214. /**
  100215. * Disposes of the object
  100216. */
  100217. dispose(): void;
  100218. }
  100219. }
  100220. declare module BABYLON {
  100221. /**
  100222. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100223. */
  100224. export class WebXRManagedOutputCanvas implements IDisposable {
  100225. private _canvas;
  100226. /**
  100227. * xrpresent context of the canvas which can be used to display/mirror xr content
  100228. */
  100229. canvasContext: Nullable<WebGLRenderingContext>;
  100230. /**
  100231. * Initializes the canvas to be added/removed upon entering/exiting xr
  100232. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100233. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100234. */
  100235. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100236. /**
  100237. * Disposes of the object
  100238. */
  100239. dispose(): void;
  100240. private _setManagedOutputCanvas;
  100241. private _addCanvas;
  100242. private _removeCanvas;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * Contains an array of blocks representing the octree
  100248. */
  100249. export interface IOctreeContainer<T> {
  100250. /**
  100251. * Blocks within the octree
  100252. */
  100253. blocks: Array<OctreeBlock<T>>;
  100254. }
  100255. /**
  100256. * Class used to store a cell in an octree
  100257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100258. */
  100259. export class OctreeBlock<T> {
  100260. /**
  100261. * Gets the content of the current block
  100262. */
  100263. entries: T[];
  100264. /**
  100265. * Gets the list of block children
  100266. */
  100267. blocks: Array<OctreeBlock<T>>;
  100268. private _depth;
  100269. private _maxDepth;
  100270. private _capacity;
  100271. private _minPoint;
  100272. private _maxPoint;
  100273. private _boundingVectors;
  100274. private _creationFunc;
  100275. /**
  100276. * Creates a new block
  100277. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100278. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100279. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100280. * @param depth defines the current depth of this block in the octree
  100281. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100282. * @param creationFunc defines a callback to call when an element is added to the block
  100283. */
  100284. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100285. /**
  100286. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100287. */
  100288. readonly capacity: number;
  100289. /**
  100290. * Gets the minimum vector (in world space) of the block's bounding box
  100291. */
  100292. readonly minPoint: Vector3;
  100293. /**
  100294. * Gets the maximum vector (in world space) of the block's bounding box
  100295. */
  100296. readonly maxPoint: Vector3;
  100297. /**
  100298. * Add a new element to this block
  100299. * @param entry defines the element to add
  100300. */
  100301. addEntry(entry: T): void;
  100302. /**
  100303. * Remove an element from this block
  100304. * @param entry defines the element to remove
  100305. */
  100306. removeEntry(entry: T): void;
  100307. /**
  100308. * Add an array of elements to this block
  100309. * @param entries defines the array of elements to add
  100310. */
  100311. addEntries(entries: T[]): void;
  100312. /**
  100313. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100314. * @param frustumPlanes defines the frustum planes to test
  100315. * @param selection defines the array to store current content if selection is positive
  100316. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100317. */
  100318. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100319. /**
  100320. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100321. * @param sphereCenter defines the bounding sphere center
  100322. * @param sphereRadius defines the bounding sphere radius
  100323. * @param selection defines the array to store current content if selection is positive
  100324. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100325. */
  100326. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100327. /**
  100328. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100329. * @param ray defines the ray to test with
  100330. * @param selection defines the array to store current content if selection is positive
  100331. */
  100332. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100333. /**
  100334. * Subdivide the content into child blocks (this block will then be empty)
  100335. */
  100336. createInnerBlocks(): void;
  100337. /**
  100338. * @hidden
  100339. */
  100340. 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;
  100341. }
  100342. }
  100343. declare module BABYLON {
  100344. /**
  100345. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100347. */
  100348. export class Octree<T> {
  100349. /** 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.) */
  100350. maxDepth: number;
  100351. /**
  100352. * Blocks within the octree containing objects
  100353. */
  100354. blocks: Array<OctreeBlock<T>>;
  100355. /**
  100356. * Content stored in the octree
  100357. */
  100358. dynamicContent: T[];
  100359. private _maxBlockCapacity;
  100360. private _selectionContent;
  100361. private _creationFunc;
  100362. /**
  100363. * Creates a octree
  100364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100365. * @param creationFunc function to be used to instatiate the octree
  100366. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100367. * @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.)
  100368. */
  100369. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100370. /** 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.) */
  100371. maxDepth?: number);
  100372. /**
  100373. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100374. * @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);
  100375. * @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);
  100376. * @param entries meshes to be added to the octree blocks
  100377. */
  100378. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100379. /**
  100380. * Adds a mesh to the octree
  100381. * @param entry Mesh to add to the octree
  100382. */
  100383. addMesh(entry: T): void;
  100384. /**
  100385. * Remove an element from the octree
  100386. * @param entry defines the element to remove
  100387. */
  100388. removeMesh(entry: T): void;
  100389. /**
  100390. * Selects an array of meshes within the frustum
  100391. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100392. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100393. * @returns array of meshes within the frustum
  100394. */
  100395. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100396. /**
  100397. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100398. * @param sphereCenter defines the bounding sphere center
  100399. * @param sphereRadius defines the bounding sphere radius
  100400. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100401. * @returns an array of objects that intersect the sphere
  100402. */
  100403. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100404. /**
  100405. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100406. * @param ray defines the ray to test with
  100407. * @returns array of intersected objects
  100408. */
  100409. intersectsRay(ray: Ray): SmartArray<T>;
  100410. /**
  100411. * Adds a mesh into the octree block if it intersects the block
  100412. */
  100413. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100414. /**
  100415. * Adds a submesh into the octree block if it intersects the block
  100416. */
  100417. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100418. }
  100419. }
  100420. declare module BABYLON {
  100421. interface Scene {
  100422. /**
  100423. * @hidden
  100424. * Backing Filed
  100425. */
  100426. _selectionOctree: Octree<AbstractMesh>;
  100427. /**
  100428. * Gets the octree used to boost mesh selection (picking)
  100429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100430. */
  100431. selectionOctree: Octree<AbstractMesh>;
  100432. /**
  100433. * Creates or updates the octree used to boost selection (picking)
  100434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100435. * @param maxCapacity defines the maximum capacity per leaf
  100436. * @param maxDepth defines the maximum depth of the octree
  100437. * @returns an octree of AbstractMesh
  100438. */
  100439. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100440. }
  100441. interface AbstractMesh {
  100442. /**
  100443. * @hidden
  100444. * Backing Field
  100445. */
  100446. _submeshesOctree: Octree<SubMesh>;
  100447. /**
  100448. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100449. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100450. * @param maxCapacity defines the maximum size of each block (64 by default)
  100451. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100452. * @returns the new octree
  100453. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100455. */
  100456. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100457. }
  100458. /**
  100459. * Defines the octree scene component responsible to manage any octrees
  100460. * in a given scene.
  100461. */
  100462. export class OctreeSceneComponent {
  100463. /**
  100464. * The component name help to identify the component in the list of scene components.
  100465. */
  100466. readonly name: string;
  100467. /**
  100468. * The scene the component belongs to.
  100469. */
  100470. scene: Scene;
  100471. /**
  100472. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100473. */
  100474. readonly checksIsEnabled: boolean;
  100475. /**
  100476. * Creates a new instance of the component for the given scene
  100477. * @param scene Defines the scene to register the component in
  100478. */
  100479. constructor(scene: Scene);
  100480. /**
  100481. * Registers the component in a given scene
  100482. */
  100483. register(): void;
  100484. /**
  100485. * Return the list of active meshes
  100486. * @returns the list of active meshes
  100487. */
  100488. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100489. /**
  100490. * Return the list of active sub meshes
  100491. * @param mesh The mesh to get the candidates sub meshes from
  100492. * @returns the list of active sub meshes
  100493. */
  100494. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100495. private _tempRay;
  100496. /**
  100497. * Return the list of sub meshes intersecting with a given local ray
  100498. * @param mesh defines the mesh to find the submesh for
  100499. * @param localRay defines the ray in local space
  100500. * @returns the list of intersecting sub meshes
  100501. */
  100502. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100503. /**
  100504. * Return the list of sub meshes colliding with a collider
  100505. * @param mesh defines the mesh to find the submesh for
  100506. * @param collider defines the collider to evaluate the collision against
  100507. * @returns the list of colliding sub meshes
  100508. */
  100509. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100510. /**
  100511. * Rebuilds the elements related to this component in case of
  100512. * context lost for instance.
  100513. */
  100514. rebuild(): void;
  100515. /**
  100516. * Disposes the component and the associated ressources.
  100517. */
  100518. dispose(): void;
  100519. }
  100520. }
  100521. declare module BABYLON {
  100522. /**
  100523. * Renders a layer on top of an existing scene
  100524. */
  100525. export class UtilityLayerRenderer implements IDisposable {
  100526. /** the original scene that will be rendered on top of */
  100527. originalScene: Scene;
  100528. private _pointerCaptures;
  100529. private _lastPointerEvents;
  100530. private static _DefaultUtilityLayer;
  100531. private static _DefaultKeepDepthUtilityLayer;
  100532. private _sharedGizmoLight;
  100533. /**
  100534. * @hidden
  100535. * Light which used by gizmos to get light shading
  100536. */
  100537. _getSharedGizmoLight(): HemisphericLight;
  100538. /**
  100539. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100540. */
  100541. pickUtilitySceneFirst: boolean;
  100542. /**
  100543. * 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)
  100544. */
  100545. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100546. /**
  100547. * 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)
  100548. */
  100549. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100550. /**
  100551. * The scene that is rendered on top of the original scene
  100552. */
  100553. utilityLayerScene: Scene;
  100554. /**
  100555. * If the utility layer should automatically be rendered on top of existing scene
  100556. */
  100557. shouldRender: boolean;
  100558. /**
  100559. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100560. */
  100561. onlyCheckPointerDownEvents: boolean;
  100562. /**
  100563. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100564. */
  100565. processAllEvents: boolean;
  100566. /**
  100567. * Observable raised when the pointer move from the utility layer scene to the main scene
  100568. */
  100569. onPointerOutObservable: Observable<number>;
  100570. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100571. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100572. private _afterRenderObserver;
  100573. private _sceneDisposeObserver;
  100574. private _originalPointerObserver;
  100575. /**
  100576. * Instantiates a UtilityLayerRenderer
  100577. * @param originalScene the original scene that will be rendered on top of
  100578. * @param handleEvents boolean indicating if the utility layer should handle events
  100579. */
  100580. constructor(
  100581. /** the original scene that will be rendered on top of */
  100582. originalScene: Scene, handleEvents?: boolean);
  100583. private _notifyObservers;
  100584. /**
  100585. * Renders the utility layers scene on top of the original scene
  100586. */
  100587. render(): void;
  100588. /**
  100589. * Disposes of the renderer
  100590. */
  100591. dispose(): void;
  100592. private _updateCamera;
  100593. }
  100594. }
  100595. declare module BABYLON {
  100596. /**
  100597. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100598. */
  100599. export class Gizmo implements IDisposable {
  100600. /** The utility layer the gizmo will be added to */
  100601. gizmoLayer: UtilityLayerRenderer;
  100602. /**
  100603. * The root mesh of the gizmo
  100604. */
  100605. _rootMesh: Mesh;
  100606. private _attachedMesh;
  100607. /**
  100608. * Ratio for the scale of the gizmo (Default: 1)
  100609. */
  100610. scaleRatio: number;
  100611. /**
  100612. * If a custom mesh has been set (Default: false)
  100613. */
  100614. protected _customMeshSet: boolean;
  100615. /**
  100616. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100617. * * When set, interactions will be enabled
  100618. */
  100619. attachedMesh: Nullable<AbstractMesh>;
  100620. /**
  100621. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100622. * @param mesh The mesh to replace the default mesh of the gizmo
  100623. */
  100624. setCustomMesh(mesh: Mesh): void;
  100625. /**
  100626. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100627. */
  100628. updateGizmoRotationToMatchAttachedMesh: boolean;
  100629. /**
  100630. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100631. */
  100632. updateGizmoPositionToMatchAttachedMesh: boolean;
  100633. /**
  100634. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100635. */
  100636. protected _updateScale: boolean;
  100637. protected _interactionsEnabled: boolean;
  100638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100639. private _beforeRenderObserver;
  100640. private _tempVector;
  100641. /**
  100642. * Creates a gizmo
  100643. * @param gizmoLayer The utility layer the gizmo will be added to
  100644. */
  100645. constructor(
  100646. /** The utility layer the gizmo will be added to */
  100647. gizmoLayer?: UtilityLayerRenderer);
  100648. /**
  100649. * Updates the gizmo to match the attached mesh's position/rotation
  100650. */
  100651. protected _update(): void;
  100652. /**
  100653. * Disposes of the gizmo
  100654. */
  100655. dispose(): void;
  100656. }
  100657. }
  100658. declare module BABYLON {
  100659. /**
  100660. * Single axis drag gizmo
  100661. */
  100662. export class AxisDragGizmo extends Gizmo {
  100663. /**
  100664. * Drag behavior responsible for the gizmos dragging interactions
  100665. */
  100666. dragBehavior: PointerDragBehavior;
  100667. private _pointerObserver;
  100668. /**
  100669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100670. */
  100671. snapDistance: number;
  100672. /**
  100673. * Event that fires each time the gizmo snaps to a new location.
  100674. * * snapDistance is the the change in distance
  100675. */
  100676. onSnapObservable: Observable<{
  100677. snapDistance: number;
  100678. }>;
  100679. /** @hidden */
  100680. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100681. /** @hidden */
  100682. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100683. /**
  100684. * Creates an AxisDragGizmo
  100685. * @param gizmoLayer The utility layer the gizmo will be added to
  100686. * @param dragAxis The axis which the gizmo will be able to drag on
  100687. * @param color The color of the gizmo
  100688. */
  100689. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100691. /**
  100692. * Disposes of the gizmo
  100693. */
  100694. dispose(): void;
  100695. }
  100696. }
  100697. declare module BABYLON.Debug {
  100698. /**
  100699. * The Axes viewer will show 3 axes in a specific point in space
  100700. */
  100701. export class AxesViewer {
  100702. private _xAxis;
  100703. private _yAxis;
  100704. private _zAxis;
  100705. private _scaleLinesFactor;
  100706. private _instanced;
  100707. /**
  100708. * Gets the hosting scene
  100709. */
  100710. scene: Scene;
  100711. /**
  100712. * Gets or sets a number used to scale line length
  100713. */
  100714. scaleLines: number;
  100715. /** Gets the node hierarchy used to render x-axis */
  100716. readonly xAxis: TransformNode;
  100717. /** Gets the node hierarchy used to render y-axis */
  100718. readonly yAxis: TransformNode;
  100719. /** Gets the node hierarchy used to render z-axis */
  100720. readonly zAxis: TransformNode;
  100721. /**
  100722. * Creates a new AxesViewer
  100723. * @param scene defines the hosting scene
  100724. * @param scaleLines defines a number used to scale line length (1 by default)
  100725. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100726. * @param xAxis defines the node hierarchy used to render the x-axis
  100727. * @param yAxis defines the node hierarchy used to render the y-axis
  100728. * @param zAxis defines the node hierarchy used to render the z-axis
  100729. */
  100730. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100731. /**
  100732. * Force the viewer to update
  100733. * @param position defines the position of the viewer
  100734. * @param xaxis defines the x axis of the viewer
  100735. * @param yaxis defines the y axis of the viewer
  100736. * @param zaxis defines the z axis of the viewer
  100737. */
  100738. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100739. /**
  100740. * Creates an instance of this axes viewer.
  100741. * @returns a new axes viewer with instanced meshes
  100742. */
  100743. createInstance(): AxesViewer;
  100744. /** Releases resources */
  100745. dispose(): void;
  100746. private static _SetRenderingGroupId;
  100747. }
  100748. }
  100749. declare module BABYLON.Debug {
  100750. /**
  100751. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100752. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100753. */
  100754. export class BoneAxesViewer extends AxesViewer {
  100755. /**
  100756. * Gets or sets the target mesh where to display the axes viewer
  100757. */
  100758. mesh: Nullable<Mesh>;
  100759. /**
  100760. * Gets or sets the target bone where to display the axes viewer
  100761. */
  100762. bone: Nullable<Bone>;
  100763. /** Gets current position */
  100764. pos: Vector3;
  100765. /** Gets direction of X axis */
  100766. xaxis: Vector3;
  100767. /** Gets direction of Y axis */
  100768. yaxis: Vector3;
  100769. /** Gets direction of Z axis */
  100770. zaxis: Vector3;
  100771. /**
  100772. * Creates a new BoneAxesViewer
  100773. * @param scene defines the hosting scene
  100774. * @param bone defines the target bone
  100775. * @param mesh defines the target mesh
  100776. * @param scaleLines defines a scaling factor for line length (1 by default)
  100777. */
  100778. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100779. /**
  100780. * Force the viewer to update
  100781. */
  100782. update(): void;
  100783. /** Releases resources */
  100784. dispose(): void;
  100785. }
  100786. }
  100787. declare module BABYLON {
  100788. /**
  100789. * Interface used to define scene explorer extensibility option
  100790. */
  100791. export interface IExplorerExtensibilityOption {
  100792. /**
  100793. * Define the option label
  100794. */
  100795. label: string;
  100796. /**
  100797. * Defines the action to execute on click
  100798. */
  100799. action: (entity: any) => void;
  100800. }
  100801. /**
  100802. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100803. */
  100804. export interface IExplorerExtensibilityGroup {
  100805. /**
  100806. * Defines a predicate to test if a given type mut be extended
  100807. */
  100808. predicate: (entity: any) => boolean;
  100809. /**
  100810. * Gets the list of options added to a type
  100811. */
  100812. entries: IExplorerExtensibilityOption[];
  100813. }
  100814. /**
  100815. * Interface used to define the options to use to create the Inspector
  100816. */
  100817. export interface IInspectorOptions {
  100818. /**
  100819. * Display in overlay mode (default: false)
  100820. */
  100821. overlay?: boolean;
  100822. /**
  100823. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100824. */
  100825. globalRoot?: HTMLElement;
  100826. /**
  100827. * Display the Scene explorer
  100828. */
  100829. showExplorer?: boolean;
  100830. /**
  100831. * Display the property inspector
  100832. */
  100833. showInspector?: boolean;
  100834. /**
  100835. * Display in embed mode (both panes on the right)
  100836. */
  100837. embedMode?: boolean;
  100838. /**
  100839. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100840. */
  100841. handleResize?: boolean;
  100842. /**
  100843. * Allow the panes to popup (default: true)
  100844. */
  100845. enablePopup?: boolean;
  100846. /**
  100847. * Allow the panes to be closed by users (default: true)
  100848. */
  100849. enableClose?: boolean;
  100850. /**
  100851. * Optional list of extensibility entries
  100852. */
  100853. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100854. /**
  100855. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100856. */
  100857. inspectorURL?: string;
  100858. }
  100859. interface Scene {
  100860. /**
  100861. * @hidden
  100862. * Backing field
  100863. */
  100864. _debugLayer: DebugLayer;
  100865. /**
  100866. * Gets the debug layer (aka Inspector) associated with the scene
  100867. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100868. */
  100869. debugLayer: DebugLayer;
  100870. }
  100871. /**
  100872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100873. * what is happening in your scene
  100874. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100875. */
  100876. export class DebugLayer {
  100877. /**
  100878. * Define the url to get the inspector script from.
  100879. * By default it uses the babylonjs CDN.
  100880. * @ignoreNaming
  100881. */
  100882. static InspectorURL: string;
  100883. private _scene;
  100884. private BJSINSPECTOR;
  100885. /**
  100886. * Observable triggered when a property is changed through the inspector.
  100887. */
  100888. onPropertyChangedObservable: Observable<{
  100889. object: any;
  100890. property: string;
  100891. value: any;
  100892. initialValue: any;
  100893. }>;
  100894. /**
  100895. * Instantiates a new debug layer.
  100896. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100897. * what is happening in your scene
  100898. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100899. * @param scene Defines the scene to inspect
  100900. */
  100901. constructor(scene: Scene);
  100902. /** Creates the inspector window. */
  100903. private _createInspector;
  100904. /**
  100905. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100906. * @param entity defines the entity to select
  100907. * @param lineContainerTitle defines the specific block to highlight
  100908. */
  100909. select(entity: any, lineContainerTitle?: string): void;
  100910. /** Get the inspector from bundle or global */
  100911. private _getGlobalInspector;
  100912. /**
  100913. * Get if the inspector is visible or not.
  100914. * @returns true if visible otherwise, false
  100915. */
  100916. isVisible(): boolean;
  100917. /**
  100918. * Hide the inspector and close its window.
  100919. */
  100920. hide(): void;
  100921. /**
  100922. * Launch the debugLayer.
  100923. * @param config Define the configuration of the inspector
  100924. * @return a promise fulfilled when the debug layer is visible
  100925. */
  100926. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100927. }
  100928. }
  100929. declare module BABYLON {
  100930. /**
  100931. * Class containing static functions to help procedurally build meshes
  100932. */
  100933. export class BoxBuilder {
  100934. /**
  100935. * Creates a box mesh
  100936. * * The parameter `size` sets the size (float) of each box side (default 1)
  100937. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100938. * * 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)
  100939. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100943. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100944. * @param name defines the name of the mesh
  100945. * @param options defines the options used to create the mesh
  100946. * @param scene defines the hosting scene
  100947. * @returns the box mesh
  100948. */
  100949. static CreateBox(name: string, options: {
  100950. size?: number;
  100951. width?: number;
  100952. height?: number;
  100953. depth?: number;
  100954. faceUV?: Vector4[];
  100955. faceColors?: Color4[];
  100956. sideOrientation?: number;
  100957. frontUVs?: Vector4;
  100958. backUVs?: Vector4;
  100959. wrap?: boolean;
  100960. topBaseAt?: number;
  100961. bottomBaseAt?: number;
  100962. updatable?: boolean;
  100963. }, scene?: Nullable<Scene>): Mesh;
  100964. }
  100965. }
  100966. declare module BABYLON {
  100967. /**
  100968. * Class containing static functions to help procedurally build meshes
  100969. */
  100970. export class SphereBuilder {
  100971. /**
  100972. * Creates a sphere mesh
  100973. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100974. * * 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`)
  100975. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100976. * * 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
  100977. * * 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)
  100978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100981. * @param name defines the name of the mesh
  100982. * @param options defines the options used to create the mesh
  100983. * @param scene defines the hosting scene
  100984. * @returns the sphere mesh
  100985. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100986. */
  100987. static CreateSphere(name: string, options: {
  100988. segments?: number;
  100989. diameter?: number;
  100990. diameterX?: number;
  100991. diameterY?: number;
  100992. diameterZ?: number;
  100993. arc?: number;
  100994. slice?: number;
  100995. sideOrientation?: number;
  100996. frontUVs?: Vector4;
  100997. backUVs?: Vector4;
  100998. updatable?: boolean;
  100999. }, scene: any): Mesh;
  101000. }
  101001. }
  101002. declare module BABYLON.Debug {
  101003. /**
  101004. * Used to show the physics impostor around the specific mesh
  101005. */
  101006. export class PhysicsViewer {
  101007. /** @hidden */
  101008. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101009. /** @hidden */
  101010. protected _meshes: Array<Nullable<AbstractMesh>>;
  101011. /** @hidden */
  101012. protected _scene: Nullable<Scene>;
  101013. /** @hidden */
  101014. protected _numMeshes: number;
  101015. /** @hidden */
  101016. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101017. private _renderFunction;
  101018. private _utilityLayer;
  101019. private _debugBoxMesh;
  101020. private _debugSphereMesh;
  101021. private _debugCylinderMesh;
  101022. private _debugMaterial;
  101023. private _debugMeshMeshes;
  101024. /**
  101025. * Creates a new PhysicsViewer
  101026. * @param scene defines the hosting scene
  101027. */
  101028. constructor(scene: Scene);
  101029. /** @hidden */
  101030. protected _updateDebugMeshes(): void;
  101031. /**
  101032. * Renders a specified physic impostor
  101033. * @param impostor defines the impostor to render
  101034. * @param targetMesh defines the mesh represented by the impostor
  101035. * @returns the new debug mesh used to render the impostor
  101036. */
  101037. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101038. /**
  101039. * Hides a specified physic impostor
  101040. * @param impostor defines the impostor to hide
  101041. */
  101042. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101043. private _getDebugMaterial;
  101044. private _getDebugBoxMesh;
  101045. private _getDebugSphereMesh;
  101046. private _getDebugCylinderMesh;
  101047. private _getDebugMeshMesh;
  101048. private _getDebugMesh;
  101049. /** Releases all resources */
  101050. dispose(): void;
  101051. }
  101052. }
  101053. declare module BABYLON {
  101054. /**
  101055. * Class containing static functions to help procedurally build meshes
  101056. */
  101057. export class LinesBuilder {
  101058. /**
  101059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101060. * * 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
  101061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101066. * * 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
  101067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101070. * @param name defines the name of the new line system
  101071. * @param options defines the options used to create the line system
  101072. * @param scene defines the hosting scene
  101073. * @returns a new line system mesh
  101074. */
  101075. static CreateLineSystem(name: string, options: {
  101076. lines: Vector3[][];
  101077. updatable?: boolean;
  101078. instance?: Nullable<LinesMesh>;
  101079. colors?: Nullable<Color4[][]>;
  101080. useVertexAlpha?: boolean;
  101081. }, scene: Nullable<Scene>): LinesMesh;
  101082. /**
  101083. * Creates a line mesh
  101084. * 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
  101085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101086. * * The parameter `points` is an array successive Vector3
  101087. * * 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
  101088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101090. * * When updating an instance, remember that only point positions can change, not the number of points
  101091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101093. * @param name defines the name of the new line system
  101094. * @param options defines the options used to create the line system
  101095. * @param scene defines the hosting scene
  101096. * @returns a new line mesh
  101097. */
  101098. static CreateLines(name: string, options: {
  101099. points: Vector3[];
  101100. updatable?: boolean;
  101101. instance?: Nullable<LinesMesh>;
  101102. colors?: Color4[];
  101103. useVertexAlpha?: boolean;
  101104. }, scene?: Nullable<Scene>): LinesMesh;
  101105. /**
  101106. * Creates a dashed line mesh
  101107. * * 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
  101108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101109. * * The parameter `points` is an array successive Vector3
  101110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101113. * * 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
  101114. * * When updating an instance, remember that only point positions can change, not the number of points
  101115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101116. * @param name defines the name of the mesh
  101117. * @param options defines the options used to create the mesh
  101118. * @param scene defines the hosting scene
  101119. * @returns the dashed line mesh
  101120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101121. */
  101122. static CreateDashedLines(name: string, options: {
  101123. points: Vector3[];
  101124. dashSize?: number;
  101125. gapSize?: number;
  101126. dashNb?: number;
  101127. updatable?: boolean;
  101128. instance?: LinesMesh;
  101129. }, scene?: Nullable<Scene>): LinesMesh;
  101130. }
  101131. }
  101132. declare module BABYLON {
  101133. /**
  101134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101135. * in order to better appreciate the issue one might have.
  101136. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101137. */
  101138. export class RayHelper {
  101139. /**
  101140. * Defines the ray we are currently tryin to visualize.
  101141. */
  101142. ray: Nullable<Ray>;
  101143. private _renderPoints;
  101144. private _renderLine;
  101145. private _renderFunction;
  101146. private _scene;
  101147. private _updateToMeshFunction;
  101148. private _attachedToMesh;
  101149. private _meshSpaceDirection;
  101150. private _meshSpaceOrigin;
  101151. /**
  101152. * Helper function to create a colored helper in a scene in one line.
  101153. * @param ray Defines the ray we are currently tryin to visualize
  101154. * @param scene Defines the scene the ray is used in
  101155. * @param color Defines the color we want to see the ray in
  101156. * @returns The newly created ray helper.
  101157. */
  101158. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101159. /**
  101160. * Instantiate a new ray helper.
  101161. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101162. * in order to better appreciate the issue one might have.
  101163. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101164. * @param ray Defines the ray we are currently tryin to visualize
  101165. */
  101166. constructor(ray: Ray);
  101167. /**
  101168. * Shows the ray we are willing to debug.
  101169. * @param scene Defines the scene the ray needs to be rendered in
  101170. * @param color Defines the color the ray needs to be rendered in
  101171. */
  101172. show(scene: Scene, color?: Color3): void;
  101173. /**
  101174. * Hides the ray we are debugging.
  101175. */
  101176. hide(): void;
  101177. private _render;
  101178. /**
  101179. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101180. * @param mesh Defines the mesh we want the helper attached to
  101181. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101182. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101183. * @param length Defines the length of the ray
  101184. */
  101185. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101186. /**
  101187. * Detach the ray helper from the mesh it has previously been attached to.
  101188. */
  101189. detachFromMesh(): void;
  101190. private _updateToMesh;
  101191. /**
  101192. * Dispose the helper and release its associated resources.
  101193. */
  101194. dispose(): void;
  101195. }
  101196. }
  101197. declare module BABYLON.Debug {
  101198. /**
  101199. * Class used to render a debug view of a given skeleton
  101200. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101201. */
  101202. export class SkeletonViewer {
  101203. /** defines the skeleton to render */
  101204. skeleton: Skeleton;
  101205. /** defines the mesh attached to the skeleton */
  101206. mesh: AbstractMesh;
  101207. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101208. autoUpdateBonesMatrices: boolean;
  101209. /** defines the rendering group id to use with the viewer */
  101210. renderingGroupId: number;
  101211. /** Gets or sets the color used to render the skeleton */
  101212. color: Color3;
  101213. private _scene;
  101214. private _debugLines;
  101215. private _debugMesh;
  101216. private _isEnabled;
  101217. private _renderFunction;
  101218. private _utilityLayer;
  101219. /**
  101220. * Returns the mesh used to render the bones
  101221. */
  101222. readonly debugMesh: Nullable<LinesMesh>;
  101223. /**
  101224. * Creates a new SkeletonViewer
  101225. * @param skeleton defines the skeleton to render
  101226. * @param mesh defines the mesh attached to the skeleton
  101227. * @param scene defines the hosting scene
  101228. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101229. * @param renderingGroupId defines the rendering group id to use with the viewer
  101230. */
  101231. constructor(
  101232. /** defines the skeleton to render */
  101233. skeleton: Skeleton,
  101234. /** defines the mesh attached to the skeleton */
  101235. mesh: AbstractMesh, scene: Scene,
  101236. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101237. autoUpdateBonesMatrices?: boolean,
  101238. /** defines the rendering group id to use with the viewer */
  101239. renderingGroupId?: number);
  101240. /** Gets or sets a boolean indicating if the viewer is enabled */
  101241. isEnabled: boolean;
  101242. private _getBonePosition;
  101243. private _getLinesForBonesWithLength;
  101244. private _getLinesForBonesNoLength;
  101245. /** Update the viewer to sync with current skeleton state */
  101246. update(): void;
  101247. /** Release associated resources */
  101248. dispose(): void;
  101249. }
  101250. }
  101251. declare module BABYLON {
  101252. /**
  101253. * Options to create the null engine
  101254. */
  101255. export class NullEngineOptions {
  101256. /**
  101257. * Render width (Default: 512)
  101258. */
  101259. renderWidth: number;
  101260. /**
  101261. * Render height (Default: 256)
  101262. */
  101263. renderHeight: number;
  101264. /**
  101265. * Texture size (Default: 512)
  101266. */
  101267. textureSize: number;
  101268. /**
  101269. * If delta time between frames should be constant
  101270. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101271. */
  101272. deterministicLockstep: boolean;
  101273. /**
  101274. * Maximum about of steps between frames (Default: 4)
  101275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101276. */
  101277. lockstepMaxSteps: number;
  101278. }
  101279. /**
  101280. * The null engine class provides support for headless version of babylon.js.
  101281. * This can be used in server side scenario or for testing purposes
  101282. */
  101283. export class NullEngine extends Engine {
  101284. private _options;
  101285. /**
  101286. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101287. */
  101288. isDeterministicLockStep(): boolean;
  101289. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101290. getLockstepMaxSteps(): number;
  101291. /**
  101292. * Sets hardware scaling, used to save performance if needed
  101293. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101294. */
  101295. getHardwareScalingLevel(): number;
  101296. constructor(options?: NullEngineOptions);
  101297. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101298. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101299. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101300. getRenderWidth(useScreen?: boolean): number;
  101301. getRenderHeight(useScreen?: boolean): number;
  101302. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101303. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101304. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101305. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101306. bindSamplers(effect: Effect): void;
  101307. enableEffect(effect: Effect): void;
  101308. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101309. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101311. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101312. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101313. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101314. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101315. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101316. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101317. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101318. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101319. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101320. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101321. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101322. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101323. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101324. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101325. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101326. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101327. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101328. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101329. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101330. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101331. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101332. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101333. bindBuffers(vertexBuffers: {
  101334. [key: string]: VertexBuffer;
  101335. }, indexBuffer: DataBuffer, effect: Effect): void;
  101336. wipeCaches(bruteForce?: boolean): void;
  101337. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101338. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101339. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101340. /** @hidden */
  101341. _createTexture(): WebGLTexture;
  101342. /** @hidden */
  101343. _releaseTexture(texture: InternalTexture): void;
  101344. 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;
  101345. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101347. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101348. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101349. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101350. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101351. areAllEffectsReady(): boolean;
  101352. /**
  101353. * @hidden
  101354. * Get the current error code of the webGL context
  101355. * @returns the error code
  101356. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101357. */
  101358. getError(): number;
  101359. /** @hidden */
  101360. _getUnpackAlignement(): number;
  101361. /** @hidden */
  101362. _unpackFlipY(value: boolean): void;
  101363. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101364. /**
  101365. * Updates a dynamic vertex buffer.
  101366. * @param vertexBuffer the vertex buffer to update
  101367. * @param data the data used to update the vertex buffer
  101368. * @param byteOffset the byte offset of the data (optional)
  101369. * @param byteLength the byte length of the data (optional)
  101370. */
  101371. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101372. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101373. /** @hidden */
  101374. _bindTexture(channel: number, texture: InternalTexture): void;
  101375. /** @hidden */
  101376. _releaseBuffer(buffer: DataBuffer): boolean;
  101377. releaseEffects(): void;
  101378. displayLoadingUI(): void;
  101379. hideLoadingUI(): void;
  101380. /** @hidden */
  101381. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101382. /** @hidden */
  101383. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101384. /** @hidden */
  101385. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101386. /** @hidden */
  101387. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101388. }
  101389. }
  101390. declare module BABYLON {
  101391. /** @hidden */
  101392. export class _OcclusionDataStorage {
  101393. /** @hidden */
  101394. occlusionInternalRetryCounter: number;
  101395. /** @hidden */
  101396. isOcclusionQueryInProgress: boolean;
  101397. /** @hidden */
  101398. isOccluded: boolean;
  101399. /** @hidden */
  101400. occlusionRetryCount: number;
  101401. /** @hidden */
  101402. occlusionType: number;
  101403. /** @hidden */
  101404. occlusionQueryAlgorithmType: number;
  101405. }
  101406. interface Engine {
  101407. /**
  101408. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101409. * @return the new query
  101410. */
  101411. createQuery(): WebGLQuery;
  101412. /**
  101413. * Delete and release a webGL query
  101414. * @param query defines the query to delete
  101415. * @return the current engine
  101416. */
  101417. deleteQuery(query: WebGLQuery): Engine;
  101418. /**
  101419. * Check if a given query has resolved and got its value
  101420. * @param query defines the query to check
  101421. * @returns true if the query got its value
  101422. */
  101423. isQueryResultAvailable(query: WebGLQuery): boolean;
  101424. /**
  101425. * Gets the value of a given query
  101426. * @param query defines the query to check
  101427. * @returns the value of the query
  101428. */
  101429. getQueryResult(query: WebGLQuery): number;
  101430. /**
  101431. * Initiates an occlusion query
  101432. * @param algorithmType defines the algorithm to use
  101433. * @param query defines the query to use
  101434. * @returns the current engine
  101435. * @see http://doc.babylonjs.com/features/occlusionquery
  101436. */
  101437. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101438. /**
  101439. * Ends an occlusion query
  101440. * @see http://doc.babylonjs.com/features/occlusionquery
  101441. * @param algorithmType defines the algorithm to use
  101442. * @returns the current engine
  101443. */
  101444. endOcclusionQuery(algorithmType: number): Engine;
  101445. /**
  101446. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101447. * Please note that only one query can be issued at a time
  101448. * @returns a time token used to track the time span
  101449. */
  101450. startTimeQuery(): Nullable<_TimeToken>;
  101451. /**
  101452. * Ends a time query
  101453. * @param token defines the token used to measure the time span
  101454. * @returns the time spent (in ns)
  101455. */
  101456. endTimeQuery(token: _TimeToken): int;
  101457. /** @hidden */
  101458. _currentNonTimestampToken: Nullable<_TimeToken>;
  101459. /** @hidden */
  101460. _createTimeQuery(): WebGLQuery;
  101461. /** @hidden */
  101462. _deleteTimeQuery(query: WebGLQuery): void;
  101463. /** @hidden */
  101464. _getGlAlgorithmType(algorithmType: number): number;
  101465. /** @hidden */
  101466. _getTimeQueryResult(query: WebGLQuery): any;
  101467. /** @hidden */
  101468. _getTimeQueryAvailability(query: WebGLQuery): any;
  101469. }
  101470. interface AbstractMesh {
  101471. /**
  101472. * Backing filed
  101473. * @hidden
  101474. */
  101475. __occlusionDataStorage: _OcclusionDataStorage;
  101476. /**
  101477. * Access property
  101478. * @hidden
  101479. */
  101480. _occlusionDataStorage: _OcclusionDataStorage;
  101481. /**
  101482. * 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.
  101483. * The default value is -1 which means don't break the query and wait till the result
  101484. * @see http://doc.babylonjs.com/features/occlusionquery
  101485. */
  101486. occlusionRetryCount: number;
  101487. /**
  101488. * 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:
  101489. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101490. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101491. * * 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.
  101492. * @see http://doc.babylonjs.com/features/occlusionquery
  101493. */
  101494. occlusionType: number;
  101495. /**
  101496. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101497. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101498. * * 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.
  101499. * @see http://doc.babylonjs.com/features/occlusionquery
  101500. */
  101501. occlusionQueryAlgorithmType: number;
  101502. /**
  101503. * 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
  101504. * @see http://doc.babylonjs.com/features/occlusionquery
  101505. */
  101506. isOccluded: boolean;
  101507. /**
  101508. * Flag to check the progress status of the query
  101509. * @see http://doc.babylonjs.com/features/occlusionquery
  101510. */
  101511. isOcclusionQueryInProgress: boolean;
  101512. }
  101513. }
  101514. declare module BABYLON {
  101515. /** @hidden */
  101516. export var _forceTransformFeedbackToBundle: boolean;
  101517. interface Engine {
  101518. /**
  101519. * Creates a webGL transform feedback object
  101520. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101521. * @returns the webGL transform feedback object
  101522. */
  101523. createTransformFeedback(): WebGLTransformFeedback;
  101524. /**
  101525. * Delete a webGL transform feedback object
  101526. * @param value defines the webGL transform feedback object to delete
  101527. */
  101528. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101529. /**
  101530. * Bind a webGL transform feedback object to the webgl context
  101531. * @param value defines the webGL transform feedback object to bind
  101532. */
  101533. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101534. /**
  101535. * Begins a transform feedback operation
  101536. * @param usePoints defines if points or triangles must be used
  101537. */
  101538. beginTransformFeedback(usePoints: boolean): void;
  101539. /**
  101540. * Ends a transform feedback operation
  101541. */
  101542. endTransformFeedback(): void;
  101543. /**
  101544. * Specify the varyings to use with transform feedback
  101545. * @param program defines the associated webGL program
  101546. * @param value defines the list of strings representing the varying names
  101547. */
  101548. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101549. /**
  101550. * Bind a webGL buffer for a transform feedback operation
  101551. * @param value defines the webGL buffer to bind
  101552. */
  101553. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101554. }
  101555. }
  101556. declare module BABYLON {
  101557. /**
  101558. * Creation options of the multi render target texture.
  101559. */
  101560. export interface IMultiRenderTargetOptions {
  101561. /**
  101562. * Define if the texture needs to create mip maps after render.
  101563. */
  101564. generateMipMaps?: boolean;
  101565. /**
  101566. * Define the types of all the draw buffers we want to create
  101567. */
  101568. types?: number[];
  101569. /**
  101570. * Define the sampling modes of all the draw buffers we want to create
  101571. */
  101572. samplingModes?: number[];
  101573. /**
  101574. * Define if a depth buffer is required
  101575. */
  101576. generateDepthBuffer?: boolean;
  101577. /**
  101578. * Define if a stencil buffer is required
  101579. */
  101580. generateStencilBuffer?: boolean;
  101581. /**
  101582. * Define if a depth texture is required instead of a depth buffer
  101583. */
  101584. generateDepthTexture?: boolean;
  101585. /**
  101586. * Define the number of desired draw buffers
  101587. */
  101588. textureCount?: number;
  101589. /**
  101590. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101591. */
  101592. doNotChangeAspectRatio?: boolean;
  101593. /**
  101594. * Define the default type of the buffers we are creating
  101595. */
  101596. defaultType?: number;
  101597. }
  101598. /**
  101599. * A multi render target, like a render target provides the ability to render to a texture.
  101600. * Unlike the render target, it can render to several draw buffers in one draw.
  101601. * This is specially interesting in deferred rendering or for any effects requiring more than
  101602. * just one color from a single pass.
  101603. */
  101604. export class MultiRenderTarget extends RenderTargetTexture {
  101605. private _internalTextures;
  101606. private _textures;
  101607. private _multiRenderTargetOptions;
  101608. /**
  101609. * Get if draw buffers are currently supported by the used hardware and browser.
  101610. */
  101611. readonly isSupported: boolean;
  101612. /**
  101613. * Get the list of textures generated by the multi render target.
  101614. */
  101615. readonly textures: Texture[];
  101616. /**
  101617. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101618. */
  101619. readonly depthTexture: Texture;
  101620. /**
  101621. * Set the wrapping mode on U of all the textures we are rendering to.
  101622. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101623. */
  101624. wrapU: number;
  101625. /**
  101626. * Set the wrapping mode on V of all the textures we are rendering to.
  101627. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101628. */
  101629. wrapV: number;
  101630. /**
  101631. * Instantiate a new multi render target texture.
  101632. * A multi render target, like a render target provides the ability to render to a texture.
  101633. * Unlike the render target, it can render to several draw buffers in one draw.
  101634. * This is specially interesting in deferred rendering or for any effects requiring more than
  101635. * just one color from a single pass.
  101636. * @param name Define the name of the texture
  101637. * @param size Define the size of the buffers to render to
  101638. * @param count Define the number of target we are rendering into
  101639. * @param scene Define the scene the texture belongs to
  101640. * @param options Define the options used to create the multi render target
  101641. */
  101642. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101643. /** @hidden */
  101644. _rebuild(): void;
  101645. private _createInternalTextures;
  101646. private _createTextures;
  101647. /**
  101648. * Define the number of samples used if MSAA is enabled.
  101649. */
  101650. samples: number;
  101651. /**
  101652. * Resize all the textures in the multi render target.
  101653. * Be carrefull as it will recreate all the data in the new texture.
  101654. * @param size Define the new size
  101655. */
  101656. resize(size: any): void;
  101657. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101658. /**
  101659. * Dispose the render targets and their associated resources
  101660. */
  101661. dispose(): void;
  101662. /**
  101663. * Release all the underlying texture used as draw buffers.
  101664. */
  101665. releaseInternalTextures(): void;
  101666. }
  101667. }
  101668. declare module BABYLON {
  101669. interface Engine {
  101670. /**
  101671. * Unbind a list of render target textures from the webGL context
  101672. * This is used only when drawBuffer extension or webGL2 are active
  101673. * @param textures defines the render target textures to unbind
  101674. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101675. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101676. */
  101677. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101678. /**
  101679. * Create a multi render target texture
  101680. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101681. * @param size defines the size of the texture
  101682. * @param options defines the creation options
  101683. * @returns the cube texture as an InternalTexture
  101684. */
  101685. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101686. /**
  101687. * Update the sample count for a given multiple render target texture
  101688. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101689. * @param textures defines the textures to update
  101690. * @param samples defines the sample count to set
  101691. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101692. */
  101693. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101694. }
  101695. }
  101696. declare module BABYLON {
  101697. /**
  101698. * Gather the list of clipboard event types as constants.
  101699. */
  101700. export class ClipboardEventTypes {
  101701. /**
  101702. * The clipboard event is fired when a copy command is active (pressed).
  101703. */
  101704. static readonly COPY: number;
  101705. /**
  101706. * The clipboard event is fired when a cut command is active (pressed).
  101707. */
  101708. static readonly CUT: number;
  101709. /**
  101710. * The clipboard event is fired when a paste command is active (pressed).
  101711. */
  101712. static readonly PASTE: number;
  101713. }
  101714. /**
  101715. * This class is used to store clipboard related info for the onClipboardObservable event.
  101716. */
  101717. export class ClipboardInfo {
  101718. /**
  101719. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101720. */
  101721. type: number;
  101722. /**
  101723. * Defines the related dom event
  101724. */
  101725. event: ClipboardEvent;
  101726. /**
  101727. *Creates an instance of ClipboardInfo.
  101728. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101729. * @param event Defines the related dom event
  101730. */
  101731. constructor(
  101732. /**
  101733. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101734. */
  101735. type: number,
  101736. /**
  101737. * Defines the related dom event
  101738. */
  101739. event: ClipboardEvent);
  101740. /**
  101741. * Get the clipboard event's type from the keycode.
  101742. * @param keyCode Defines the keyCode for the current keyboard event.
  101743. * @return {number}
  101744. */
  101745. static GetTypeFromCharacter(keyCode: number): number;
  101746. }
  101747. }
  101748. declare module BABYLON {
  101749. /**
  101750. * Class used to represent data loading progression
  101751. */
  101752. export class SceneLoaderProgressEvent {
  101753. /** defines if data length to load can be evaluated */
  101754. readonly lengthComputable: boolean;
  101755. /** defines the loaded data length */
  101756. readonly loaded: number;
  101757. /** defines the data length to load */
  101758. readonly total: number;
  101759. /**
  101760. * Create a new progress event
  101761. * @param lengthComputable defines if data length to load can be evaluated
  101762. * @param loaded defines the loaded data length
  101763. * @param total defines the data length to load
  101764. */
  101765. constructor(
  101766. /** defines if data length to load can be evaluated */
  101767. lengthComputable: boolean,
  101768. /** defines the loaded data length */
  101769. loaded: number,
  101770. /** defines the data length to load */
  101771. total: number);
  101772. /**
  101773. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101774. * @param event defines the source event
  101775. * @returns a new SceneLoaderProgressEvent
  101776. */
  101777. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101778. }
  101779. /**
  101780. * Interface used by SceneLoader plugins to define supported file extensions
  101781. */
  101782. export interface ISceneLoaderPluginExtensions {
  101783. /**
  101784. * Defines the list of supported extensions
  101785. */
  101786. [extension: string]: {
  101787. isBinary: boolean;
  101788. };
  101789. }
  101790. /**
  101791. * Interface used by SceneLoader plugin factory
  101792. */
  101793. export interface ISceneLoaderPluginFactory {
  101794. /**
  101795. * Defines the name of the factory
  101796. */
  101797. name: string;
  101798. /**
  101799. * Function called to create a new plugin
  101800. * @return the new plugin
  101801. */
  101802. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101803. /**
  101804. * Boolean indicating if the plugin can direct load specific data
  101805. */
  101806. canDirectLoad?: (data: string) => boolean;
  101807. }
  101808. /**
  101809. * Interface used to define a SceneLoader plugin
  101810. */
  101811. export interface ISceneLoaderPlugin {
  101812. /**
  101813. * The friendly name of this plugin.
  101814. */
  101815. name: string;
  101816. /**
  101817. * The file extensions supported by this plugin.
  101818. */
  101819. extensions: string | ISceneLoaderPluginExtensions;
  101820. /**
  101821. * Import meshes into a scene.
  101822. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101823. * @param scene The scene to import into
  101824. * @param data The data to import
  101825. * @param rootUrl The root url for scene and resources
  101826. * @param meshes The meshes array to import into
  101827. * @param particleSystems The particle systems array to import into
  101828. * @param skeletons The skeletons array to import into
  101829. * @param onError The callback when import fails
  101830. * @returns True if successful or false otherwise
  101831. */
  101832. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101833. /**
  101834. * Load into a scene.
  101835. * @param scene The scene to load into
  101836. * @param data The data to import
  101837. * @param rootUrl The root url for scene and resources
  101838. * @param onError The callback when import fails
  101839. * @returns true if successful or false otherwise
  101840. */
  101841. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101842. /**
  101843. * The callback that returns true if the data can be directly loaded.
  101844. */
  101845. canDirectLoad?: (data: string) => boolean;
  101846. /**
  101847. * The callback that allows custom handling of the root url based on the response url.
  101848. */
  101849. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101850. /**
  101851. * Load into an asset container.
  101852. * @param scene The scene to load into
  101853. * @param data The data to import
  101854. * @param rootUrl The root url for scene and resources
  101855. * @param onError The callback when import fails
  101856. * @returns The loaded asset container
  101857. */
  101858. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101859. }
  101860. /**
  101861. * Interface used to define an async SceneLoader plugin
  101862. */
  101863. export interface ISceneLoaderPluginAsync {
  101864. /**
  101865. * The friendly name of this plugin.
  101866. */
  101867. name: string;
  101868. /**
  101869. * The file extensions supported by this plugin.
  101870. */
  101871. extensions: string | ISceneLoaderPluginExtensions;
  101872. /**
  101873. * Import meshes into a scene.
  101874. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101875. * @param scene The scene to import into
  101876. * @param data The data to import
  101877. * @param rootUrl The root url for scene and resources
  101878. * @param onProgress The callback when the load progresses
  101879. * @param fileName Defines the name of the file to load
  101880. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101881. */
  101882. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101883. meshes: AbstractMesh[];
  101884. particleSystems: IParticleSystem[];
  101885. skeletons: Skeleton[];
  101886. animationGroups: AnimationGroup[];
  101887. }>;
  101888. /**
  101889. * Load into a scene.
  101890. * @param scene The scene to load into
  101891. * @param data The data to import
  101892. * @param rootUrl The root url for scene and resources
  101893. * @param onProgress The callback when the load progresses
  101894. * @param fileName Defines the name of the file to load
  101895. * @returns Nothing
  101896. */
  101897. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101898. /**
  101899. * The callback that returns true if the data can be directly loaded.
  101900. */
  101901. canDirectLoad?: (data: string) => boolean;
  101902. /**
  101903. * The callback that allows custom handling of the root url based on the response url.
  101904. */
  101905. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101906. /**
  101907. * Load into an asset container.
  101908. * @param scene The scene to load into
  101909. * @param data The data to import
  101910. * @param rootUrl The root url for scene and resources
  101911. * @param onProgress The callback when the load progresses
  101912. * @param fileName Defines the name of the file to load
  101913. * @returns The loaded asset container
  101914. */
  101915. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101916. }
  101917. /**
  101918. * Class used to load scene from various file formats using registered plugins
  101919. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101920. */
  101921. export class SceneLoader {
  101922. /**
  101923. * No logging while loading
  101924. */
  101925. static readonly NO_LOGGING: number;
  101926. /**
  101927. * Minimal logging while loading
  101928. */
  101929. static readonly MINIMAL_LOGGING: number;
  101930. /**
  101931. * Summary logging while loading
  101932. */
  101933. static readonly SUMMARY_LOGGING: number;
  101934. /**
  101935. * Detailled logging while loading
  101936. */
  101937. static readonly DETAILED_LOGGING: number;
  101938. /**
  101939. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101940. */
  101941. static ForceFullSceneLoadingForIncremental: boolean;
  101942. /**
  101943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101944. */
  101945. static ShowLoadingScreen: boolean;
  101946. /**
  101947. * Defines the current logging level (while loading the scene)
  101948. * @ignorenaming
  101949. */
  101950. static loggingLevel: number;
  101951. /**
  101952. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101953. */
  101954. static CleanBoneMatrixWeights: boolean;
  101955. /**
  101956. * Event raised when a plugin is used to load a scene
  101957. */
  101958. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101959. private static _registeredPlugins;
  101960. private static _getDefaultPlugin;
  101961. private static _getPluginForExtension;
  101962. private static _getPluginForDirectLoad;
  101963. private static _getPluginForFilename;
  101964. private static _getDirectLoad;
  101965. private static _loadData;
  101966. private static _getFileInfo;
  101967. /**
  101968. * Gets a plugin that can load the given extension
  101969. * @param extension defines the extension to load
  101970. * @returns a plugin or null if none works
  101971. */
  101972. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101973. /**
  101974. * Gets a boolean indicating that the given extension can be loaded
  101975. * @param extension defines the extension to load
  101976. * @returns true if the extension is supported
  101977. */
  101978. static IsPluginForExtensionAvailable(extension: string): boolean;
  101979. /**
  101980. * Adds a new plugin to the list of registered plugins
  101981. * @param plugin defines the plugin to add
  101982. */
  101983. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101984. /**
  101985. * Import meshes into a scene
  101986. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101987. * @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)
  101988. * @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)
  101989. * @param scene the instance of BABYLON.Scene to append to
  101990. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101991. * @param onProgress a callback with a progress event for each file being loaded
  101992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101993. * @param pluginExtension the extension used to determine the plugin
  101994. * @returns The loaded plugin
  101995. */
  101996. 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>;
  101997. /**
  101998. * Import meshes into a scene
  101999. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102000. * @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)
  102001. * @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)
  102002. * @param scene the instance of BABYLON.Scene to append to
  102003. * @param onProgress a callback with a progress event for each file being loaded
  102004. * @param pluginExtension the extension used to determine the plugin
  102005. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102006. */
  102007. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102008. meshes: AbstractMesh[];
  102009. particleSystems: IParticleSystem[];
  102010. skeletons: Skeleton[];
  102011. animationGroups: AnimationGroup[];
  102012. }>;
  102013. /**
  102014. * Load a scene
  102015. * @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)
  102016. * @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)
  102017. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102018. * @param onSuccess a callback with the scene when import succeeds
  102019. * @param onProgress a callback with a progress event for each file being loaded
  102020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102021. * @param pluginExtension the extension used to determine the plugin
  102022. * @returns The loaded plugin
  102023. */
  102024. 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>;
  102025. /**
  102026. * Load a scene
  102027. * @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)
  102028. * @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)
  102029. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102030. * @param onProgress a callback with a progress event for each file being loaded
  102031. * @param pluginExtension the extension used to determine the plugin
  102032. * @returns The loaded scene
  102033. */
  102034. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102035. /**
  102036. * Append a scene
  102037. * @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)
  102038. * @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)
  102039. * @param scene is the instance of BABYLON.Scene to append to
  102040. * @param onSuccess a callback with the scene when import succeeds
  102041. * @param onProgress a callback with a progress event for each file being loaded
  102042. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102043. * @param pluginExtension the extension used to determine the plugin
  102044. * @returns The loaded plugin
  102045. */
  102046. 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>;
  102047. /**
  102048. * Append a scene
  102049. * @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)
  102050. * @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)
  102051. * @param scene is the instance of BABYLON.Scene to append to
  102052. * @param onProgress a callback with a progress event for each file being loaded
  102053. * @param pluginExtension the extension used to determine the plugin
  102054. * @returns The given scene
  102055. */
  102056. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102057. /**
  102058. * Load a scene into an asset container
  102059. * @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)
  102060. * @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)
  102061. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102062. * @param onSuccess a callback with the scene when import succeeds
  102063. * @param onProgress a callback with a progress event for each file being loaded
  102064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102065. * @param pluginExtension the extension used to determine the plugin
  102066. * @returns The loaded plugin
  102067. */
  102068. 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>;
  102069. /**
  102070. * Load a scene into an asset container
  102071. * @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)
  102072. * @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)
  102073. * @param scene is the instance of Scene to append to
  102074. * @param onProgress a callback with a progress event for each file being loaded
  102075. * @param pluginExtension the extension used to determine the plugin
  102076. * @returns The loaded asset container
  102077. */
  102078. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102079. }
  102080. }
  102081. declare module BABYLON {
  102082. /**
  102083. * Google Daydream controller
  102084. */
  102085. export class DaydreamController extends WebVRController {
  102086. /**
  102087. * Base Url for the controller model.
  102088. */
  102089. static MODEL_BASE_URL: string;
  102090. /**
  102091. * File name for the controller model.
  102092. */
  102093. static MODEL_FILENAME: string;
  102094. /**
  102095. * Gamepad Id prefix used to identify Daydream Controller.
  102096. */
  102097. static readonly GAMEPAD_ID_PREFIX: string;
  102098. /**
  102099. * Creates a new DaydreamController from a gamepad
  102100. * @param vrGamepad the gamepad that the controller should be created from
  102101. */
  102102. constructor(vrGamepad: any);
  102103. /**
  102104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102105. * @param scene scene in which to add meshes
  102106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102107. */
  102108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102109. /**
  102110. * Called once for each button that changed state since the last frame
  102111. * @param buttonIdx Which button index changed
  102112. * @param state New state of the button
  102113. * @param changes Which properties on the state changed since last frame
  102114. */
  102115. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102116. }
  102117. }
  102118. declare module BABYLON {
  102119. /**
  102120. * Gear VR Controller
  102121. */
  102122. export class GearVRController extends WebVRController {
  102123. /**
  102124. * Base Url for the controller model.
  102125. */
  102126. static MODEL_BASE_URL: string;
  102127. /**
  102128. * File name for the controller model.
  102129. */
  102130. static MODEL_FILENAME: string;
  102131. /**
  102132. * Gamepad Id prefix used to identify this controller.
  102133. */
  102134. static readonly GAMEPAD_ID_PREFIX: string;
  102135. private readonly _buttonIndexToObservableNameMap;
  102136. /**
  102137. * Creates a new GearVRController from a gamepad
  102138. * @param vrGamepad the gamepad that the controller should be created from
  102139. */
  102140. constructor(vrGamepad: any);
  102141. /**
  102142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102143. * @param scene scene in which to add meshes
  102144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102145. */
  102146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102147. /**
  102148. * Called once for each button that changed state since the last frame
  102149. * @param buttonIdx Which button index changed
  102150. * @param state New state of the button
  102151. * @param changes Which properties on the state changed since last frame
  102152. */
  102153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102154. }
  102155. }
  102156. declare module BABYLON {
  102157. /**
  102158. * Generic Controller
  102159. */
  102160. export class GenericController extends WebVRController {
  102161. /**
  102162. * Base Url for the controller model.
  102163. */
  102164. static readonly MODEL_BASE_URL: string;
  102165. /**
  102166. * File name for the controller model.
  102167. */
  102168. static readonly MODEL_FILENAME: string;
  102169. /**
  102170. * Creates a new GenericController from a gamepad
  102171. * @param vrGamepad the gamepad that the controller should be created from
  102172. */
  102173. constructor(vrGamepad: any);
  102174. /**
  102175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102176. * @param scene scene in which to add meshes
  102177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102178. */
  102179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102180. /**
  102181. * Called once for each button that changed state since the last frame
  102182. * @param buttonIdx Which button index changed
  102183. * @param state New state of the button
  102184. * @param changes Which properties on the state changed since last frame
  102185. */
  102186. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102187. }
  102188. }
  102189. declare module BABYLON {
  102190. /**
  102191. * Oculus Touch Controller
  102192. */
  102193. export class OculusTouchController extends WebVRController {
  102194. /**
  102195. * Base Url for the controller model.
  102196. */
  102197. static MODEL_BASE_URL: string;
  102198. /**
  102199. * File name for the left controller model.
  102200. */
  102201. static MODEL_LEFT_FILENAME: string;
  102202. /**
  102203. * File name for the right controller model.
  102204. */
  102205. static MODEL_RIGHT_FILENAME: string;
  102206. /**
  102207. * Fired when the secondary trigger on this controller is modified
  102208. */
  102209. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102210. /**
  102211. * Fired when the thumb rest on this controller is modified
  102212. */
  102213. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102214. /**
  102215. * Creates a new OculusTouchController from a gamepad
  102216. * @param vrGamepad the gamepad that the controller should be created from
  102217. */
  102218. constructor(vrGamepad: any);
  102219. /**
  102220. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102221. * @param scene scene in which to add meshes
  102222. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102223. */
  102224. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102225. /**
  102226. * Fired when the A button on this controller is modified
  102227. */
  102228. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102229. /**
  102230. * Fired when the B button on this controller is modified
  102231. */
  102232. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102233. /**
  102234. * Fired when the X button on this controller is modified
  102235. */
  102236. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102237. /**
  102238. * Fired when the Y button on this controller is modified
  102239. */
  102240. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102241. /**
  102242. * Called once for each button that changed state since the last frame
  102243. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102244. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102245. * 2) secondary trigger (same)
  102246. * 3) A (right) X (left), touch, pressed = value
  102247. * 4) B / Y
  102248. * 5) thumb rest
  102249. * @param buttonIdx Which button index changed
  102250. * @param state New state of the button
  102251. * @param changes Which properties on the state changed since last frame
  102252. */
  102253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102254. }
  102255. }
  102256. declare module BABYLON {
  102257. /**
  102258. * Vive Controller
  102259. */
  102260. export class ViveController extends WebVRController {
  102261. /**
  102262. * Base Url for the controller model.
  102263. */
  102264. static MODEL_BASE_URL: string;
  102265. /**
  102266. * File name for the controller model.
  102267. */
  102268. static MODEL_FILENAME: string;
  102269. /**
  102270. * Creates a new ViveController from a gamepad
  102271. * @param vrGamepad the gamepad that the controller should be created from
  102272. */
  102273. constructor(vrGamepad: any);
  102274. /**
  102275. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102276. * @param scene scene in which to add meshes
  102277. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102278. */
  102279. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102280. /**
  102281. * Fired when the left button on this controller is modified
  102282. */
  102283. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102284. /**
  102285. * Fired when the right button on this controller is modified
  102286. */
  102287. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102288. /**
  102289. * Fired when the menu button on this controller is modified
  102290. */
  102291. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102292. /**
  102293. * Called once for each button that changed state since the last frame
  102294. * Vive mapping:
  102295. * 0: touchpad
  102296. * 1: trigger
  102297. * 2: left AND right buttons
  102298. * 3: menu button
  102299. * @param buttonIdx Which button index changed
  102300. * @param state New state of the button
  102301. * @param changes Which properties on the state changed since last frame
  102302. */
  102303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102304. }
  102305. }
  102306. declare module BABYLON {
  102307. /**
  102308. * Defines the WindowsMotionController object that the state of the windows motion controller
  102309. */
  102310. export class WindowsMotionController extends WebVRController {
  102311. /**
  102312. * The base url used to load the left and right controller models
  102313. */
  102314. static MODEL_BASE_URL: string;
  102315. /**
  102316. * The name of the left controller model file
  102317. */
  102318. static MODEL_LEFT_FILENAME: string;
  102319. /**
  102320. * The name of the right controller model file
  102321. */
  102322. static MODEL_RIGHT_FILENAME: string;
  102323. /**
  102324. * The controller name prefix for this controller type
  102325. */
  102326. static readonly GAMEPAD_ID_PREFIX: string;
  102327. /**
  102328. * The controller id pattern for this controller type
  102329. */
  102330. private static readonly GAMEPAD_ID_PATTERN;
  102331. private _loadedMeshInfo;
  102332. private readonly _mapping;
  102333. /**
  102334. * Fired when the trackpad on this controller is clicked
  102335. */
  102336. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102337. /**
  102338. * Fired when the trackpad on this controller is modified
  102339. */
  102340. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102341. /**
  102342. * The current x and y values of this controller's trackpad
  102343. */
  102344. trackpad: StickValues;
  102345. /**
  102346. * Creates a new WindowsMotionController from a gamepad
  102347. * @param vrGamepad the gamepad that the controller should be created from
  102348. */
  102349. constructor(vrGamepad: any);
  102350. /**
  102351. * Fired when the trigger on this controller is modified
  102352. */
  102353. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102354. /**
  102355. * Fired when the menu button on this controller is modified
  102356. */
  102357. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102358. /**
  102359. * Fired when the grip button on this controller is modified
  102360. */
  102361. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102362. /**
  102363. * Fired when the thumbstick button on this controller is modified
  102364. */
  102365. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102366. /**
  102367. * Fired when the touchpad button on this controller is modified
  102368. */
  102369. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102370. /**
  102371. * Fired when the touchpad values on this controller are modified
  102372. */
  102373. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102374. private _updateTrackpad;
  102375. /**
  102376. * Called once per frame by the engine.
  102377. */
  102378. update(): void;
  102379. /**
  102380. * Called once for each button that changed state since the last frame
  102381. * @param buttonIdx Which button index changed
  102382. * @param state New state of the button
  102383. * @param changes Which properties on the state changed since last frame
  102384. */
  102385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102386. /**
  102387. * Moves the buttons on the controller mesh based on their current state
  102388. * @param buttonName the name of the button to move
  102389. * @param buttonValue the value of the button which determines the buttons new position
  102390. */
  102391. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102392. /**
  102393. * Moves the axis on the controller mesh based on its current state
  102394. * @param axis the index of the axis
  102395. * @param axisValue the value of the axis which determines the meshes new position
  102396. * @hidden
  102397. */
  102398. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102399. /**
  102400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102401. * @param scene scene in which to add meshes
  102402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102403. */
  102404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102405. /**
  102406. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102407. * can be transformed by button presses and axes values, based on this._mapping.
  102408. *
  102409. * @param scene scene in which the meshes exist
  102410. * @param meshes list of meshes that make up the controller model to process
  102411. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102412. */
  102413. private processModel;
  102414. private createMeshInfo;
  102415. /**
  102416. * Gets the ray of the controller in the direction the controller is pointing
  102417. * @param length the length the resulting ray should be
  102418. * @returns a ray in the direction the controller is pointing
  102419. */
  102420. getForwardRay(length?: number): Ray;
  102421. /**
  102422. * Disposes of the controller
  102423. */
  102424. dispose(): void;
  102425. }
  102426. }
  102427. declare module BABYLON {
  102428. /**
  102429. * Single axis scale gizmo
  102430. */
  102431. export class AxisScaleGizmo extends Gizmo {
  102432. private _coloredMaterial;
  102433. /**
  102434. * Drag behavior responsible for the gizmos dragging interactions
  102435. */
  102436. dragBehavior: PointerDragBehavior;
  102437. private _pointerObserver;
  102438. /**
  102439. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102440. */
  102441. snapDistance: number;
  102442. /**
  102443. * Event that fires each time the gizmo snaps to a new location.
  102444. * * snapDistance is the the change in distance
  102445. */
  102446. onSnapObservable: Observable<{
  102447. snapDistance: number;
  102448. }>;
  102449. /**
  102450. * If the scaling operation should be done on all axis (default: false)
  102451. */
  102452. uniformScaling: boolean;
  102453. /**
  102454. * Creates an AxisScaleGizmo
  102455. * @param gizmoLayer The utility layer the gizmo will be added to
  102456. * @param dragAxis The axis which the gizmo will be able to scale on
  102457. * @param color The color of the gizmo
  102458. */
  102459. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102460. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102461. /**
  102462. * Disposes of the gizmo
  102463. */
  102464. dispose(): void;
  102465. /**
  102466. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102467. * @param mesh The mesh to replace the default mesh of the gizmo
  102468. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102469. */
  102470. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102471. }
  102472. }
  102473. declare module BABYLON {
  102474. /**
  102475. * Bounding box gizmo
  102476. */
  102477. export class BoundingBoxGizmo extends Gizmo {
  102478. private _lineBoundingBox;
  102479. private _rotateSpheresParent;
  102480. private _scaleBoxesParent;
  102481. private _boundingDimensions;
  102482. private _renderObserver;
  102483. private _pointerObserver;
  102484. private _scaleDragSpeed;
  102485. private _tmpQuaternion;
  102486. private _tmpVector;
  102487. private _tmpRotationMatrix;
  102488. /**
  102489. * 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)
  102490. */
  102491. ignoreChildren: boolean;
  102492. /**
  102493. * 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)
  102494. */
  102495. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102496. /**
  102497. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102498. */
  102499. rotationSphereSize: number;
  102500. /**
  102501. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102502. */
  102503. scaleBoxSize: number;
  102504. /**
  102505. * 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)
  102506. */
  102507. fixedDragMeshScreenSize: boolean;
  102508. /**
  102509. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102510. */
  102511. fixedDragMeshScreenSizeDistanceFactor: number;
  102512. /**
  102513. * Fired when a rotation sphere or scale box is dragged
  102514. */
  102515. onDragStartObservable: Observable<{}>;
  102516. /**
  102517. * Fired when a scale box is dragged
  102518. */
  102519. onScaleBoxDragObservable: Observable<{}>;
  102520. /**
  102521. * Fired when a scale box drag is ended
  102522. */
  102523. onScaleBoxDragEndObservable: Observable<{}>;
  102524. /**
  102525. * Fired when a rotation sphere is dragged
  102526. */
  102527. onRotationSphereDragObservable: Observable<{}>;
  102528. /**
  102529. * Fired when a rotation sphere drag is ended
  102530. */
  102531. onRotationSphereDragEndObservable: Observable<{}>;
  102532. /**
  102533. * 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)
  102534. */
  102535. scalePivot: Nullable<Vector3>;
  102536. /**
  102537. * Mesh used as a pivot to rotate the attached mesh
  102538. */
  102539. private _anchorMesh;
  102540. private _existingMeshScale;
  102541. private _dragMesh;
  102542. private pointerDragBehavior;
  102543. private coloredMaterial;
  102544. private hoverColoredMaterial;
  102545. /**
  102546. * Sets the color of the bounding box gizmo
  102547. * @param color the color to set
  102548. */
  102549. setColor(color: Color3): void;
  102550. /**
  102551. * Creates an BoundingBoxGizmo
  102552. * @param gizmoLayer The utility layer the gizmo will be added to
  102553. * @param color The color of the gizmo
  102554. */
  102555. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102556. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102557. private _selectNode;
  102558. /**
  102559. * Updates the bounding box information for the Gizmo
  102560. */
  102561. updateBoundingBox(): void;
  102562. private _updateRotationSpheres;
  102563. private _updateScaleBoxes;
  102564. /**
  102565. * Enables rotation on the specified axis and disables rotation on the others
  102566. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102567. */
  102568. setEnabledRotationAxis(axis: string): void;
  102569. /**
  102570. * Enables/disables scaling
  102571. * @param enable if scaling should be enabled
  102572. */
  102573. setEnabledScaling(enable: boolean): void;
  102574. private _updateDummy;
  102575. /**
  102576. * Enables a pointer drag behavior on the bounding box of the gizmo
  102577. */
  102578. enableDragBehavior(): void;
  102579. /**
  102580. * Disposes of the gizmo
  102581. */
  102582. dispose(): void;
  102583. /**
  102584. * 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)
  102585. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102586. * @returns the bounding box mesh with the passed in mesh as a child
  102587. */
  102588. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102589. /**
  102590. * CustomMeshes are not supported by this gizmo
  102591. * @param mesh The mesh to replace the default mesh of the gizmo
  102592. */
  102593. setCustomMesh(mesh: Mesh): void;
  102594. }
  102595. }
  102596. declare module BABYLON {
  102597. /**
  102598. * Single plane rotation gizmo
  102599. */
  102600. export class PlaneRotationGizmo extends Gizmo {
  102601. /**
  102602. * Drag behavior responsible for the gizmos dragging interactions
  102603. */
  102604. dragBehavior: PointerDragBehavior;
  102605. private _pointerObserver;
  102606. /**
  102607. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102608. */
  102609. snapDistance: number;
  102610. /**
  102611. * Event that fires each time the gizmo snaps to a new location.
  102612. * * snapDistance is the the change in distance
  102613. */
  102614. onSnapObservable: Observable<{
  102615. snapDistance: number;
  102616. }>;
  102617. /**
  102618. * Creates a PlaneRotationGizmo
  102619. * @param gizmoLayer The utility layer the gizmo will be added to
  102620. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102621. * @param color The color of the gizmo
  102622. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102623. */
  102624. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102625. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102626. /**
  102627. * Disposes of the gizmo
  102628. */
  102629. dispose(): void;
  102630. }
  102631. }
  102632. declare module BABYLON {
  102633. /**
  102634. * Gizmo that enables rotating a mesh along 3 axis
  102635. */
  102636. export class RotationGizmo extends Gizmo {
  102637. /**
  102638. * Internal gizmo used for interactions on the x axis
  102639. */
  102640. xGizmo: PlaneRotationGizmo;
  102641. /**
  102642. * Internal gizmo used for interactions on the y axis
  102643. */
  102644. yGizmo: PlaneRotationGizmo;
  102645. /**
  102646. * Internal gizmo used for interactions on the z axis
  102647. */
  102648. zGizmo: PlaneRotationGizmo;
  102649. /** Fires an event when any of it's sub gizmos are dragged */
  102650. onDragStartObservable: Observable<{}>;
  102651. /** Fires an event when any of it's sub gizmos are released from dragging */
  102652. onDragEndObservable: Observable<{}>;
  102653. attachedMesh: Nullable<AbstractMesh>;
  102654. /**
  102655. * Creates a RotationGizmo
  102656. * @param gizmoLayer The utility layer the gizmo will be added to
  102657. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102658. */
  102659. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102660. updateGizmoRotationToMatchAttachedMesh: boolean;
  102661. /**
  102662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102663. */
  102664. snapDistance: number;
  102665. /**
  102666. * Ratio for the scale of the gizmo (Default: 1)
  102667. */
  102668. scaleRatio: number;
  102669. /**
  102670. * Disposes of the gizmo
  102671. */
  102672. dispose(): void;
  102673. /**
  102674. * CustomMeshes are not supported by this gizmo
  102675. * @param mesh The mesh to replace the default mesh of the gizmo
  102676. */
  102677. setCustomMesh(mesh: Mesh): void;
  102678. }
  102679. }
  102680. declare module BABYLON {
  102681. /**
  102682. * Gizmo that enables dragging a mesh along 3 axis
  102683. */
  102684. export class PositionGizmo extends Gizmo {
  102685. /**
  102686. * Internal gizmo used for interactions on the x axis
  102687. */
  102688. xGizmo: AxisDragGizmo;
  102689. /**
  102690. * Internal gizmo used for interactions on the y axis
  102691. */
  102692. yGizmo: AxisDragGizmo;
  102693. /**
  102694. * Internal gizmo used for interactions on the z axis
  102695. */
  102696. zGizmo: AxisDragGizmo;
  102697. /** Fires an event when any of it's sub gizmos are dragged */
  102698. onDragStartObservable: Observable<{}>;
  102699. /** Fires an event when any of it's sub gizmos are released from dragging */
  102700. onDragEndObservable: Observable<{}>;
  102701. attachedMesh: Nullable<AbstractMesh>;
  102702. /**
  102703. * Creates a PositionGizmo
  102704. * @param gizmoLayer The utility layer the gizmo will be added to
  102705. */
  102706. constructor(gizmoLayer?: UtilityLayerRenderer);
  102707. updateGizmoRotationToMatchAttachedMesh: boolean;
  102708. /**
  102709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102710. */
  102711. snapDistance: number;
  102712. /**
  102713. * Ratio for the scale of the gizmo (Default: 1)
  102714. */
  102715. scaleRatio: number;
  102716. /**
  102717. * Disposes of the gizmo
  102718. */
  102719. dispose(): void;
  102720. /**
  102721. * CustomMeshes are not supported by this gizmo
  102722. * @param mesh The mesh to replace the default mesh of the gizmo
  102723. */
  102724. setCustomMesh(mesh: Mesh): void;
  102725. }
  102726. }
  102727. declare module BABYLON {
  102728. /**
  102729. * Class containing static functions to help procedurally build meshes
  102730. */
  102731. export class PolyhedronBuilder {
  102732. /**
  102733. * Creates a polyhedron mesh
  102734. * * 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
  102735. * * The parameter `size` (positive float, default 1) sets the polygon size
  102736. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102737. * * 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`
  102738. * * 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
  102739. * * 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)`)
  102740. * * 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
  102741. * * 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
  102742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102745. * @param name defines the name of the mesh
  102746. * @param options defines the options used to create the mesh
  102747. * @param scene defines the hosting scene
  102748. * @returns the polyhedron mesh
  102749. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102750. */
  102751. static CreatePolyhedron(name: string, options: {
  102752. type?: number;
  102753. size?: number;
  102754. sizeX?: number;
  102755. sizeY?: number;
  102756. sizeZ?: number;
  102757. custom?: any;
  102758. faceUV?: Vector4[];
  102759. faceColors?: Color4[];
  102760. flat?: boolean;
  102761. updatable?: boolean;
  102762. sideOrientation?: number;
  102763. frontUVs?: Vector4;
  102764. backUVs?: Vector4;
  102765. }, scene?: Nullable<Scene>): Mesh;
  102766. }
  102767. }
  102768. declare module BABYLON {
  102769. /**
  102770. * Gizmo that enables scaling a mesh along 3 axis
  102771. */
  102772. export class ScaleGizmo extends Gizmo {
  102773. /**
  102774. * Internal gizmo used for interactions on the x axis
  102775. */
  102776. xGizmo: AxisScaleGizmo;
  102777. /**
  102778. * Internal gizmo used for interactions on the y axis
  102779. */
  102780. yGizmo: AxisScaleGizmo;
  102781. /**
  102782. * Internal gizmo used for interactions on the z axis
  102783. */
  102784. zGizmo: AxisScaleGizmo;
  102785. /**
  102786. * Internal gizmo used to scale all axis equally
  102787. */
  102788. uniformScaleGizmo: AxisScaleGizmo;
  102789. /** Fires an event when any of it's sub gizmos are dragged */
  102790. onDragStartObservable: Observable<{}>;
  102791. /** Fires an event when any of it's sub gizmos are released from dragging */
  102792. onDragEndObservable: Observable<{}>;
  102793. attachedMesh: Nullable<AbstractMesh>;
  102794. /**
  102795. * Creates a ScaleGizmo
  102796. * @param gizmoLayer The utility layer the gizmo will be added to
  102797. */
  102798. constructor(gizmoLayer?: UtilityLayerRenderer);
  102799. updateGizmoRotationToMatchAttachedMesh: boolean;
  102800. /**
  102801. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102802. */
  102803. snapDistance: number;
  102804. /**
  102805. * Ratio for the scale of the gizmo (Default: 1)
  102806. */
  102807. scaleRatio: number;
  102808. /**
  102809. * Disposes of the gizmo
  102810. */
  102811. dispose(): void;
  102812. }
  102813. }
  102814. declare module BABYLON {
  102815. /**
  102816. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102817. */
  102818. export class GizmoManager implements IDisposable {
  102819. private scene;
  102820. /**
  102821. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102822. */
  102823. gizmos: {
  102824. positionGizmo: Nullable<PositionGizmo>;
  102825. rotationGizmo: Nullable<RotationGizmo>;
  102826. scaleGizmo: Nullable<ScaleGizmo>;
  102827. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102828. };
  102829. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102830. clearGizmoOnEmptyPointerEvent: boolean;
  102831. /** Fires an event when the manager is attached to a mesh */
  102832. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102833. private _gizmosEnabled;
  102834. private _pointerObserver;
  102835. private _attachedMesh;
  102836. private _boundingBoxColor;
  102837. private _defaultUtilityLayer;
  102838. private _defaultKeepDepthUtilityLayer;
  102839. /**
  102840. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102841. */
  102842. boundingBoxDragBehavior: SixDofDragBehavior;
  102843. /**
  102844. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102845. */
  102846. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102847. /**
  102848. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102849. */
  102850. usePointerToAttachGizmos: boolean;
  102851. /**
  102852. * Instatiates a gizmo manager
  102853. * @param scene the scene to overlay the gizmos on top of
  102854. */
  102855. constructor(scene: Scene);
  102856. /**
  102857. * Attaches a set of gizmos to the specified mesh
  102858. * @param mesh The mesh the gizmo's should be attached to
  102859. */
  102860. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102861. /**
  102862. * If the position gizmo is enabled
  102863. */
  102864. positionGizmoEnabled: boolean;
  102865. /**
  102866. * If the rotation gizmo is enabled
  102867. */
  102868. rotationGizmoEnabled: boolean;
  102869. /**
  102870. * If the scale gizmo is enabled
  102871. */
  102872. scaleGizmoEnabled: boolean;
  102873. /**
  102874. * If the boundingBox gizmo is enabled
  102875. */
  102876. boundingBoxGizmoEnabled: boolean;
  102877. /**
  102878. * Disposes of the gizmo manager
  102879. */
  102880. dispose(): void;
  102881. }
  102882. }
  102883. declare module BABYLON {
  102884. /**
  102885. * A directional light is defined by a direction (what a surprise!).
  102886. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102887. * 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.
  102888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102889. */
  102890. export class DirectionalLight extends ShadowLight {
  102891. private _shadowFrustumSize;
  102892. /**
  102893. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102894. */
  102895. /**
  102896. * Specifies a fix frustum size for the shadow generation.
  102897. */
  102898. shadowFrustumSize: number;
  102899. private _shadowOrthoScale;
  102900. /**
  102901. * Gets the shadow projection scale against the optimal computed one.
  102902. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102903. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102904. */
  102905. /**
  102906. * Sets the shadow projection scale against the optimal computed one.
  102907. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102908. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102909. */
  102910. shadowOrthoScale: number;
  102911. /**
  102912. * Automatically compute the projection matrix to best fit (including all the casters)
  102913. * on each frame.
  102914. */
  102915. autoUpdateExtends: boolean;
  102916. private _orthoLeft;
  102917. private _orthoRight;
  102918. private _orthoTop;
  102919. private _orthoBottom;
  102920. /**
  102921. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102922. * The directional light is emitted from everywhere in the given direction.
  102923. * It can cast shadows.
  102924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102925. * @param name The friendly name of the light
  102926. * @param direction The direction of the light
  102927. * @param scene The scene the light belongs to
  102928. */
  102929. constructor(name: string, direction: Vector3, scene: Scene);
  102930. /**
  102931. * Returns the string "DirectionalLight".
  102932. * @return The class name
  102933. */
  102934. getClassName(): string;
  102935. /**
  102936. * Returns the integer 1.
  102937. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102938. */
  102939. getTypeID(): number;
  102940. /**
  102941. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102942. * Returns the DirectionalLight Shadow projection matrix.
  102943. */
  102944. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102945. /**
  102946. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102947. * Returns the DirectionalLight Shadow projection matrix.
  102948. */
  102949. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102950. /**
  102951. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102952. * Returns the DirectionalLight Shadow projection matrix.
  102953. */
  102954. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102955. protected _buildUniformLayout(): void;
  102956. /**
  102957. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102958. * @param effect The effect to update
  102959. * @param lightIndex The index of the light in the effect to update
  102960. * @returns The directional light
  102961. */
  102962. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102963. /**
  102964. * Gets the minZ used for shadow according to both the scene and the light.
  102965. *
  102966. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102967. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102968. * @param activeCamera The camera we are returning the min for
  102969. * @returns the depth min z
  102970. */
  102971. getDepthMinZ(activeCamera: Camera): number;
  102972. /**
  102973. * Gets the maxZ 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 max for
  102978. * @returns the depth max z
  102979. */
  102980. getDepthMaxZ(activeCamera: Camera): number;
  102981. /**
  102982. * Prepares the list of defines specific to the light type.
  102983. * @param defines the list of defines
  102984. * @param lightIndex defines the index of the light for the effect
  102985. */
  102986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102987. }
  102988. }
  102989. declare module BABYLON {
  102990. /**
  102991. * Class containing static functions to help procedurally build meshes
  102992. */
  102993. export class HemisphereBuilder {
  102994. /**
  102995. * Creates a hemisphere mesh
  102996. * @param name defines the name of the mesh
  102997. * @param options defines the options used to create the mesh
  102998. * @param scene defines the hosting scene
  102999. * @returns the hemisphere mesh
  103000. */
  103001. static CreateHemisphere(name: string, options: {
  103002. segments?: number;
  103003. diameter?: number;
  103004. sideOrientation?: number;
  103005. }, scene: any): Mesh;
  103006. }
  103007. }
  103008. declare module BABYLON {
  103009. /**
  103010. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103011. * These values define a cone of light starting from the position, emitting toward the direction.
  103012. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103013. * and the exponent defines the speed of the decay of the light with distance (reach).
  103014. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103015. */
  103016. export class SpotLight extends ShadowLight {
  103017. private _angle;
  103018. private _innerAngle;
  103019. private _cosHalfAngle;
  103020. private _lightAngleScale;
  103021. private _lightAngleOffset;
  103022. /**
  103023. * Gets the cone angle of the spot light in Radians.
  103024. */
  103025. /**
  103026. * Sets the cone angle of the spot light in Radians.
  103027. */
  103028. angle: number;
  103029. /**
  103030. * Only used in gltf falloff mode, this defines the angle where
  103031. * the directional falloff will start before cutting at angle which could be seen
  103032. * as outer angle.
  103033. */
  103034. /**
  103035. * Only used in gltf falloff mode, this defines the angle where
  103036. * the directional falloff will start before cutting at angle which could be seen
  103037. * as outer angle.
  103038. */
  103039. innerAngle: number;
  103040. private _shadowAngleScale;
  103041. /**
  103042. * Allows scaling the angle of the light for shadow generation only.
  103043. */
  103044. /**
  103045. * Allows scaling the angle of the light for shadow generation only.
  103046. */
  103047. shadowAngleScale: number;
  103048. /**
  103049. * The light decay speed with the distance from the emission spot.
  103050. */
  103051. exponent: number;
  103052. private _projectionTextureMatrix;
  103053. /**
  103054. * Allows reading the projecton texture
  103055. */
  103056. readonly projectionTextureMatrix: Matrix;
  103057. protected _projectionTextureLightNear: number;
  103058. /**
  103059. * Gets the near clip of the Spotlight for texture projection.
  103060. */
  103061. /**
  103062. * Sets the near clip of the Spotlight for texture projection.
  103063. */
  103064. projectionTextureLightNear: number;
  103065. protected _projectionTextureLightFar: number;
  103066. /**
  103067. * Gets the far clip of the Spotlight for texture projection.
  103068. */
  103069. /**
  103070. * Sets the far clip of the Spotlight for texture projection.
  103071. */
  103072. projectionTextureLightFar: number;
  103073. protected _projectionTextureUpDirection: Vector3;
  103074. /**
  103075. * Gets the Up vector of the Spotlight for texture projection.
  103076. */
  103077. /**
  103078. * Sets the Up vector of the Spotlight for texture projection.
  103079. */
  103080. projectionTextureUpDirection: Vector3;
  103081. private _projectionTexture;
  103082. /**
  103083. * Gets the projection texture of the light.
  103084. */
  103085. /**
  103086. * Sets the projection texture of the light.
  103087. */
  103088. projectionTexture: Nullable<BaseTexture>;
  103089. private _projectionTextureViewLightDirty;
  103090. private _projectionTextureProjectionLightDirty;
  103091. private _projectionTextureDirty;
  103092. private _projectionTextureViewTargetVector;
  103093. private _projectionTextureViewLightMatrix;
  103094. private _projectionTextureProjectionLightMatrix;
  103095. private _projectionTextureScalingMatrix;
  103096. /**
  103097. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103098. * It can cast shadows.
  103099. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103100. * @param name The light friendly name
  103101. * @param position The position of the spot light in the scene
  103102. * @param direction The direction of the light in the scene
  103103. * @param angle The cone angle of the light in Radians
  103104. * @param exponent The light decay speed with the distance from the emission spot
  103105. * @param scene The scene the lights belongs to
  103106. */
  103107. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103108. /**
  103109. * Returns the string "SpotLight".
  103110. * @returns the class name
  103111. */
  103112. getClassName(): string;
  103113. /**
  103114. * Returns the integer 2.
  103115. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103116. */
  103117. getTypeID(): number;
  103118. /**
  103119. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103120. */
  103121. protected _setDirection(value: Vector3): void;
  103122. /**
  103123. * Overrides the position setter to recompute the projection texture view light Matrix.
  103124. */
  103125. protected _setPosition(value: Vector3): void;
  103126. /**
  103127. * 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.
  103128. * Returns the SpotLight.
  103129. */
  103130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103131. protected _computeProjectionTextureViewLightMatrix(): void;
  103132. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103133. /**
  103134. * Main function for light texture projection matrix computing.
  103135. */
  103136. protected _computeProjectionTextureMatrix(): void;
  103137. protected _buildUniformLayout(): void;
  103138. private _computeAngleValues;
  103139. /**
  103140. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103141. * @param effect The effect to update
  103142. * @param lightIndex The index of the light in the effect to update
  103143. * @returns The spot light
  103144. */
  103145. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103146. /**
  103147. * Disposes the light and the associated resources.
  103148. */
  103149. dispose(): void;
  103150. /**
  103151. * Prepares the list of defines specific to the light type.
  103152. * @param defines the list of defines
  103153. * @param lightIndex defines the index of the light for the effect
  103154. */
  103155. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103156. }
  103157. }
  103158. declare module BABYLON {
  103159. /**
  103160. * Gizmo that enables viewing a light
  103161. */
  103162. export class LightGizmo extends Gizmo {
  103163. private _lightMesh;
  103164. private _material;
  103165. private cachedPosition;
  103166. private cachedForward;
  103167. /**
  103168. * Creates a LightGizmo
  103169. * @param gizmoLayer The utility layer the gizmo will be added to
  103170. */
  103171. constructor(gizmoLayer?: UtilityLayerRenderer);
  103172. private _light;
  103173. /**
  103174. * The light that the gizmo is attached to
  103175. */
  103176. light: Nullable<Light>;
  103177. /**
  103178. * @hidden
  103179. * Updates the gizmo to match the attached mesh's position/rotation
  103180. */
  103181. protected _update(): void;
  103182. private static _Scale;
  103183. /**
  103184. * Creates the lines for a light mesh
  103185. */
  103186. private static _createLightLines;
  103187. private static _CreateHemisphericLightMesh;
  103188. private static _CreatePointLightMesh;
  103189. private static _CreateSpotLightMesh;
  103190. private static _CreateDirectionalLightMesh;
  103191. }
  103192. }
  103193. declare module BABYLON {
  103194. /** @hidden */
  103195. export var backgroundFragmentDeclaration: {
  103196. name: string;
  103197. shader: string;
  103198. };
  103199. }
  103200. declare module BABYLON {
  103201. /** @hidden */
  103202. export var backgroundUboDeclaration: {
  103203. name: string;
  103204. shader: string;
  103205. };
  103206. }
  103207. declare module BABYLON {
  103208. /** @hidden */
  103209. export var backgroundPixelShader: {
  103210. name: string;
  103211. shader: string;
  103212. };
  103213. }
  103214. declare module BABYLON {
  103215. /** @hidden */
  103216. export var backgroundVertexDeclaration: {
  103217. name: string;
  103218. shader: string;
  103219. };
  103220. }
  103221. declare module BABYLON {
  103222. /** @hidden */
  103223. export var backgroundVertexShader: {
  103224. name: string;
  103225. shader: string;
  103226. };
  103227. }
  103228. declare module BABYLON {
  103229. /**
  103230. * Background material used to create an efficient environement around your scene.
  103231. */
  103232. export class BackgroundMaterial extends PushMaterial {
  103233. /**
  103234. * Standard reflectance value at parallel view angle.
  103235. */
  103236. static StandardReflectance0: number;
  103237. /**
  103238. * Standard reflectance value at grazing angle.
  103239. */
  103240. static StandardReflectance90: number;
  103241. protected _primaryColor: Color3;
  103242. /**
  103243. * Key light Color (multiply against the environement texture)
  103244. */
  103245. primaryColor: Color3;
  103246. protected __perceptualColor: Nullable<Color3>;
  103247. /**
  103248. * Experimental Internal Use Only.
  103249. *
  103250. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103251. * This acts as a helper to set the primary color to a more "human friendly" value.
  103252. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103253. * output color as close as possible from the chosen value.
  103254. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103255. * part of lighting setup.)
  103256. */
  103257. _perceptualColor: Nullable<Color3>;
  103258. protected _primaryColorShadowLevel: float;
  103259. /**
  103260. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103261. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103262. */
  103263. primaryColorShadowLevel: float;
  103264. protected _primaryColorHighlightLevel: float;
  103265. /**
  103266. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103267. * The primary color is used at the level chosen to define what the white area would look.
  103268. */
  103269. primaryColorHighlightLevel: float;
  103270. protected _reflectionTexture: Nullable<BaseTexture>;
  103271. /**
  103272. * Reflection Texture used in the material.
  103273. * Should be author in a specific way for the best result (refer to the documentation).
  103274. */
  103275. reflectionTexture: Nullable<BaseTexture>;
  103276. protected _reflectionBlur: float;
  103277. /**
  103278. * Reflection Texture level of blur.
  103279. *
  103280. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103281. * texture twice.
  103282. */
  103283. reflectionBlur: float;
  103284. protected _diffuseTexture: Nullable<BaseTexture>;
  103285. /**
  103286. * Diffuse Texture used in the material.
  103287. * Should be author in a specific way for the best result (refer to the documentation).
  103288. */
  103289. diffuseTexture: Nullable<BaseTexture>;
  103290. protected _shadowLights: Nullable<IShadowLight[]>;
  103291. /**
  103292. * Specify the list of lights casting shadow on the material.
  103293. * All scene shadow lights will be included if null.
  103294. */
  103295. shadowLights: Nullable<IShadowLight[]>;
  103296. protected _shadowLevel: float;
  103297. /**
  103298. * Helps adjusting the shadow to a softer level if required.
  103299. * 0 means black shadows and 1 means no shadows.
  103300. */
  103301. shadowLevel: float;
  103302. protected _sceneCenter: Vector3;
  103303. /**
  103304. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103305. * It is usually zero but might be interesting to modify according to your setup.
  103306. */
  103307. sceneCenter: Vector3;
  103308. protected _opacityFresnel: boolean;
  103309. /**
  103310. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103311. * This helps ensuring a nice transition when the camera goes under the ground.
  103312. */
  103313. opacityFresnel: boolean;
  103314. protected _reflectionFresnel: boolean;
  103315. /**
  103316. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103317. * This helps adding a mirror texture on the ground.
  103318. */
  103319. reflectionFresnel: boolean;
  103320. protected _reflectionFalloffDistance: number;
  103321. /**
  103322. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103323. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103324. */
  103325. reflectionFalloffDistance: number;
  103326. protected _reflectionAmount: number;
  103327. /**
  103328. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103329. */
  103330. reflectionAmount: number;
  103331. protected _reflectionReflectance0: number;
  103332. /**
  103333. * This specifies the weight of the reflection at grazing angle.
  103334. */
  103335. reflectionReflectance0: number;
  103336. protected _reflectionReflectance90: number;
  103337. /**
  103338. * This specifies the weight of the reflection at a perpendicular point of view.
  103339. */
  103340. reflectionReflectance90: number;
  103341. /**
  103342. * Sets the reflection reflectance fresnel values according to the default standard
  103343. * empirically know to work well :-)
  103344. */
  103345. reflectionStandardFresnelWeight: number;
  103346. protected _useRGBColor: boolean;
  103347. /**
  103348. * Helps to directly use the maps channels instead of their level.
  103349. */
  103350. useRGBColor: boolean;
  103351. protected _enableNoise: boolean;
  103352. /**
  103353. * This helps reducing the banding effect that could occur on the background.
  103354. */
  103355. enableNoise: boolean;
  103356. /**
  103357. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103358. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103359. * Recommended to be keep at 1.0 except for special cases.
  103360. */
  103361. fovMultiplier: number;
  103362. private _fovMultiplier;
  103363. /**
  103364. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103365. */
  103366. useEquirectangularFOV: boolean;
  103367. private _maxSimultaneousLights;
  103368. /**
  103369. * Number of Simultaneous lights allowed on the material.
  103370. */
  103371. maxSimultaneousLights: int;
  103372. /**
  103373. * Default configuration related to image processing available in the Background Material.
  103374. */
  103375. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103376. /**
  103377. * Keep track of the image processing observer to allow dispose and replace.
  103378. */
  103379. private _imageProcessingObserver;
  103380. /**
  103381. * Attaches a new image processing configuration to the PBR Material.
  103382. * @param configuration (if null the scene configuration will be use)
  103383. */
  103384. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103385. /**
  103386. * Gets the image processing configuration used either in this material.
  103387. */
  103388. /**
  103389. * Sets the Default image processing configuration used either in the this material.
  103390. *
  103391. * If sets to null, the scene one is in use.
  103392. */
  103393. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103394. /**
  103395. * Gets wether the color curves effect is enabled.
  103396. */
  103397. /**
  103398. * Sets wether the color curves effect is enabled.
  103399. */
  103400. cameraColorCurvesEnabled: boolean;
  103401. /**
  103402. * Gets wether the color grading effect is enabled.
  103403. */
  103404. /**
  103405. * Gets wether the color grading effect is enabled.
  103406. */
  103407. cameraColorGradingEnabled: boolean;
  103408. /**
  103409. * Gets wether tonemapping is enabled or not.
  103410. */
  103411. /**
  103412. * Sets wether tonemapping is enabled or not
  103413. */
  103414. cameraToneMappingEnabled: boolean;
  103415. /**
  103416. * The camera exposure used on this material.
  103417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103418. * This corresponds to a photographic exposure.
  103419. */
  103420. /**
  103421. * The camera exposure used on this material.
  103422. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103423. * This corresponds to a photographic exposure.
  103424. */
  103425. cameraExposure: float;
  103426. /**
  103427. * Gets The camera contrast used on this material.
  103428. */
  103429. /**
  103430. * Sets The camera contrast used on this material.
  103431. */
  103432. cameraContrast: float;
  103433. /**
  103434. * Gets the Color Grading 2D Lookup Texture.
  103435. */
  103436. /**
  103437. * Sets the Color Grading 2D Lookup Texture.
  103438. */
  103439. cameraColorGradingTexture: Nullable<BaseTexture>;
  103440. /**
  103441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103443. * 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;
  103444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103445. */
  103446. /**
  103447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103449. * 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;
  103450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103451. */
  103452. cameraColorCurves: Nullable<ColorCurves>;
  103453. /**
  103454. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103455. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103456. */
  103457. switchToBGR: boolean;
  103458. private _renderTargets;
  103459. private _reflectionControls;
  103460. private _white;
  103461. private _primaryShadowColor;
  103462. private _primaryHighlightColor;
  103463. /**
  103464. * Instantiates a Background Material in the given scene
  103465. * @param name The friendly name of the material
  103466. * @param scene The scene to add the material to
  103467. */
  103468. constructor(name: string, scene: Scene);
  103469. /**
  103470. * Gets a boolean indicating that current material needs to register RTT
  103471. */
  103472. readonly hasRenderTargetTextures: boolean;
  103473. /**
  103474. * The entire material has been created in order to prevent overdraw.
  103475. * @returns false
  103476. */
  103477. needAlphaTesting(): boolean;
  103478. /**
  103479. * The entire material has been created in order to prevent overdraw.
  103480. * @returns true if blending is enable
  103481. */
  103482. needAlphaBlending(): boolean;
  103483. /**
  103484. * Checks wether the material is ready to be rendered for a given mesh.
  103485. * @param mesh The mesh to render
  103486. * @param subMesh The submesh to check against
  103487. * @param useInstances Specify wether or not the material is used with instances
  103488. * @returns true if all the dependencies are ready (Textures, Effects...)
  103489. */
  103490. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103491. /**
  103492. * Compute the primary color according to the chosen perceptual color.
  103493. */
  103494. private _computePrimaryColorFromPerceptualColor;
  103495. /**
  103496. * Compute the highlights and shadow colors according to their chosen levels.
  103497. */
  103498. private _computePrimaryColors;
  103499. /**
  103500. * Build the uniform buffer used in the material.
  103501. */
  103502. buildUniformLayout(): void;
  103503. /**
  103504. * Unbind the material.
  103505. */
  103506. unbind(): void;
  103507. /**
  103508. * Bind only the world matrix to the material.
  103509. * @param world The world matrix to bind.
  103510. */
  103511. bindOnlyWorldMatrix(world: Matrix): void;
  103512. /**
  103513. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103514. * @param world The world matrix to bind.
  103515. * @param subMesh The submesh to bind for.
  103516. */
  103517. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103518. /**
  103519. * Dispose the material.
  103520. * @param forceDisposeEffect Force disposal of the associated effect.
  103521. * @param forceDisposeTextures Force disposal of the associated textures.
  103522. */
  103523. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103524. /**
  103525. * Clones the material.
  103526. * @param name The cloned name.
  103527. * @returns The cloned material.
  103528. */
  103529. clone(name: string): BackgroundMaterial;
  103530. /**
  103531. * Serializes the current material to its JSON representation.
  103532. * @returns The JSON representation.
  103533. */
  103534. serialize(): any;
  103535. /**
  103536. * Gets the class name of the material
  103537. * @returns "BackgroundMaterial"
  103538. */
  103539. getClassName(): string;
  103540. /**
  103541. * Parse a JSON input to create back a background material.
  103542. * @param source The JSON data to parse
  103543. * @param scene The scene to create the parsed material in
  103544. * @param rootUrl The root url of the assets the material depends upon
  103545. * @returns the instantiated BackgroundMaterial.
  103546. */
  103547. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. /**
  103552. * Represents the different options available during the creation of
  103553. * a Environment helper.
  103554. *
  103555. * This can control the default ground, skybox and image processing setup of your scene.
  103556. */
  103557. export interface IEnvironmentHelperOptions {
  103558. /**
  103559. * Specifies wether or not to create a ground.
  103560. * True by default.
  103561. */
  103562. createGround: boolean;
  103563. /**
  103564. * Specifies the ground size.
  103565. * 15 by default.
  103566. */
  103567. groundSize: number;
  103568. /**
  103569. * The texture used on the ground for the main color.
  103570. * Comes from the BabylonJS CDN by default.
  103571. *
  103572. * Remarks: Can be either a texture or a url.
  103573. */
  103574. groundTexture: string | BaseTexture;
  103575. /**
  103576. * The color mixed in the ground texture by default.
  103577. * BabylonJS clearColor by default.
  103578. */
  103579. groundColor: Color3;
  103580. /**
  103581. * Specifies the ground opacity.
  103582. * 1 by default.
  103583. */
  103584. groundOpacity: number;
  103585. /**
  103586. * Enables the ground to receive shadows.
  103587. * True by default.
  103588. */
  103589. enableGroundShadow: boolean;
  103590. /**
  103591. * Helps preventing the shadow to be fully black on the ground.
  103592. * 0.5 by default.
  103593. */
  103594. groundShadowLevel: number;
  103595. /**
  103596. * Creates a mirror texture attach to the ground.
  103597. * false by default.
  103598. */
  103599. enableGroundMirror: boolean;
  103600. /**
  103601. * Specifies the ground mirror size ratio.
  103602. * 0.3 by default as the default kernel is 64.
  103603. */
  103604. groundMirrorSizeRatio: number;
  103605. /**
  103606. * Specifies the ground mirror blur kernel size.
  103607. * 64 by default.
  103608. */
  103609. groundMirrorBlurKernel: number;
  103610. /**
  103611. * Specifies the ground mirror visibility amount.
  103612. * 1 by default
  103613. */
  103614. groundMirrorAmount: number;
  103615. /**
  103616. * Specifies the ground mirror reflectance weight.
  103617. * This uses the standard weight of the background material to setup the fresnel effect
  103618. * of the mirror.
  103619. * 1 by default.
  103620. */
  103621. groundMirrorFresnelWeight: number;
  103622. /**
  103623. * Specifies the ground mirror Falloff distance.
  103624. * This can helps reducing the size of the reflection.
  103625. * 0 by Default.
  103626. */
  103627. groundMirrorFallOffDistance: number;
  103628. /**
  103629. * Specifies the ground mirror texture type.
  103630. * Unsigned Int by Default.
  103631. */
  103632. groundMirrorTextureType: number;
  103633. /**
  103634. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103635. * the shown objects.
  103636. */
  103637. groundYBias: number;
  103638. /**
  103639. * Specifies wether or not to create a skybox.
  103640. * True by default.
  103641. */
  103642. createSkybox: boolean;
  103643. /**
  103644. * Specifies the skybox size.
  103645. * 20 by default.
  103646. */
  103647. skyboxSize: number;
  103648. /**
  103649. * The texture used on the skybox for the main color.
  103650. * Comes from the BabylonJS CDN by default.
  103651. *
  103652. * Remarks: Can be either a texture or a url.
  103653. */
  103654. skyboxTexture: string | BaseTexture;
  103655. /**
  103656. * The color mixed in the skybox texture by default.
  103657. * BabylonJS clearColor by default.
  103658. */
  103659. skyboxColor: Color3;
  103660. /**
  103661. * The background rotation around the Y axis of the scene.
  103662. * This helps aligning the key lights of your scene with the background.
  103663. * 0 by default.
  103664. */
  103665. backgroundYRotation: number;
  103666. /**
  103667. * Compute automatically the size of the elements to best fit with the scene.
  103668. */
  103669. sizeAuto: boolean;
  103670. /**
  103671. * Default position of the rootMesh if autoSize is not true.
  103672. */
  103673. rootPosition: Vector3;
  103674. /**
  103675. * Sets up the image processing in the scene.
  103676. * true by default.
  103677. */
  103678. setupImageProcessing: boolean;
  103679. /**
  103680. * The texture used as your environment texture in the scene.
  103681. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103682. *
  103683. * Remarks: Can be either a texture or a url.
  103684. */
  103685. environmentTexture: string | BaseTexture;
  103686. /**
  103687. * The value of the exposure to apply to the scene.
  103688. * 0.6 by default if setupImageProcessing is true.
  103689. */
  103690. cameraExposure: number;
  103691. /**
  103692. * The value of the contrast to apply to the scene.
  103693. * 1.6 by default if setupImageProcessing is true.
  103694. */
  103695. cameraContrast: number;
  103696. /**
  103697. * Specifies wether or not tonemapping should be enabled in the scene.
  103698. * true by default if setupImageProcessing is true.
  103699. */
  103700. toneMappingEnabled: boolean;
  103701. }
  103702. /**
  103703. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103704. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103705. * It also helps with the default setup of your imageProcessing configuration.
  103706. */
  103707. export class EnvironmentHelper {
  103708. /**
  103709. * Default ground texture URL.
  103710. */
  103711. private static _groundTextureCDNUrl;
  103712. /**
  103713. * Default skybox texture URL.
  103714. */
  103715. private static _skyboxTextureCDNUrl;
  103716. /**
  103717. * Default environment texture URL.
  103718. */
  103719. private static _environmentTextureCDNUrl;
  103720. /**
  103721. * Creates the default options for the helper.
  103722. */
  103723. private static _getDefaultOptions;
  103724. private _rootMesh;
  103725. /**
  103726. * Gets the root mesh created by the helper.
  103727. */
  103728. readonly rootMesh: Mesh;
  103729. private _skybox;
  103730. /**
  103731. * Gets the skybox created by the helper.
  103732. */
  103733. readonly skybox: Nullable<Mesh>;
  103734. private _skyboxTexture;
  103735. /**
  103736. * Gets the skybox texture created by the helper.
  103737. */
  103738. readonly skyboxTexture: Nullable<BaseTexture>;
  103739. private _skyboxMaterial;
  103740. /**
  103741. * Gets the skybox material created by the helper.
  103742. */
  103743. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103744. private _ground;
  103745. /**
  103746. * Gets the ground mesh created by the helper.
  103747. */
  103748. readonly ground: Nullable<Mesh>;
  103749. private _groundTexture;
  103750. /**
  103751. * Gets the ground texture created by the helper.
  103752. */
  103753. readonly groundTexture: Nullable<BaseTexture>;
  103754. private _groundMirror;
  103755. /**
  103756. * Gets the ground mirror created by the helper.
  103757. */
  103758. readonly groundMirror: Nullable<MirrorTexture>;
  103759. /**
  103760. * Gets the ground mirror render list to helps pushing the meshes
  103761. * you wish in the ground reflection.
  103762. */
  103763. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103764. private _groundMaterial;
  103765. /**
  103766. * Gets the ground material created by the helper.
  103767. */
  103768. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103769. /**
  103770. * Stores the creation options.
  103771. */
  103772. private readonly _scene;
  103773. private _options;
  103774. /**
  103775. * This observable will be notified with any error during the creation of the environment,
  103776. * mainly texture creation errors.
  103777. */
  103778. onErrorObservable: Observable<{
  103779. message?: string;
  103780. exception?: any;
  103781. }>;
  103782. /**
  103783. * constructor
  103784. * @param options Defines the options we want to customize the helper
  103785. * @param scene The scene to add the material to
  103786. */
  103787. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103788. /**
  103789. * Updates the background according to the new options
  103790. * @param options
  103791. */
  103792. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103793. /**
  103794. * Sets the primary color of all the available elements.
  103795. * @param color the main color to affect to the ground and the background
  103796. */
  103797. setMainColor(color: Color3): void;
  103798. /**
  103799. * Setup the image processing according to the specified options.
  103800. */
  103801. private _setupImageProcessing;
  103802. /**
  103803. * Setup the environment texture according to the specified options.
  103804. */
  103805. private _setupEnvironmentTexture;
  103806. /**
  103807. * Setup the background according to the specified options.
  103808. */
  103809. private _setupBackground;
  103810. /**
  103811. * Get the scene sizes according to the setup.
  103812. */
  103813. private _getSceneSize;
  103814. /**
  103815. * Setup the ground according to the specified options.
  103816. */
  103817. private _setupGround;
  103818. /**
  103819. * Setup the ground material according to the specified options.
  103820. */
  103821. private _setupGroundMaterial;
  103822. /**
  103823. * Setup the ground diffuse texture according to the specified options.
  103824. */
  103825. private _setupGroundDiffuseTexture;
  103826. /**
  103827. * Setup the ground mirror texture according to the specified options.
  103828. */
  103829. private _setupGroundMirrorTexture;
  103830. /**
  103831. * Setup the ground to receive the mirror texture.
  103832. */
  103833. private _setupMirrorInGroundMaterial;
  103834. /**
  103835. * Setup the skybox according to the specified options.
  103836. */
  103837. private _setupSkybox;
  103838. /**
  103839. * Setup the skybox material according to the specified options.
  103840. */
  103841. private _setupSkyboxMaterial;
  103842. /**
  103843. * Setup the skybox reflection texture according to the specified options.
  103844. */
  103845. private _setupSkyboxReflectionTexture;
  103846. private _errorHandler;
  103847. /**
  103848. * Dispose all the elements created by the Helper.
  103849. */
  103850. dispose(): void;
  103851. }
  103852. }
  103853. declare module BABYLON {
  103854. /**
  103855. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103856. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103857. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103858. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103859. */
  103860. export class PhotoDome extends TransformNode {
  103861. private _useDirectMapping;
  103862. /**
  103863. * The texture being displayed on the sphere
  103864. */
  103865. protected _photoTexture: Texture;
  103866. /**
  103867. * Gets or sets the texture being displayed on the sphere
  103868. */
  103869. photoTexture: Texture;
  103870. /**
  103871. * Observable raised when an error occured while loading the 360 image
  103872. */
  103873. onLoadErrorObservable: Observable<string>;
  103874. /**
  103875. * The skybox material
  103876. */
  103877. protected _material: BackgroundMaterial;
  103878. /**
  103879. * The surface used for the skybox
  103880. */
  103881. protected _mesh: Mesh;
  103882. /**
  103883. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103884. * Also see the options.resolution property.
  103885. */
  103886. fovMultiplier: number;
  103887. /**
  103888. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103889. * @param name Element's name, child elements will append suffixes for their own names.
  103890. * @param urlsOfPhoto defines the url of the photo to display
  103891. * @param options defines an object containing optional or exposed sub element properties
  103892. * @param onError defines a callback called when an error occured while loading the texture
  103893. */
  103894. constructor(name: string, urlOfPhoto: string, options: {
  103895. resolution?: number;
  103896. size?: number;
  103897. useDirectMapping?: boolean;
  103898. faceForward?: boolean;
  103899. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103900. /**
  103901. * Releases resources associated with this node.
  103902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103904. */
  103905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103906. }
  103907. }
  103908. declare module BABYLON {
  103909. /** @hidden */
  103910. export var rgbdDecodePixelShader: {
  103911. name: string;
  103912. shader: string;
  103913. };
  103914. }
  103915. declare module BABYLON {
  103916. /**
  103917. * Class used to host texture specific utilities
  103918. */
  103919. export class BRDFTextureTools {
  103920. /**
  103921. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103922. * @param texture the texture to expand.
  103923. */
  103924. private static _ExpandDefaultBRDFTexture;
  103925. /**
  103926. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103927. * @param scene defines the hosting scene
  103928. * @returns the environment BRDF texture
  103929. */
  103930. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103931. private static _environmentBRDFBase64Texture;
  103932. }
  103933. }
  103934. declare module BABYLON {
  103935. /**
  103936. * @hidden
  103937. */
  103938. export interface IMaterialClearCoatDefines {
  103939. CLEARCOAT: boolean;
  103940. CLEARCOAT_DEFAULTIOR: boolean;
  103941. CLEARCOAT_TEXTURE: boolean;
  103942. CLEARCOAT_TEXTUREDIRECTUV: number;
  103943. CLEARCOAT_BUMP: boolean;
  103944. CLEARCOAT_BUMPDIRECTUV: number;
  103945. CLEARCOAT_TINT: boolean;
  103946. CLEARCOAT_TINT_TEXTURE: boolean;
  103947. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103948. /** @hidden */
  103949. _areTexturesDirty: boolean;
  103950. }
  103951. /**
  103952. * Define the code related to the clear coat parameters of the pbr material.
  103953. */
  103954. export class PBRClearCoatConfiguration {
  103955. /**
  103956. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103957. * The default fits with a polyurethane material.
  103958. */
  103959. private static readonly _DefaultIndiceOfRefraction;
  103960. private _isEnabled;
  103961. /**
  103962. * Defines if the clear coat is enabled in the material.
  103963. */
  103964. isEnabled: boolean;
  103965. /**
  103966. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103967. */
  103968. intensity: number;
  103969. /**
  103970. * Defines the clear coat layer roughness.
  103971. */
  103972. roughness: number;
  103973. private _indiceOfRefraction;
  103974. /**
  103975. * Defines the indice of refraction of the clear coat.
  103976. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103977. * The default fits with a polyurethane material.
  103978. * Changing the default value is more performance intensive.
  103979. */
  103980. indiceOfRefraction: number;
  103981. private _texture;
  103982. /**
  103983. * Stores the clear coat values in a texture.
  103984. */
  103985. texture: Nullable<BaseTexture>;
  103986. private _bumpTexture;
  103987. /**
  103988. * Define the clear coat specific bump texture.
  103989. */
  103990. bumpTexture: Nullable<BaseTexture>;
  103991. private _isTintEnabled;
  103992. /**
  103993. * Defines if the clear coat tint is enabled in the material.
  103994. */
  103995. isTintEnabled: boolean;
  103996. /**
  103997. * Defines the clear coat tint of the material.
  103998. * This is only use if tint is enabled
  103999. */
  104000. tintColor: Color3;
  104001. /**
  104002. * Defines the distance at which the tint color should be found in the
  104003. * clear coat media.
  104004. * This is only use if tint is enabled
  104005. */
  104006. tintColorAtDistance: number;
  104007. /**
  104008. * Defines the clear coat layer thickness.
  104009. * This is only use if tint is enabled
  104010. */
  104011. tintThickness: number;
  104012. private _tintTexture;
  104013. /**
  104014. * Stores the clear tint values in a texture.
  104015. * rgb is tint
  104016. * a is a thickness factor
  104017. */
  104018. tintTexture: Nullable<BaseTexture>;
  104019. /** @hidden */
  104020. private _internalMarkAllSubMeshesAsTexturesDirty;
  104021. /** @hidden */
  104022. _markAllSubMeshesAsTexturesDirty(): void;
  104023. /**
  104024. * Instantiate a new istance of clear coat configuration.
  104025. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104026. */
  104027. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104028. /**
  104029. * Gets wehter the submesh is ready to be used or not.
  104030. * @param defines the list of "defines" to update.
  104031. * @param scene defines the scene the material belongs to.
  104032. * @param engine defines the engine the material belongs to.
  104033. * @param disableBumpMap defines wether the material disables bump or not.
  104034. * @returns - boolean indicating that the submesh is ready or not.
  104035. */
  104036. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104037. /**
  104038. * Checks to see if a texture is used in the material.
  104039. * @param defines the list of "defines" to update.
  104040. * @param scene defines the scene to the material belongs to.
  104041. */
  104042. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104043. /**
  104044. * Binds the material data.
  104045. * @param uniformBuffer defines the Uniform buffer to fill in.
  104046. * @param scene defines the scene the material belongs to.
  104047. * @param engine defines the engine the material belongs to.
  104048. * @param disableBumpMap defines wether the material disables bump or not.
  104049. * @param isFrozen defines wether the material is frozen or not.
  104050. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104051. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104052. */
  104053. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104054. /**
  104055. * Checks to see if a texture is used in the material.
  104056. * @param texture - Base texture to use.
  104057. * @returns - Boolean specifying if a texture is used in the material.
  104058. */
  104059. hasTexture(texture: BaseTexture): boolean;
  104060. /**
  104061. * Returns an array of the actively used textures.
  104062. * @param activeTextures Array of BaseTextures
  104063. */
  104064. getActiveTextures(activeTextures: BaseTexture[]): void;
  104065. /**
  104066. * Returns the animatable textures.
  104067. * @param animatables Array of animatable textures.
  104068. */
  104069. getAnimatables(animatables: IAnimatable[]): void;
  104070. /**
  104071. * Disposes the resources of the material.
  104072. * @param forceDisposeTextures - Forces the disposal of all textures.
  104073. */
  104074. dispose(forceDisposeTextures?: boolean): void;
  104075. /**
  104076. * Get the current class name of the texture useful for serialization or dynamic coding.
  104077. * @returns "PBRClearCoatConfiguration"
  104078. */
  104079. getClassName(): string;
  104080. /**
  104081. * Add fallbacks to the effect fallbacks list.
  104082. * @param defines defines the Base texture to use.
  104083. * @param fallbacks defines the current fallback list.
  104084. * @param currentRank defines the current fallback rank.
  104085. * @returns the new fallback rank.
  104086. */
  104087. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104088. /**
  104089. * Add the required uniforms to the current list.
  104090. * @param uniforms defines the current uniform list.
  104091. */
  104092. static AddUniforms(uniforms: string[]): void;
  104093. /**
  104094. * Add the required samplers to the current list.
  104095. * @param samplers defines the current sampler list.
  104096. */
  104097. static AddSamplers(samplers: string[]): void;
  104098. /**
  104099. * Add the required uniforms to the current buffer.
  104100. * @param uniformBuffer defines the current uniform buffer.
  104101. */
  104102. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104103. /**
  104104. * Makes a duplicate of the current configuration into another one.
  104105. * @param clearCoatConfiguration define the config where to copy the info
  104106. */
  104107. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104108. /**
  104109. * Serializes this clear coat configuration.
  104110. * @returns - An object with the serialized config.
  104111. */
  104112. serialize(): any;
  104113. /**
  104114. * Parses a Clear Coat Configuration from a serialized object.
  104115. * @param source - Serialized object.
  104116. */
  104117. parse(source: any): void;
  104118. }
  104119. }
  104120. declare module BABYLON {
  104121. /**
  104122. * @hidden
  104123. */
  104124. export interface IMaterialAnisotropicDefines {
  104125. ANISOTROPIC: boolean;
  104126. ANISOTROPIC_TEXTURE: boolean;
  104127. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104128. MAINUV1: boolean;
  104129. _areTexturesDirty: boolean;
  104130. _needUVs: boolean;
  104131. }
  104132. /**
  104133. * Define the code related to the anisotropic parameters of the pbr material.
  104134. */
  104135. export class PBRAnisotropicConfiguration {
  104136. private _isEnabled;
  104137. /**
  104138. * Defines if the anisotropy is enabled in the material.
  104139. */
  104140. isEnabled: boolean;
  104141. /**
  104142. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104143. */
  104144. intensity: number;
  104145. /**
  104146. * Defines if the effect is along the tangents, bitangents or in between.
  104147. * By default, the effect is "strectching" the highlights along the tangents.
  104148. */
  104149. direction: Vector2;
  104150. private _texture;
  104151. /**
  104152. * Stores the anisotropy values in a texture.
  104153. * rg is direction (like normal from -1 to 1)
  104154. * b is a intensity
  104155. */
  104156. texture: Nullable<BaseTexture>;
  104157. /** @hidden */
  104158. private _internalMarkAllSubMeshesAsTexturesDirty;
  104159. /** @hidden */
  104160. _markAllSubMeshesAsTexturesDirty(): void;
  104161. /**
  104162. * Instantiate a new istance of anisotropy configuration.
  104163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104164. */
  104165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104166. /**
  104167. * Specifies that the submesh is ready to be used.
  104168. * @param defines the list of "defines" to update.
  104169. * @param scene defines the scene the material belongs to.
  104170. * @returns - boolean indicating that the submesh is ready or not.
  104171. */
  104172. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104173. /**
  104174. * Checks to see if a texture is used in the material.
  104175. * @param defines the list of "defines" to update.
  104176. * @param mesh the mesh we are preparing the defines for.
  104177. * @param scene defines the scene the material belongs to.
  104178. */
  104179. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104180. /**
  104181. * Binds the material data.
  104182. * @param uniformBuffer defines the Uniform buffer to fill in.
  104183. * @param scene defines the scene the material belongs to.
  104184. * @param isFrozen defines wether the material is frozen or not.
  104185. */
  104186. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104187. /**
  104188. * Checks to see if a texture is used in the material.
  104189. * @param texture - Base texture to use.
  104190. * @returns - Boolean specifying if a texture is used in the material.
  104191. */
  104192. hasTexture(texture: BaseTexture): boolean;
  104193. /**
  104194. * Returns an array of the actively used textures.
  104195. * @param activeTextures Array of BaseTextures
  104196. */
  104197. getActiveTextures(activeTextures: BaseTexture[]): void;
  104198. /**
  104199. * Returns the animatable textures.
  104200. * @param animatables Array of animatable textures.
  104201. */
  104202. getAnimatables(animatables: IAnimatable[]): void;
  104203. /**
  104204. * Disposes the resources of the material.
  104205. * @param forceDisposeTextures - Forces the disposal of all textures.
  104206. */
  104207. dispose(forceDisposeTextures?: boolean): void;
  104208. /**
  104209. * Get the current class name of the texture useful for serialization or dynamic coding.
  104210. * @returns "PBRAnisotropicConfiguration"
  104211. */
  104212. getClassName(): string;
  104213. /**
  104214. * Add fallbacks to the effect fallbacks list.
  104215. * @param defines defines the Base texture to use.
  104216. * @param fallbacks defines the current fallback list.
  104217. * @param currentRank defines the current fallback rank.
  104218. * @returns the new fallback rank.
  104219. */
  104220. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104221. /**
  104222. * Add the required uniforms to the current list.
  104223. * @param uniforms defines the current uniform list.
  104224. */
  104225. static AddUniforms(uniforms: string[]): void;
  104226. /**
  104227. * Add the required uniforms to the current buffer.
  104228. * @param uniformBuffer defines the current uniform buffer.
  104229. */
  104230. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104231. /**
  104232. * Add the required samplers to the current list.
  104233. * @param samplers defines the current sampler list.
  104234. */
  104235. static AddSamplers(samplers: string[]): void;
  104236. /**
  104237. * Makes a duplicate of the current configuration into another one.
  104238. * @param anisotropicConfiguration define the config where to copy the info
  104239. */
  104240. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104241. /**
  104242. * Serializes this anisotropy configuration.
  104243. * @returns - An object with the serialized config.
  104244. */
  104245. serialize(): any;
  104246. /**
  104247. * Parses a anisotropy Configuration from a serialized object.
  104248. * @param source - Serialized object.
  104249. */
  104250. parse(source: any): void;
  104251. }
  104252. }
  104253. declare module BABYLON {
  104254. /**
  104255. * @hidden
  104256. */
  104257. export interface IMaterialBRDFDefines {
  104258. BRDF_V_HEIGHT_CORRELATED: boolean;
  104259. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104260. SPHERICAL_HARMONICS: boolean;
  104261. /** @hidden */
  104262. _areMiscDirty: boolean;
  104263. }
  104264. /**
  104265. * Define the code related to the BRDF parameters of the pbr material.
  104266. */
  104267. export class PBRBRDFConfiguration {
  104268. /**
  104269. * Default value used for the energy conservation.
  104270. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104271. */
  104272. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104273. /**
  104274. * Default value used for the Smith Visibility Height Correlated mode.
  104275. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104276. */
  104277. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104278. /**
  104279. * Default value used for the IBL diffuse part.
  104280. * This can help switching back to the polynomials mode globally which is a tiny bit
  104281. * less GPU intensive at the drawback of a lower quality.
  104282. */
  104283. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104284. private _useEnergyConservation;
  104285. /**
  104286. * Defines if the material uses energy conservation.
  104287. */
  104288. useEnergyConservation: boolean;
  104289. private _useSmithVisibilityHeightCorrelated;
  104290. /**
  104291. * LEGACY Mode set to false
  104292. * Defines if the material uses height smith correlated visibility term.
  104293. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104294. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104295. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104296. * Not relying on height correlated will also disable energy conservation.
  104297. */
  104298. useSmithVisibilityHeightCorrelated: boolean;
  104299. private _useSphericalHarmonics;
  104300. /**
  104301. * LEGACY Mode set to false
  104302. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104303. * diffuse part of the IBL.
  104304. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104305. * to the ground truth.
  104306. */
  104307. useSphericalHarmonics: boolean;
  104308. /** @hidden */
  104309. private _internalMarkAllSubMeshesAsMiscDirty;
  104310. /** @hidden */
  104311. _markAllSubMeshesAsMiscDirty(): void;
  104312. /**
  104313. * Instantiate a new istance of clear coat configuration.
  104314. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104315. */
  104316. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104317. /**
  104318. * Checks to see if a texture is used in the material.
  104319. * @param defines the list of "defines" to update.
  104320. */
  104321. prepareDefines(defines: IMaterialBRDFDefines): void;
  104322. /**
  104323. * Get the current class name of the texture useful for serialization or dynamic coding.
  104324. * @returns "PBRClearCoatConfiguration"
  104325. */
  104326. getClassName(): string;
  104327. /**
  104328. * Makes a duplicate of the current configuration into another one.
  104329. * @param brdfConfiguration define the config where to copy the info
  104330. */
  104331. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104332. /**
  104333. * Serializes this BRDF configuration.
  104334. * @returns - An object with the serialized config.
  104335. */
  104336. serialize(): any;
  104337. /**
  104338. * Parses a BRDF Configuration from a serialized object.
  104339. * @param source - Serialized object.
  104340. */
  104341. parse(source: any): void;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * @hidden
  104347. */
  104348. export interface IMaterialSheenDefines {
  104349. SHEEN: boolean;
  104350. SHEEN_TEXTURE: boolean;
  104351. SHEEN_TEXTUREDIRECTUV: number;
  104352. SHEEN_LINKWITHALBEDO: boolean;
  104353. /** @hidden */
  104354. _areTexturesDirty: boolean;
  104355. }
  104356. /**
  104357. * Define the code related to the Sheen parameters of the pbr material.
  104358. */
  104359. export class PBRSheenConfiguration {
  104360. private _isEnabled;
  104361. /**
  104362. * Defines if the material uses sheen.
  104363. */
  104364. isEnabled: boolean;
  104365. private _linkSheenWithAlbedo;
  104366. /**
  104367. * Defines if the sheen is linked to the sheen color.
  104368. */
  104369. linkSheenWithAlbedo: boolean;
  104370. /**
  104371. * Defines the sheen intensity.
  104372. */
  104373. intensity: number;
  104374. /**
  104375. * Defines the sheen color.
  104376. */
  104377. color: Color3;
  104378. private _texture;
  104379. /**
  104380. * Stores the sheen tint values in a texture.
  104381. * rgb is tint
  104382. * a is a intensity
  104383. */
  104384. texture: Nullable<BaseTexture>;
  104385. /** @hidden */
  104386. private _internalMarkAllSubMeshesAsTexturesDirty;
  104387. /** @hidden */
  104388. _markAllSubMeshesAsTexturesDirty(): void;
  104389. /**
  104390. * Instantiate a new istance of clear coat configuration.
  104391. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104392. */
  104393. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104394. /**
  104395. * Specifies that the submesh is ready to be used.
  104396. * @param defines the list of "defines" to update.
  104397. * @param scene defines the scene the material belongs to.
  104398. * @returns - boolean indicating that the submesh is ready or not.
  104399. */
  104400. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104401. /**
  104402. * Checks to see if a texture is used in the material.
  104403. * @param defines the list of "defines" to update.
  104404. * @param scene defines the scene the material belongs to.
  104405. */
  104406. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104407. /**
  104408. * Binds the material data.
  104409. * @param uniformBuffer defines the Uniform buffer to fill in.
  104410. * @param scene defines the scene the material belongs to.
  104411. * @param isFrozen defines wether the material is frozen or not.
  104412. */
  104413. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104414. /**
  104415. * Checks to see if a texture is used in the material.
  104416. * @param texture - Base texture to use.
  104417. * @returns - Boolean specifying if a texture is used in the material.
  104418. */
  104419. hasTexture(texture: BaseTexture): boolean;
  104420. /**
  104421. * Returns an array of the actively used textures.
  104422. * @param activeTextures Array of BaseTextures
  104423. */
  104424. getActiveTextures(activeTextures: BaseTexture[]): void;
  104425. /**
  104426. * Returns the animatable textures.
  104427. * @param animatables Array of animatable textures.
  104428. */
  104429. getAnimatables(animatables: IAnimatable[]): void;
  104430. /**
  104431. * Disposes the resources of the material.
  104432. * @param forceDisposeTextures - Forces the disposal of all textures.
  104433. */
  104434. dispose(forceDisposeTextures?: boolean): void;
  104435. /**
  104436. * Get the current class name of the texture useful for serialization or dynamic coding.
  104437. * @returns "PBRSheenConfiguration"
  104438. */
  104439. getClassName(): string;
  104440. /**
  104441. * Add fallbacks to the effect fallbacks list.
  104442. * @param defines defines the Base texture to use.
  104443. * @param fallbacks defines the current fallback list.
  104444. * @param currentRank defines the current fallback rank.
  104445. * @returns the new fallback rank.
  104446. */
  104447. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104448. /**
  104449. * Add the required uniforms to the current list.
  104450. * @param uniforms defines the current uniform list.
  104451. */
  104452. static AddUniforms(uniforms: string[]): void;
  104453. /**
  104454. * Add the required uniforms to the current buffer.
  104455. * @param uniformBuffer defines the current uniform buffer.
  104456. */
  104457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104458. /**
  104459. * Add the required samplers to the current list.
  104460. * @param samplers defines the current sampler list.
  104461. */
  104462. static AddSamplers(samplers: string[]): void;
  104463. /**
  104464. * Makes a duplicate of the current configuration into another one.
  104465. * @param sheenConfiguration define the config where to copy the info
  104466. */
  104467. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104468. /**
  104469. * Serializes this BRDF configuration.
  104470. * @returns - An object with the serialized config.
  104471. */
  104472. serialize(): any;
  104473. /**
  104474. * Parses a Sheen Configuration from a serialized object.
  104475. * @param source - Serialized object.
  104476. */
  104477. parse(source: any): void;
  104478. }
  104479. }
  104480. declare module BABYLON {
  104481. /**
  104482. * @hidden
  104483. */
  104484. export interface IMaterialSubSurfaceDefines {
  104485. SUBSURFACE: boolean;
  104486. SS_REFRACTION: boolean;
  104487. SS_TRANSLUCENCY: boolean;
  104488. SS_SCATERRING: boolean;
  104489. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104490. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104491. SS_REFRACTIONMAP_3D: boolean;
  104492. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104493. SS_LODINREFRACTIONALPHA: boolean;
  104494. SS_GAMMAREFRACTION: boolean;
  104495. SS_RGBDREFRACTION: boolean;
  104496. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104497. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104498. /** @hidden */
  104499. _areTexturesDirty: boolean;
  104500. }
  104501. /**
  104502. * Define the code related to the sub surface parameters of the pbr material.
  104503. */
  104504. export class PBRSubSurfaceConfiguration {
  104505. private _isRefractionEnabled;
  104506. /**
  104507. * Defines if the refraction is enabled in the material.
  104508. */
  104509. isRefractionEnabled: boolean;
  104510. private _isTranslucencyEnabled;
  104511. /**
  104512. * Defines if the translucency is enabled in the material.
  104513. */
  104514. isTranslucencyEnabled: boolean;
  104515. private _isScatteringEnabled;
  104516. /**
  104517. * Defines the refraction intensity of the material.
  104518. * The refraction when enabled replaces the Diffuse part of the material.
  104519. * The intensity helps transitionning between diffuse and refraction.
  104520. */
  104521. refractionIntensity: number;
  104522. /**
  104523. * Defines the translucency intensity of the material.
  104524. * When translucency has been enabled, this defines how much of the "translucency"
  104525. * is addded to the diffuse part of the material.
  104526. */
  104527. translucencyIntensity: number;
  104528. /**
  104529. * Defines the scattering intensity of the material.
  104530. * When scattering has been enabled, this defines how much of the "scattered light"
  104531. * is addded to the diffuse part of the material.
  104532. */
  104533. scatteringIntensity: number;
  104534. private _thicknessTexture;
  104535. /**
  104536. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104537. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104538. * 0 would mean minimumThickness
  104539. * 1 would mean maximumThickness
  104540. * The other channels might be use as a mask to vary the different effects intensity.
  104541. */
  104542. thicknessTexture: Nullable<BaseTexture>;
  104543. private _refractionTexture;
  104544. /**
  104545. * Defines the texture to use for refraction.
  104546. */
  104547. refractionTexture: Nullable<BaseTexture>;
  104548. private _indexOfRefraction;
  104549. /**
  104550. * Defines the indice of refraction used in the material.
  104551. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104552. */
  104553. indexOfRefraction: number;
  104554. private _invertRefractionY;
  104555. /**
  104556. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104557. */
  104558. invertRefractionY: boolean;
  104559. private _linkRefractionWithTransparency;
  104560. /**
  104561. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104562. * Materials half opaque for instance using refraction could benefit from this control.
  104563. */
  104564. linkRefractionWithTransparency: boolean;
  104565. /**
  104566. * Defines the minimum thickness stored in the thickness map.
  104567. * If no thickness map is defined, this value will be used to simulate thickness.
  104568. */
  104569. minimumThickness: number;
  104570. /**
  104571. * Defines the maximum thickness stored in the thickness map.
  104572. */
  104573. maximumThickness: number;
  104574. /**
  104575. * Defines the volume tint of the material.
  104576. * This is used for both translucency and scattering.
  104577. */
  104578. tintColor: Color3;
  104579. /**
  104580. * Defines the distance at which the tint color should be found in the media.
  104581. * This is used for refraction only.
  104582. */
  104583. tintColorAtDistance: number;
  104584. /**
  104585. * Defines how far each channel transmit through the media.
  104586. * It is defined as a color to simplify it selection.
  104587. */
  104588. diffusionDistance: Color3;
  104589. private _useMaskFromThicknessTexture;
  104590. /**
  104591. * Stores the intensity of the different subsurface effects in the thickness texture.
  104592. * * the green channel is the translucency intensity.
  104593. * * the blue channel is the scattering intensity.
  104594. * * the alpha channel is the refraction intensity.
  104595. */
  104596. useMaskFromThicknessTexture: boolean;
  104597. /** @hidden */
  104598. private _internalMarkAllSubMeshesAsTexturesDirty;
  104599. /** @hidden */
  104600. _markAllSubMeshesAsTexturesDirty(): void;
  104601. /**
  104602. * Instantiate a new istance of sub surface configuration.
  104603. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104604. */
  104605. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104606. /**
  104607. * Gets wehter the submesh is ready to be used or not.
  104608. * @param defines the list of "defines" to update.
  104609. * @param scene defines the scene the material belongs to.
  104610. * @returns - boolean indicating that the submesh is ready or not.
  104611. */
  104612. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104613. /**
  104614. * Checks to see if a texture is used in the material.
  104615. * @param defines the list of "defines" to update.
  104616. * @param scene defines the scene to the material belongs to.
  104617. */
  104618. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104619. /**
  104620. * Binds the material data.
  104621. * @param uniformBuffer defines the Uniform buffer to fill in.
  104622. * @param scene defines the scene the material belongs to.
  104623. * @param engine defines the engine the material belongs to.
  104624. * @param isFrozen defines wether the material is frozen or not.
  104625. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104626. */
  104627. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104628. /**
  104629. * Unbinds the material from the mesh.
  104630. * @param activeEffect defines the effect that should be unbound from.
  104631. * @returns true if unbound, otherwise false
  104632. */
  104633. unbind(activeEffect: Effect): boolean;
  104634. /**
  104635. * Returns the texture used for refraction or null if none is used.
  104636. * @param scene defines the scene the material belongs to.
  104637. * @returns - Refraction texture if present. If no refraction texture and refraction
  104638. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104639. */
  104640. private _getRefractionTexture;
  104641. /**
  104642. * Returns true if alpha blending should be disabled.
  104643. */
  104644. readonly disableAlphaBlending: boolean;
  104645. /**
  104646. * Fills the list of render target textures.
  104647. * @param renderTargets the list of render targets to update
  104648. */
  104649. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104650. /**
  104651. * Checks to see if a texture is used in the material.
  104652. * @param texture - Base texture to use.
  104653. * @returns - Boolean specifying if a texture is used in the material.
  104654. */
  104655. hasTexture(texture: BaseTexture): boolean;
  104656. /**
  104657. * Gets a boolean indicating that current material needs to register RTT
  104658. * @returns true if this uses a render target otherwise false.
  104659. */
  104660. hasRenderTargetTextures(): boolean;
  104661. /**
  104662. * Returns an array of the actively used textures.
  104663. * @param activeTextures Array of BaseTextures
  104664. */
  104665. getActiveTextures(activeTextures: BaseTexture[]): void;
  104666. /**
  104667. * Returns the animatable textures.
  104668. * @param animatables Array of animatable textures.
  104669. */
  104670. getAnimatables(animatables: IAnimatable[]): void;
  104671. /**
  104672. * Disposes the resources of the material.
  104673. * @param forceDisposeTextures - Forces the disposal of all textures.
  104674. */
  104675. dispose(forceDisposeTextures?: boolean): void;
  104676. /**
  104677. * Get the current class name of the texture useful for serialization or dynamic coding.
  104678. * @returns "PBRSubSurfaceConfiguration"
  104679. */
  104680. getClassName(): string;
  104681. /**
  104682. * Add fallbacks to the effect fallbacks list.
  104683. * @param defines defines the Base texture to use.
  104684. * @param fallbacks defines the current fallback list.
  104685. * @param currentRank defines the current fallback rank.
  104686. * @returns the new fallback rank.
  104687. */
  104688. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104689. /**
  104690. * Add the required uniforms to the current list.
  104691. * @param uniforms defines the current uniform list.
  104692. */
  104693. static AddUniforms(uniforms: string[]): void;
  104694. /**
  104695. * Add the required samplers to the current list.
  104696. * @param samplers defines the current sampler list.
  104697. */
  104698. static AddSamplers(samplers: string[]): void;
  104699. /**
  104700. * Add the required uniforms to the current buffer.
  104701. * @param uniformBuffer defines the current uniform buffer.
  104702. */
  104703. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104704. /**
  104705. * Makes a duplicate of the current configuration into another one.
  104706. * @param configuration define the config where to copy the info
  104707. */
  104708. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104709. /**
  104710. * Serializes this Sub Surface configuration.
  104711. * @returns - An object with the serialized config.
  104712. */
  104713. serialize(): any;
  104714. /**
  104715. * Parses a Sub Surface Configuration from a serialized object.
  104716. * @param source - Serialized object.
  104717. */
  104718. parse(source: any): void;
  104719. }
  104720. }
  104721. declare module BABYLON {
  104722. /** @hidden */
  104723. export var pbrFragmentDeclaration: {
  104724. name: string;
  104725. shader: string;
  104726. };
  104727. }
  104728. declare module BABYLON {
  104729. /** @hidden */
  104730. export var pbrUboDeclaration: {
  104731. name: string;
  104732. shader: string;
  104733. };
  104734. }
  104735. declare module BABYLON {
  104736. /** @hidden */
  104737. export var pbrFragmentExtraDeclaration: {
  104738. name: string;
  104739. shader: string;
  104740. };
  104741. }
  104742. declare module BABYLON {
  104743. /** @hidden */
  104744. export var pbrFragmentSamplersDeclaration: {
  104745. name: string;
  104746. shader: string;
  104747. };
  104748. }
  104749. declare module BABYLON {
  104750. /** @hidden */
  104751. export var pbrHelperFunctions: {
  104752. name: string;
  104753. shader: string;
  104754. };
  104755. }
  104756. declare module BABYLON {
  104757. /** @hidden */
  104758. export var harmonicsFunctions: {
  104759. name: string;
  104760. shader: string;
  104761. };
  104762. }
  104763. declare module BABYLON {
  104764. /** @hidden */
  104765. export var pbrDirectLightingSetupFunctions: {
  104766. name: string;
  104767. shader: string;
  104768. };
  104769. }
  104770. declare module BABYLON {
  104771. /** @hidden */
  104772. export var pbrDirectLightingFalloffFunctions: {
  104773. name: string;
  104774. shader: string;
  104775. };
  104776. }
  104777. declare module BABYLON {
  104778. /** @hidden */
  104779. export var pbrBRDFFunctions: {
  104780. name: string;
  104781. shader: string;
  104782. };
  104783. }
  104784. declare module BABYLON {
  104785. /** @hidden */
  104786. export var pbrDirectLightingFunctions: {
  104787. name: string;
  104788. shader: string;
  104789. };
  104790. }
  104791. declare module BABYLON {
  104792. /** @hidden */
  104793. export var pbrIBLFunctions: {
  104794. name: string;
  104795. shader: string;
  104796. };
  104797. }
  104798. declare module BABYLON {
  104799. /** @hidden */
  104800. export var pbrDebug: {
  104801. name: string;
  104802. shader: string;
  104803. };
  104804. }
  104805. declare module BABYLON {
  104806. /** @hidden */
  104807. export var pbrPixelShader: {
  104808. name: string;
  104809. shader: string;
  104810. };
  104811. }
  104812. declare module BABYLON {
  104813. /** @hidden */
  104814. export var pbrVertexDeclaration: {
  104815. name: string;
  104816. shader: string;
  104817. };
  104818. }
  104819. declare module BABYLON {
  104820. /** @hidden */
  104821. export var pbrVertexShader: {
  104822. name: string;
  104823. shader: string;
  104824. };
  104825. }
  104826. declare module BABYLON {
  104827. /**
  104828. * Manages the defines for the PBR Material.
  104829. * @hidden
  104830. */
  104831. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104832. PBR: boolean;
  104833. MAINUV1: boolean;
  104834. MAINUV2: boolean;
  104835. UV1: boolean;
  104836. UV2: boolean;
  104837. ALBEDO: boolean;
  104838. ALBEDODIRECTUV: number;
  104839. VERTEXCOLOR: boolean;
  104840. AMBIENT: boolean;
  104841. AMBIENTDIRECTUV: number;
  104842. AMBIENTINGRAYSCALE: boolean;
  104843. OPACITY: boolean;
  104844. VERTEXALPHA: boolean;
  104845. OPACITYDIRECTUV: number;
  104846. OPACITYRGB: boolean;
  104847. ALPHATEST: boolean;
  104848. DEPTHPREPASS: boolean;
  104849. ALPHABLEND: boolean;
  104850. ALPHAFROMALBEDO: boolean;
  104851. ALPHATESTVALUE: string;
  104852. SPECULAROVERALPHA: boolean;
  104853. RADIANCEOVERALPHA: boolean;
  104854. ALPHAFRESNEL: boolean;
  104855. LINEARALPHAFRESNEL: boolean;
  104856. PREMULTIPLYALPHA: boolean;
  104857. EMISSIVE: boolean;
  104858. EMISSIVEDIRECTUV: number;
  104859. REFLECTIVITY: boolean;
  104860. REFLECTIVITYDIRECTUV: number;
  104861. SPECULARTERM: boolean;
  104862. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104863. MICROSURFACEAUTOMATIC: boolean;
  104864. LODBASEDMICROSFURACE: boolean;
  104865. MICROSURFACEMAP: boolean;
  104866. MICROSURFACEMAPDIRECTUV: number;
  104867. METALLICWORKFLOW: boolean;
  104868. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104869. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104870. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104871. AOSTOREINMETALMAPRED: boolean;
  104872. ENVIRONMENTBRDF: boolean;
  104873. ENVIRONMENTBRDF_RGBD: boolean;
  104874. NORMAL: boolean;
  104875. TANGENT: boolean;
  104876. BUMP: boolean;
  104877. BUMPDIRECTUV: number;
  104878. OBJECTSPACE_NORMALMAP: boolean;
  104879. PARALLAX: boolean;
  104880. PARALLAXOCCLUSION: boolean;
  104881. NORMALXYSCALE: boolean;
  104882. LIGHTMAP: boolean;
  104883. LIGHTMAPDIRECTUV: number;
  104884. USELIGHTMAPASSHADOWMAP: boolean;
  104885. GAMMALIGHTMAP: boolean;
  104886. REFLECTION: boolean;
  104887. REFLECTIONMAP_3D: boolean;
  104888. REFLECTIONMAP_SPHERICAL: boolean;
  104889. REFLECTIONMAP_PLANAR: boolean;
  104890. REFLECTIONMAP_CUBIC: boolean;
  104891. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104892. REFLECTIONMAP_PROJECTION: boolean;
  104893. REFLECTIONMAP_SKYBOX: boolean;
  104894. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104895. REFLECTIONMAP_EXPLICIT: boolean;
  104896. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104897. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104898. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104899. INVERTCUBICMAP: boolean;
  104900. USESPHERICALFROMREFLECTIONMAP: boolean;
  104901. SPHERICAL_HARMONICS: boolean;
  104902. USESPHERICALINVERTEX: boolean;
  104903. REFLECTIONMAP_OPPOSITEZ: boolean;
  104904. LODINREFLECTIONALPHA: boolean;
  104905. GAMMAREFLECTION: boolean;
  104906. RGBDREFLECTION: boolean;
  104907. RADIANCEOCCLUSION: boolean;
  104908. HORIZONOCCLUSION: boolean;
  104909. INSTANCES: boolean;
  104910. NUM_BONE_INFLUENCERS: number;
  104911. BonesPerMesh: number;
  104912. BONETEXTURE: boolean;
  104913. NONUNIFORMSCALING: boolean;
  104914. MORPHTARGETS: boolean;
  104915. MORPHTARGETS_NORMAL: boolean;
  104916. MORPHTARGETS_TANGENT: boolean;
  104917. NUM_MORPH_INFLUENCERS: number;
  104918. IMAGEPROCESSING: boolean;
  104919. VIGNETTE: boolean;
  104920. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104921. VIGNETTEBLENDMODEOPAQUE: boolean;
  104922. TONEMAPPING: boolean;
  104923. TONEMAPPING_ACES: boolean;
  104924. CONTRAST: boolean;
  104925. COLORCURVES: boolean;
  104926. COLORGRADING: boolean;
  104927. COLORGRADING3D: boolean;
  104928. SAMPLER3DGREENDEPTH: boolean;
  104929. SAMPLER3DBGRMAP: boolean;
  104930. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104931. EXPOSURE: boolean;
  104932. MULTIVIEW: boolean;
  104933. USEPHYSICALLIGHTFALLOFF: boolean;
  104934. USEGLTFLIGHTFALLOFF: boolean;
  104935. TWOSIDEDLIGHTING: boolean;
  104936. SHADOWFLOAT: boolean;
  104937. CLIPPLANE: boolean;
  104938. CLIPPLANE2: boolean;
  104939. CLIPPLANE3: boolean;
  104940. CLIPPLANE4: boolean;
  104941. POINTSIZE: boolean;
  104942. FOG: boolean;
  104943. LOGARITHMICDEPTH: boolean;
  104944. FORCENORMALFORWARD: boolean;
  104945. SPECULARAA: boolean;
  104946. CLEARCOAT: boolean;
  104947. CLEARCOAT_DEFAULTIOR: boolean;
  104948. CLEARCOAT_TEXTURE: boolean;
  104949. CLEARCOAT_TEXTUREDIRECTUV: number;
  104950. CLEARCOAT_BUMP: boolean;
  104951. CLEARCOAT_BUMPDIRECTUV: number;
  104952. CLEARCOAT_TINT: boolean;
  104953. CLEARCOAT_TINT_TEXTURE: boolean;
  104954. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104955. ANISOTROPIC: boolean;
  104956. ANISOTROPIC_TEXTURE: boolean;
  104957. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104958. BRDF_V_HEIGHT_CORRELATED: boolean;
  104959. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104960. SHEEN: boolean;
  104961. SHEEN_TEXTURE: boolean;
  104962. SHEEN_TEXTUREDIRECTUV: number;
  104963. SHEEN_LINKWITHALBEDO: boolean;
  104964. SUBSURFACE: boolean;
  104965. SS_REFRACTION: boolean;
  104966. SS_TRANSLUCENCY: boolean;
  104967. SS_SCATERRING: boolean;
  104968. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104969. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104970. SS_REFRACTIONMAP_3D: boolean;
  104971. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104972. SS_LODINREFRACTIONALPHA: boolean;
  104973. SS_GAMMAREFRACTION: boolean;
  104974. SS_RGBDREFRACTION: boolean;
  104975. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104976. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104977. UNLIT: boolean;
  104978. DEBUGMODE: number;
  104979. /**
  104980. * Initializes the PBR Material defines.
  104981. */
  104982. constructor();
  104983. /**
  104984. * Resets the PBR Material defines.
  104985. */
  104986. reset(): void;
  104987. }
  104988. /**
  104989. * The Physically based material base class of BJS.
  104990. *
  104991. * This offers the main features of a standard PBR material.
  104992. * For more information, please refer to the documentation :
  104993. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104994. */
  104995. export abstract class PBRBaseMaterial extends PushMaterial {
  104996. /**
  104997. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104998. */
  104999. static readonly PBRMATERIAL_OPAQUE: number;
  105000. /**
  105001. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105002. */
  105003. static readonly PBRMATERIAL_ALPHATEST: number;
  105004. /**
  105005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105006. */
  105007. static readonly PBRMATERIAL_ALPHABLEND: number;
  105008. /**
  105009. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105010. * They are also discarded below the alpha cutoff threshold to improve performances.
  105011. */
  105012. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105013. /**
  105014. * Defines the default value of how much AO map is occluding the analytical lights
  105015. * (point spot...).
  105016. */
  105017. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105018. /**
  105019. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105020. */
  105021. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105022. /**
  105023. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105024. * to enhance interoperability with other engines.
  105025. */
  105026. static readonly LIGHTFALLOFF_GLTF: number;
  105027. /**
  105028. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105029. * to enhance interoperability with other materials.
  105030. */
  105031. static readonly LIGHTFALLOFF_STANDARD: number;
  105032. /**
  105033. * Intensity of the direct lights e.g. the four lights available in your scene.
  105034. * This impacts both the direct diffuse and specular highlights.
  105035. */
  105036. protected _directIntensity: number;
  105037. /**
  105038. * Intensity of the emissive part of the material.
  105039. * This helps controlling the emissive effect without modifying the emissive color.
  105040. */
  105041. protected _emissiveIntensity: number;
  105042. /**
  105043. * Intensity of the environment e.g. how much the environment will light the object
  105044. * either through harmonics for rough material or through the refelction for shiny ones.
  105045. */
  105046. protected _environmentIntensity: number;
  105047. /**
  105048. * This is a special control allowing the reduction of the specular highlights coming from the
  105049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105050. */
  105051. protected _specularIntensity: number;
  105052. /**
  105053. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105054. */
  105055. private _lightingInfos;
  105056. /**
  105057. * Debug Control allowing disabling the bump map on this material.
  105058. */
  105059. protected _disableBumpMap: boolean;
  105060. /**
  105061. * AKA Diffuse Texture in standard nomenclature.
  105062. */
  105063. protected _albedoTexture: Nullable<BaseTexture>;
  105064. /**
  105065. * AKA Occlusion Texture in other nomenclature.
  105066. */
  105067. protected _ambientTexture: Nullable<BaseTexture>;
  105068. /**
  105069. * AKA Occlusion Texture Intensity in other nomenclature.
  105070. */
  105071. protected _ambientTextureStrength: number;
  105072. /**
  105073. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105074. * 1 means it completely occludes it
  105075. * 0 mean it has no impact
  105076. */
  105077. protected _ambientTextureImpactOnAnalyticalLights: number;
  105078. /**
  105079. * Stores the alpha values in a texture.
  105080. */
  105081. protected _opacityTexture: Nullable<BaseTexture>;
  105082. /**
  105083. * Stores the reflection values in a texture.
  105084. */
  105085. protected _reflectionTexture: Nullable<BaseTexture>;
  105086. /**
  105087. * Stores the emissive values in a texture.
  105088. */
  105089. protected _emissiveTexture: Nullable<BaseTexture>;
  105090. /**
  105091. * AKA Specular texture in other nomenclature.
  105092. */
  105093. protected _reflectivityTexture: Nullable<BaseTexture>;
  105094. /**
  105095. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105096. */
  105097. protected _metallicTexture: Nullable<BaseTexture>;
  105098. /**
  105099. * Specifies the metallic scalar of the metallic/roughness workflow.
  105100. * Can also be used to scale the metalness values of the metallic texture.
  105101. */
  105102. protected _metallic: Nullable<number>;
  105103. /**
  105104. * Specifies the roughness scalar of the metallic/roughness workflow.
  105105. * Can also be used to scale the roughness values of the metallic texture.
  105106. */
  105107. protected _roughness: Nullable<number>;
  105108. /**
  105109. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105110. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105111. */
  105112. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105113. /**
  105114. * Stores surface normal data used to displace a mesh in a texture.
  105115. */
  105116. protected _bumpTexture: Nullable<BaseTexture>;
  105117. /**
  105118. * Stores the pre-calculated light information of a mesh in a texture.
  105119. */
  105120. protected _lightmapTexture: Nullable<BaseTexture>;
  105121. /**
  105122. * The color of a material in ambient lighting.
  105123. */
  105124. protected _ambientColor: Color3;
  105125. /**
  105126. * AKA Diffuse Color in other nomenclature.
  105127. */
  105128. protected _albedoColor: Color3;
  105129. /**
  105130. * AKA Specular Color in other nomenclature.
  105131. */
  105132. protected _reflectivityColor: Color3;
  105133. /**
  105134. * The color applied when light is reflected from a material.
  105135. */
  105136. protected _reflectionColor: Color3;
  105137. /**
  105138. * The color applied when light is emitted from a material.
  105139. */
  105140. protected _emissiveColor: Color3;
  105141. /**
  105142. * AKA Glossiness in other nomenclature.
  105143. */
  105144. protected _microSurface: number;
  105145. /**
  105146. * Specifies that the material will use the light map as a show map.
  105147. */
  105148. protected _useLightmapAsShadowmap: boolean;
  105149. /**
  105150. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105151. * makes the reflect vector face the model (under horizon).
  105152. */
  105153. protected _useHorizonOcclusion: boolean;
  105154. /**
  105155. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105156. * too much the area relying on ambient texture to define their ambient occlusion.
  105157. */
  105158. protected _useRadianceOcclusion: boolean;
  105159. /**
  105160. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105161. */
  105162. protected _useAlphaFromAlbedoTexture: boolean;
  105163. /**
  105164. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105165. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105166. */
  105167. protected _useSpecularOverAlpha: boolean;
  105168. /**
  105169. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105170. */
  105171. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105172. /**
  105173. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105174. */
  105175. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105176. /**
  105177. * Specifies if the metallic texture contains the roughness information in its green channel.
  105178. */
  105179. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105180. /**
  105181. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105182. */
  105183. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105184. /**
  105185. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105186. */
  105187. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105188. /**
  105189. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105190. */
  105191. protected _useAmbientInGrayScale: boolean;
  105192. /**
  105193. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105194. * The material will try to infer what glossiness each pixel should be.
  105195. */
  105196. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105197. /**
  105198. * Defines the falloff type used in this material.
  105199. * It by default is Physical.
  105200. */
  105201. protected _lightFalloff: number;
  105202. /**
  105203. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105204. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105205. */
  105206. protected _useRadianceOverAlpha: boolean;
  105207. /**
  105208. * Allows using an object space normal map (instead of tangent space).
  105209. */
  105210. protected _useObjectSpaceNormalMap: boolean;
  105211. /**
  105212. * Allows using the bump map in parallax mode.
  105213. */
  105214. protected _useParallax: boolean;
  105215. /**
  105216. * Allows using the bump map in parallax occlusion mode.
  105217. */
  105218. protected _useParallaxOcclusion: boolean;
  105219. /**
  105220. * Controls the scale bias of the parallax mode.
  105221. */
  105222. protected _parallaxScaleBias: number;
  105223. /**
  105224. * If sets to true, disables all the lights affecting the material.
  105225. */
  105226. protected _disableLighting: boolean;
  105227. /**
  105228. * Number of Simultaneous lights allowed on the material.
  105229. */
  105230. protected _maxSimultaneousLights: number;
  105231. /**
  105232. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105233. */
  105234. protected _invertNormalMapX: boolean;
  105235. /**
  105236. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105237. */
  105238. protected _invertNormalMapY: boolean;
  105239. /**
  105240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105241. */
  105242. protected _twoSidedLighting: boolean;
  105243. /**
  105244. * Defines the alpha limits in alpha test mode.
  105245. */
  105246. protected _alphaCutOff: number;
  105247. /**
  105248. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105249. */
  105250. protected _forceAlphaTest: boolean;
  105251. /**
  105252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105253. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105254. */
  105255. protected _useAlphaFresnel: boolean;
  105256. /**
  105257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105258. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105259. */
  105260. protected _useLinearAlphaFresnel: boolean;
  105261. /**
  105262. * The transparency mode of the material.
  105263. */
  105264. protected _transparencyMode: Nullable<number>;
  105265. /**
  105266. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105267. * from cos thetav and roughness:
  105268. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105269. */
  105270. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105271. /**
  105272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105273. */
  105274. protected _forceIrradianceInFragment: boolean;
  105275. /**
  105276. * Force normal to face away from face.
  105277. */
  105278. protected _forceNormalForward: boolean;
  105279. /**
  105280. * Enables specular anti aliasing in the PBR shader.
  105281. * It will both interacts on the Geometry for analytical and IBL lighting.
  105282. * It also prefilter the roughness map based on the bump values.
  105283. */
  105284. protected _enableSpecularAntiAliasing: boolean;
  105285. /**
  105286. * Default configuration related to image processing available in the PBR Material.
  105287. */
  105288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105289. /**
  105290. * Keep track of the image processing observer to allow dispose and replace.
  105291. */
  105292. private _imageProcessingObserver;
  105293. /**
  105294. * Attaches a new image processing configuration to the PBR Material.
  105295. * @param configuration
  105296. */
  105297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105298. /**
  105299. * Stores the available render targets.
  105300. */
  105301. private _renderTargets;
  105302. /**
  105303. * Sets the global ambient color for the material used in lighting calculations.
  105304. */
  105305. private _globalAmbientColor;
  105306. /**
  105307. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105308. */
  105309. private _useLogarithmicDepth;
  105310. /**
  105311. * If set to true, no lighting calculations will be applied.
  105312. */
  105313. private _unlit;
  105314. private _debugMode;
  105315. /**
  105316. * @hidden
  105317. * This is reserved for the inspector.
  105318. * Defines the material debug mode.
  105319. * It helps seeing only some components of the material while troubleshooting.
  105320. */
  105321. debugMode: number;
  105322. /**
  105323. * @hidden
  105324. * This is reserved for the inspector.
  105325. * Specify from where on screen the debug mode should start.
  105326. * The value goes from -1 (full screen) to 1 (not visible)
  105327. * It helps with side by side comparison against the final render
  105328. * This defaults to -1
  105329. */
  105330. private debugLimit;
  105331. /**
  105332. * @hidden
  105333. * This is reserved for the inspector.
  105334. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105335. * You can use the factor to better multiply the final value.
  105336. */
  105337. private debugFactor;
  105338. /**
  105339. * Defines the clear coat layer parameters for the material.
  105340. */
  105341. readonly clearCoat: PBRClearCoatConfiguration;
  105342. /**
  105343. * Defines the anisotropic parameters for the material.
  105344. */
  105345. readonly anisotropy: PBRAnisotropicConfiguration;
  105346. /**
  105347. * Defines the BRDF parameters for the material.
  105348. */
  105349. readonly brdf: PBRBRDFConfiguration;
  105350. /**
  105351. * Defines the Sheen parameters for the material.
  105352. */
  105353. readonly sheen: PBRSheenConfiguration;
  105354. /**
  105355. * Defines the SubSurface parameters for the material.
  105356. */
  105357. readonly subSurface: PBRSubSurfaceConfiguration;
  105358. /**
  105359. * Custom callback helping to override the default shader used in the material.
  105360. */
  105361. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105362. /**
  105363. * Instantiates a new PBRMaterial instance.
  105364. *
  105365. * @param name The material name
  105366. * @param scene The scene the material will be use in.
  105367. */
  105368. constructor(name: string, scene: Scene);
  105369. /**
  105370. * Gets a boolean indicating that current material needs to register RTT
  105371. */
  105372. readonly hasRenderTargetTextures: boolean;
  105373. /**
  105374. * Gets the name of the material class.
  105375. */
  105376. getClassName(): string;
  105377. /**
  105378. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105379. */
  105380. /**
  105381. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105382. */
  105383. useLogarithmicDepth: boolean;
  105384. /**
  105385. * Gets the current transparency mode.
  105386. */
  105387. /**
  105388. * Sets the transparency mode of the material.
  105389. *
  105390. * | Value | Type | Description |
  105391. * | ----- | ----------------------------------- | ----------- |
  105392. * | 0 | OPAQUE | |
  105393. * | 1 | ALPHATEST | |
  105394. * | 2 | ALPHABLEND | |
  105395. * | 3 | ALPHATESTANDBLEND | |
  105396. *
  105397. */
  105398. transparencyMode: Nullable<number>;
  105399. /**
  105400. * Returns true if alpha blending should be disabled.
  105401. */
  105402. private readonly _disableAlphaBlending;
  105403. /**
  105404. * Specifies whether or not this material should be rendered in alpha blend mode.
  105405. */
  105406. needAlphaBlending(): boolean;
  105407. /**
  105408. * Specifies if the mesh will require alpha blending.
  105409. * @param mesh - BJS mesh.
  105410. */
  105411. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105412. /**
  105413. * Specifies whether or not this material should be rendered in alpha test mode.
  105414. */
  105415. needAlphaTesting(): boolean;
  105416. /**
  105417. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105418. */
  105419. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105420. /**
  105421. * Gets the texture used for the alpha test.
  105422. */
  105423. getAlphaTestTexture(): Nullable<BaseTexture>;
  105424. /**
  105425. * Specifies that the submesh is ready to be used.
  105426. * @param mesh - BJS mesh.
  105427. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105428. * @param useInstances - Specifies that instances should be used.
  105429. * @returns - boolean indicating that the submesh is ready or not.
  105430. */
  105431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105432. /**
  105433. * Specifies if the material uses metallic roughness workflow.
  105434. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105435. */
  105436. isMetallicWorkflow(): boolean;
  105437. private _prepareEffect;
  105438. private _prepareDefines;
  105439. /**
  105440. * Force shader compilation
  105441. */
  105442. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105443. clipPlane: boolean;
  105444. }>): void;
  105445. /**
  105446. * Initializes the uniform buffer layout for the shader.
  105447. */
  105448. buildUniformLayout(): void;
  105449. /**
  105450. * Unbinds the material from the mesh
  105451. */
  105452. unbind(): void;
  105453. /**
  105454. * Binds the submesh data.
  105455. * @param world - The world matrix.
  105456. * @param mesh - The BJS mesh.
  105457. * @param subMesh - A submesh of the BJS mesh.
  105458. */
  105459. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105460. /**
  105461. * Returns the animatable textures.
  105462. * @returns - Array of animatable textures.
  105463. */
  105464. getAnimatables(): IAnimatable[];
  105465. /**
  105466. * Returns the texture used for reflections.
  105467. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105468. */
  105469. private _getReflectionTexture;
  105470. /**
  105471. * Returns an array of the actively used textures.
  105472. * @returns - Array of BaseTextures
  105473. */
  105474. getActiveTextures(): BaseTexture[];
  105475. /**
  105476. * Checks to see if a texture is used in the material.
  105477. * @param texture - Base texture to use.
  105478. * @returns - Boolean specifying if a texture is used in the material.
  105479. */
  105480. hasTexture(texture: BaseTexture): boolean;
  105481. /**
  105482. * Disposes the resources of the material.
  105483. * @param forceDisposeEffect - Forces the disposal of effects.
  105484. * @param forceDisposeTextures - Forces the disposal of all textures.
  105485. */
  105486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105487. }
  105488. }
  105489. declare module BABYLON {
  105490. /**
  105491. * The Physically based material of BJS.
  105492. *
  105493. * This offers the main features of a standard PBR material.
  105494. * For more information, please refer to the documentation :
  105495. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105496. */
  105497. export class PBRMaterial extends PBRBaseMaterial {
  105498. /**
  105499. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105500. */
  105501. static readonly PBRMATERIAL_OPAQUE: number;
  105502. /**
  105503. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105504. */
  105505. static readonly PBRMATERIAL_ALPHATEST: number;
  105506. /**
  105507. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105508. */
  105509. static readonly PBRMATERIAL_ALPHABLEND: number;
  105510. /**
  105511. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105512. * They are also discarded below the alpha cutoff threshold to improve performances.
  105513. */
  105514. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105515. /**
  105516. * Defines the default value of how much AO map is occluding the analytical lights
  105517. * (point spot...).
  105518. */
  105519. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105520. /**
  105521. * Intensity of the direct lights e.g. the four lights available in your scene.
  105522. * This impacts both the direct diffuse and specular highlights.
  105523. */
  105524. directIntensity: number;
  105525. /**
  105526. * Intensity of the emissive part of the material.
  105527. * This helps controlling the emissive effect without modifying the emissive color.
  105528. */
  105529. emissiveIntensity: number;
  105530. /**
  105531. * Intensity of the environment e.g. how much the environment will light the object
  105532. * either through harmonics for rough material or through the refelction for shiny ones.
  105533. */
  105534. environmentIntensity: number;
  105535. /**
  105536. * This is a special control allowing the reduction of the specular highlights coming from the
  105537. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105538. */
  105539. specularIntensity: number;
  105540. /**
  105541. * Debug Control allowing disabling the bump map on this material.
  105542. */
  105543. disableBumpMap: boolean;
  105544. /**
  105545. * AKA Diffuse Texture in standard nomenclature.
  105546. */
  105547. albedoTexture: BaseTexture;
  105548. /**
  105549. * AKA Occlusion Texture in other nomenclature.
  105550. */
  105551. ambientTexture: BaseTexture;
  105552. /**
  105553. * AKA Occlusion Texture Intensity in other nomenclature.
  105554. */
  105555. ambientTextureStrength: number;
  105556. /**
  105557. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105558. * 1 means it completely occludes it
  105559. * 0 mean it has no impact
  105560. */
  105561. ambientTextureImpactOnAnalyticalLights: number;
  105562. /**
  105563. * Stores the alpha values in a texture.
  105564. */
  105565. opacityTexture: BaseTexture;
  105566. /**
  105567. * Stores the reflection values in a texture.
  105568. */
  105569. reflectionTexture: Nullable<BaseTexture>;
  105570. /**
  105571. * Stores the emissive values in a texture.
  105572. */
  105573. emissiveTexture: BaseTexture;
  105574. /**
  105575. * AKA Specular texture in other nomenclature.
  105576. */
  105577. reflectivityTexture: BaseTexture;
  105578. /**
  105579. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105580. */
  105581. metallicTexture: BaseTexture;
  105582. /**
  105583. * Specifies the metallic scalar of the metallic/roughness workflow.
  105584. * Can also be used to scale the metalness values of the metallic texture.
  105585. */
  105586. metallic: Nullable<number>;
  105587. /**
  105588. * Specifies the roughness scalar of the metallic/roughness workflow.
  105589. * Can also be used to scale the roughness values of the metallic texture.
  105590. */
  105591. roughness: Nullable<number>;
  105592. /**
  105593. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105594. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105595. */
  105596. microSurfaceTexture: BaseTexture;
  105597. /**
  105598. * Stores surface normal data used to displace a mesh in a texture.
  105599. */
  105600. bumpTexture: BaseTexture;
  105601. /**
  105602. * Stores the pre-calculated light information of a mesh in a texture.
  105603. */
  105604. lightmapTexture: BaseTexture;
  105605. /**
  105606. * Stores the refracted light information in a texture.
  105607. */
  105608. refractionTexture: Nullable<BaseTexture>;
  105609. /**
  105610. * The color of a material in ambient lighting.
  105611. */
  105612. ambientColor: Color3;
  105613. /**
  105614. * AKA Diffuse Color in other nomenclature.
  105615. */
  105616. albedoColor: Color3;
  105617. /**
  105618. * AKA Specular Color in other nomenclature.
  105619. */
  105620. reflectivityColor: Color3;
  105621. /**
  105622. * The color reflected from the material.
  105623. */
  105624. reflectionColor: Color3;
  105625. /**
  105626. * The color emitted from the material.
  105627. */
  105628. emissiveColor: Color3;
  105629. /**
  105630. * AKA Glossiness in other nomenclature.
  105631. */
  105632. microSurface: number;
  105633. /**
  105634. * source material index of refraction (IOR)' / 'destination material IOR.
  105635. */
  105636. indexOfRefraction: number;
  105637. /**
  105638. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105639. */
  105640. invertRefractionY: boolean;
  105641. /**
  105642. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105643. * Materials half opaque for instance using refraction could benefit from this control.
  105644. */
  105645. linkRefractionWithTransparency: boolean;
  105646. /**
  105647. * If true, the light map contains occlusion information instead of lighting info.
  105648. */
  105649. useLightmapAsShadowmap: boolean;
  105650. /**
  105651. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105652. */
  105653. useAlphaFromAlbedoTexture: boolean;
  105654. /**
  105655. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105656. */
  105657. forceAlphaTest: boolean;
  105658. /**
  105659. * Defines the alpha limits in alpha test mode.
  105660. */
  105661. alphaCutOff: number;
  105662. /**
  105663. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105664. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105665. */
  105666. useSpecularOverAlpha: boolean;
  105667. /**
  105668. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105669. */
  105670. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105671. /**
  105672. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105673. */
  105674. useRoughnessFromMetallicTextureAlpha: boolean;
  105675. /**
  105676. * Specifies if the metallic texture contains the roughness information in its green channel.
  105677. */
  105678. useRoughnessFromMetallicTextureGreen: boolean;
  105679. /**
  105680. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105681. */
  105682. useMetallnessFromMetallicTextureBlue: boolean;
  105683. /**
  105684. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105685. */
  105686. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105687. /**
  105688. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105689. */
  105690. useAmbientInGrayScale: boolean;
  105691. /**
  105692. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105693. * The material will try to infer what glossiness each pixel should be.
  105694. */
  105695. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105696. /**
  105697. * BJS is using an harcoded light falloff based on a manually sets up range.
  105698. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105699. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105700. */
  105701. /**
  105702. * BJS is using an harcoded light falloff based on a manually sets up range.
  105703. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105704. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105705. */
  105706. usePhysicalLightFalloff: boolean;
  105707. /**
  105708. * In order to support the falloff compatibility with gltf, a special mode has been added
  105709. * to reproduce the gltf light falloff.
  105710. */
  105711. /**
  105712. * In order to support the falloff compatibility with gltf, a special mode has been added
  105713. * to reproduce the gltf light falloff.
  105714. */
  105715. useGLTFLightFalloff: boolean;
  105716. /**
  105717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105719. */
  105720. useRadianceOverAlpha: boolean;
  105721. /**
  105722. * Allows using an object space normal map (instead of tangent space).
  105723. */
  105724. useObjectSpaceNormalMap: boolean;
  105725. /**
  105726. * Allows using the bump map in parallax mode.
  105727. */
  105728. useParallax: boolean;
  105729. /**
  105730. * Allows using the bump map in parallax occlusion mode.
  105731. */
  105732. useParallaxOcclusion: boolean;
  105733. /**
  105734. * Controls the scale bias of the parallax mode.
  105735. */
  105736. parallaxScaleBias: number;
  105737. /**
  105738. * If sets to true, disables all the lights affecting the material.
  105739. */
  105740. disableLighting: boolean;
  105741. /**
  105742. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105743. */
  105744. forceIrradianceInFragment: boolean;
  105745. /**
  105746. * Number of Simultaneous lights allowed on the material.
  105747. */
  105748. maxSimultaneousLights: number;
  105749. /**
  105750. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105751. */
  105752. invertNormalMapX: boolean;
  105753. /**
  105754. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105755. */
  105756. invertNormalMapY: boolean;
  105757. /**
  105758. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105759. */
  105760. twoSidedLighting: boolean;
  105761. /**
  105762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105763. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105764. */
  105765. useAlphaFresnel: boolean;
  105766. /**
  105767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105768. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105769. */
  105770. useLinearAlphaFresnel: boolean;
  105771. /**
  105772. * Let user defines the brdf lookup texture used for IBL.
  105773. * A default 8bit version is embedded but you could point at :
  105774. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105775. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105776. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105777. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105778. */
  105779. environmentBRDFTexture: Nullable<BaseTexture>;
  105780. /**
  105781. * Force normal to face away from face.
  105782. */
  105783. forceNormalForward: boolean;
  105784. /**
  105785. * Enables specular anti aliasing in the PBR shader.
  105786. * It will both interacts on the Geometry for analytical and IBL lighting.
  105787. * It also prefilter the roughness map based on the bump values.
  105788. */
  105789. enableSpecularAntiAliasing: boolean;
  105790. /**
  105791. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105792. * makes the reflect vector face the model (under horizon).
  105793. */
  105794. useHorizonOcclusion: boolean;
  105795. /**
  105796. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105797. * too much the area relying on ambient texture to define their ambient occlusion.
  105798. */
  105799. useRadianceOcclusion: boolean;
  105800. /**
  105801. * If set to true, no lighting calculations will be applied.
  105802. */
  105803. unlit: boolean;
  105804. /**
  105805. * Gets the image processing configuration used either in this material.
  105806. */
  105807. /**
  105808. * Sets the Default image processing configuration used either in the this material.
  105809. *
  105810. * If sets to null, the scene one is in use.
  105811. */
  105812. imageProcessingConfiguration: ImageProcessingConfiguration;
  105813. /**
  105814. * Gets wether the color curves effect is enabled.
  105815. */
  105816. /**
  105817. * Sets wether the color curves effect is enabled.
  105818. */
  105819. cameraColorCurvesEnabled: boolean;
  105820. /**
  105821. * Gets wether the color grading effect is enabled.
  105822. */
  105823. /**
  105824. * Gets wether the color grading effect is enabled.
  105825. */
  105826. cameraColorGradingEnabled: boolean;
  105827. /**
  105828. * Gets wether tonemapping is enabled or not.
  105829. */
  105830. /**
  105831. * Sets wether tonemapping is enabled or not
  105832. */
  105833. cameraToneMappingEnabled: boolean;
  105834. /**
  105835. * The camera exposure used on this material.
  105836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105837. * This corresponds to a photographic exposure.
  105838. */
  105839. /**
  105840. * The camera exposure used on this material.
  105841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105842. * This corresponds to a photographic exposure.
  105843. */
  105844. cameraExposure: number;
  105845. /**
  105846. * Gets The camera contrast used on this material.
  105847. */
  105848. /**
  105849. * Sets The camera contrast used on this material.
  105850. */
  105851. cameraContrast: number;
  105852. /**
  105853. * Gets the Color Grading 2D Lookup Texture.
  105854. */
  105855. /**
  105856. * Sets the Color Grading 2D Lookup Texture.
  105857. */
  105858. cameraColorGradingTexture: Nullable<BaseTexture>;
  105859. /**
  105860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105862. * 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;
  105863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105864. */
  105865. /**
  105866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105868. * 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;
  105869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105870. */
  105871. cameraColorCurves: Nullable<ColorCurves>;
  105872. /**
  105873. * Instantiates a new PBRMaterial instance.
  105874. *
  105875. * @param name The material name
  105876. * @param scene The scene the material will be use in.
  105877. */
  105878. constructor(name: string, scene: Scene);
  105879. /**
  105880. * Returns the name of this material class.
  105881. */
  105882. getClassName(): string;
  105883. /**
  105884. * Makes a duplicate of the current material.
  105885. * @param name - name to use for the new material.
  105886. */
  105887. clone(name: string): PBRMaterial;
  105888. /**
  105889. * Serializes this PBR Material.
  105890. * @returns - An object with the serialized material.
  105891. */
  105892. serialize(): any;
  105893. /**
  105894. * Parses a PBR Material from a serialized object.
  105895. * @param source - Serialized object.
  105896. * @param scene - BJS scene instance.
  105897. * @param rootUrl - url for the scene object
  105898. * @returns - PBRMaterial
  105899. */
  105900. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105901. }
  105902. }
  105903. declare module BABYLON {
  105904. /**
  105905. * Direct draw surface info
  105906. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105907. */
  105908. export interface DDSInfo {
  105909. /**
  105910. * Width of the texture
  105911. */
  105912. width: number;
  105913. /**
  105914. * Width of the texture
  105915. */
  105916. height: number;
  105917. /**
  105918. * Number of Mipmaps for the texture
  105919. * @see https://en.wikipedia.org/wiki/Mipmap
  105920. */
  105921. mipmapCount: number;
  105922. /**
  105923. * If the textures format is a known fourCC format
  105924. * @see https://www.fourcc.org/
  105925. */
  105926. isFourCC: boolean;
  105927. /**
  105928. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105929. */
  105930. isRGB: boolean;
  105931. /**
  105932. * If the texture is a lumincance format
  105933. */
  105934. isLuminance: boolean;
  105935. /**
  105936. * If this is a cube texture
  105937. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105938. */
  105939. isCube: boolean;
  105940. /**
  105941. * If the texture is a compressed format eg. FOURCC_DXT1
  105942. */
  105943. isCompressed: boolean;
  105944. /**
  105945. * The dxgiFormat of the texture
  105946. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105947. */
  105948. dxgiFormat: number;
  105949. /**
  105950. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105951. */
  105952. textureType: number;
  105953. /**
  105954. * Sphericle polynomial created for the dds texture
  105955. */
  105956. sphericalPolynomial?: SphericalPolynomial;
  105957. }
  105958. /**
  105959. * Class used to provide DDS decompression tools
  105960. */
  105961. export class DDSTools {
  105962. /**
  105963. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105964. */
  105965. static StoreLODInAlphaChannel: boolean;
  105966. /**
  105967. * Gets DDS information from an array buffer
  105968. * @param arrayBuffer defines the array buffer to read data from
  105969. * @returns the DDS information
  105970. */
  105971. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105972. private static _FloatView;
  105973. private static _Int32View;
  105974. private static _ToHalfFloat;
  105975. private static _FromHalfFloat;
  105976. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105977. private static _GetHalfFloatRGBAArrayBuffer;
  105978. private static _GetFloatRGBAArrayBuffer;
  105979. private static _GetFloatAsUIntRGBAArrayBuffer;
  105980. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105981. private static _GetRGBAArrayBuffer;
  105982. private static _ExtractLongWordOrder;
  105983. private static _GetRGBArrayBuffer;
  105984. private static _GetLuminanceArrayBuffer;
  105985. /**
  105986. * Uploads DDS Levels to a Babylon Texture
  105987. * @hidden
  105988. */
  105989. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105990. }
  105991. interface Engine {
  105992. /**
  105993. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105994. * @param rootUrl defines the url where the file to load is located
  105995. * @param scene defines the current scene
  105996. * @param lodScale defines scale to apply to the mip map selection
  105997. * @param lodOffset defines offset to apply to the mip map selection
  105998. * @param onLoad defines an optional callback raised when the texture is loaded
  105999. * @param onError defines an optional callback raised if there is an issue to load the texture
  106000. * @param format defines the format of the data
  106001. * @param forcedExtension defines the extension to use to pick the right loader
  106002. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106003. * @returns the cube texture as an InternalTexture
  106004. */
  106005. 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;
  106006. }
  106007. }
  106008. declare module BABYLON {
  106009. /**
  106010. * Implementation of the DDS Texture Loader.
  106011. * @hidden
  106012. */
  106013. export class _DDSTextureLoader implements IInternalTextureLoader {
  106014. /**
  106015. * Defines wether the loader supports cascade loading the different faces.
  106016. */
  106017. readonly supportCascades: boolean;
  106018. /**
  106019. * This returns if the loader support the current file information.
  106020. * @param extension defines the file extension of the file being loaded
  106021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106022. * @param fallback defines the fallback internal texture if any
  106023. * @param isBase64 defines whether the texture is encoded as a base64
  106024. * @param isBuffer defines whether the texture data are stored as a buffer
  106025. * @returns true if the loader can load the specified file
  106026. */
  106027. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106028. /**
  106029. * Transform the url before loading if required.
  106030. * @param rootUrl the url of the texture
  106031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106032. * @returns the transformed texture
  106033. */
  106034. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106035. /**
  106036. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106037. * @param rootUrl the url of the texture
  106038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106039. * @returns the fallback texture
  106040. */
  106041. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106042. /**
  106043. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106044. * @param data contains the texture data
  106045. * @param texture defines the BabylonJS internal texture
  106046. * @param createPolynomials will be true if polynomials have been requested
  106047. * @param onLoad defines the callback to trigger once the texture is ready
  106048. * @param onError defines the callback to trigger in case of error
  106049. */
  106050. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106051. /**
  106052. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106053. * @param data contains the texture data
  106054. * @param texture defines the BabylonJS internal texture
  106055. * @param callback defines the method to call once ready to upload
  106056. */
  106057. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106058. }
  106059. }
  106060. declare module BABYLON {
  106061. /** @hidden */
  106062. export var rgbdEncodePixelShader: {
  106063. name: string;
  106064. shader: string;
  106065. };
  106066. }
  106067. declare module BABYLON {
  106068. /**
  106069. * Raw texture data and descriptor sufficient for WebGL texture upload
  106070. */
  106071. export interface EnvironmentTextureInfo {
  106072. /**
  106073. * Version of the environment map
  106074. */
  106075. version: number;
  106076. /**
  106077. * Width of image
  106078. */
  106079. width: number;
  106080. /**
  106081. * Irradiance information stored in the file.
  106082. */
  106083. irradiance: any;
  106084. /**
  106085. * Specular information stored in the file.
  106086. */
  106087. specular: any;
  106088. }
  106089. /**
  106090. * Sets of helpers addressing the serialization and deserialization of environment texture
  106091. * stored in a BabylonJS env file.
  106092. * Those files are usually stored as .env files.
  106093. */
  106094. export class EnvironmentTextureTools {
  106095. /**
  106096. * Magic number identifying the env file.
  106097. */
  106098. private static _MagicBytes;
  106099. /**
  106100. * Gets the environment info from an env file.
  106101. * @param data The array buffer containing the .env bytes.
  106102. * @returns the environment file info (the json header) if successfully parsed.
  106103. */
  106104. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106105. /**
  106106. * Creates an environment texture from a loaded cube texture.
  106107. * @param texture defines the cube texture to convert in env file
  106108. * @return a promise containing the environment data if succesfull.
  106109. */
  106110. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106111. /**
  106112. * Creates a JSON representation of the spherical data.
  106113. * @param texture defines the texture containing the polynomials
  106114. * @return the JSON representation of the spherical info
  106115. */
  106116. private static _CreateEnvTextureIrradiance;
  106117. /**
  106118. * Uploads the texture info contained in the env file to the GPU.
  106119. * @param texture defines the internal texture to upload to
  106120. * @param arrayBuffer defines the buffer cotaining the data to load
  106121. * @param info defines the texture info retrieved through the GetEnvInfo method
  106122. * @returns a promise
  106123. */
  106124. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106125. /**
  106126. * Uploads the levels of image data to the GPU.
  106127. * @param texture defines the internal texture to upload to
  106128. * @param imageData defines the array buffer views of image data [mipmap][face]
  106129. * @returns a promise
  106130. */
  106131. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106132. /**
  106133. * Uploads spherical polynomials information to the texture.
  106134. * @param texture defines the texture we are trying to upload the information to
  106135. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106136. */
  106137. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106138. /** @hidden */
  106139. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * Implementation of the ENV Texture Loader.
  106145. * @hidden
  106146. */
  106147. export class _ENVTextureLoader implements IInternalTextureLoader {
  106148. /**
  106149. * Defines wether the loader supports cascade loading the different faces.
  106150. */
  106151. readonly supportCascades: boolean;
  106152. /**
  106153. * This returns if the loader support the current file information.
  106154. * @param extension defines the file extension of the file being loaded
  106155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106156. * @param fallback defines the fallback internal texture if any
  106157. * @param isBase64 defines whether the texture is encoded as a base64
  106158. * @param isBuffer defines whether the texture data are stored as a buffer
  106159. * @returns true if the loader can load the specified file
  106160. */
  106161. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106162. /**
  106163. * Transform the url before loading if required.
  106164. * @param rootUrl the url of the texture
  106165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106166. * @returns the transformed texture
  106167. */
  106168. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106169. /**
  106170. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106171. * @param rootUrl the url of the texture
  106172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106173. * @returns the fallback texture
  106174. */
  106175. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106176. /**
  106177. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106178. * @param data contains the texture data
  106179. * @param texture defines the BabylonJS internal texture
  106180. * @param createPolynomials will be true if polynomials have been requested
  106181. * @param onLoad defines the callback to trigger once the texture is ready
  106182. * @param onError defines the callback to trigger in case of error
  106183. */
  106184. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106185. /**
  106186. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106187. * @param data contains the texture data
  106188. * @param texture defines the BabylonJS internal texture
  106189. * @param callback defines the method to call once ready to upload
  106190. */
  106191. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106192. }
  106193. }
  106194. declare module BABYLON {
  106195. /**
  106196. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106197. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106198. */
  106199. export class KhronosTextureContainer {
  106200. /** contents of the KTX container file */
  106201. arrayBuffer: any;
  106202. private static HEADER_LEN;
  106203. private static COMPRESSED_2D;
  106204. private static COMPRESSED_3D;
  106205. private static TEX_2D;
  106206. private static TEX_3D;
  106207. /**
  106208. * Gets the openGL type
  106209. */
  106210. glType: number;
  106211. /**
  106212. * Gets the openGL type size
  106213. */
  106214. glTypeSize: number;
  106215. /**
  106216. * Gets the openGL format
  106217. */
  106218. glFormat: number;
  106219. /**
  106220. * Gets the openGL internal format
  106221. */
  106222. glInternalFormat: number;
  106223. /**
  106224. * Gets the base internal format
  106225. */
  106226. glBaseInternalFormat: number;
  106227. /**
  106228. * Gets image width in pixel
  106229. */
  106230. pixelWidth: number;
  106231. /**
  106232. * Gets image height in pixel
  106233. */
  106234. pixelHeight: number;
  106235. /**
  106236. * Gets image depth in pixels
  106237. */
  106238. pixelDepth: number;
  106239. /**
  106240. * Gets the number of array elements
  106241. */
  106242. numberOfArrayElements: number;
  106243. /**
  106244. * Gets the number of faces
  106245. */
  106246. numberOfFaces: number;
  106247. /**
  106248. * Gets the number of mipmap levels
  106249. */
  106250. numberOfMipmapLevels: number;
  106251. /**
  106252. * Gets the bytes of key value data
  106253. */
  106254. bytesOfKeyValueData: number;
  106255. /**
  106256. * Gets the load type
  106257. */
  106258. loadType: number;
  106259. /**
  106260. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106261. */
  106262. isInvalid: boolean;
  106263. /**
  106264. * Creates a new KhronosTextureContainer
  106265. * @param arrayBuffer contents of the KTX container file
  106266. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106267. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106268. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106269. */
  106270. constructor(
  106271. /** contents of the KTX container file */
  106272. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106273. /**
  106274. * Uploads KTX content to a Babylon Texture.
  106275. * It is assumed that the texture has already been created & is currently bound
  106276. * @hidden
  106277. */
  106278. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106279. private _upload2DCompressedLevels;
  106280. }
  106281. }
  106282. declare module BABYLON {
  106283. /**
  106284. * Implementation of the KTX Texture Loader.
  106285. * @hidden
  106286. */
  106287. export class _KTXTextureLoader implements IInternalTextureLoader {
  106288. /**
  106289. * Defines wether the loader supports cascade loading the different faces.
  106290. */
  106291. readonly supportCascades: boolean;
  106292. /**
  106293. * This returns if the loader support the current file information.
  106294. * @param extension defines the file extension of the file being loaded
  106295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106296. * @param fallback defines the fallback internal texture if any
  106297. * @param isBase64 defines whether the texture is encoded as a base64
  106298. * @param isBuffer defines whether the texture data are stored as a buffer
  106299. * @returns true if the loader can load the specified file
  106300. */
  106301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106302. /**
  106303. * Transform the url before loading if required.
  106304. * @param rootUrl the url of the texture
  106305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106306. * @returns the transformed texture
  106307. */
  106308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106309. /**
  106310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106311. * @param rootUrl the url of the texture
  106312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106313. * @returns the fallback texture
  106314. */
  106315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106316. /**
  106317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106318. * @param data contains the texture data
  106319. * @param texture defines the BabylonJS internal texture
  106320. * @param createPolynomials will be true if polynomials have been requested
  106321. * @param onLoad defines the callback to trigger once the texture is ready
  106322. * @param onError defines the callback to trigger in case of error
  106323. */
  106324. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106325. /**
  106326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106327. * @param data contains the texture data
  106328. * @param texture defines the BabylonJS internal texture
  106329. * @param callback defines the method to call once ready to upload
  106330. */
  106331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106332. }
  106333. }
  106334. declare module BABYLON {
  106335. /** @hidden */
  106336. export var _forceSceneHelpersToBundle: boolean;
  106337. interface Scene {
  106338. /**
  106339. * Creates a default light for the scene.
  106340. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106341. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106342. */
  106343. createDefaultLight(replace?: boolean): void;
  106344. /**
  106345. * Creates a default camera for the scene.
  106346. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106347. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106348. * @param replace has default false, when true replaces the active camera in the scene
  106349. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106350. */
  106351. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106352. /**
  106353. * Creates a default camera and a default light.
  106354. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106355. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106356. * @param replace has the default false, when true replaces the active camera/light in the scene
  106357. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106358. */
  106359. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106360. /**
  106361. * Creates a new sky box
  106362. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106363. * @param environmentTexture defines the texture to use as environment texture
  106364. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106365. * @param scale defines the overall scale of the skybox
  106366. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106367. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106368. * @returns a new mesh holding the sky box
  106369. */
  106370. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106371. /**
  106372. * Creates a new environment
  106373. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106374. * @param options defines the options you can use to configure the environment
  106375. * @returns the new EnvironmentHelper
  106376. */
  106377. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106378. /**
  106379. * Creates a new VREXperienceHelper
  106380. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106381. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106382. * @returns a new VREXperienceHelper
  106383. */
  106384. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106385. /**
  106386. * Creates a new XREXperienceHelper
  106387. * @see http://doc.babylonjs.com/how_to/webxr
  106388. * @returns a promise for a new XREXperienceHelper
  106389. */
  106390. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106396. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106397. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106398. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106399. */
  106400. export class VideoDome extends TransformNode {
  106401. /**
  106402. * Define the video source as a Monoscopic panoramic 360 video.
  106403. */
  106404. static readonly MODE_MONOSCOPIC: number;
  106405. /**
  106406. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106407. */
  106408. static readonly MODE_TOPBOTTOM: number;
  106409. /**
  106410. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106411. */
  106412. static readonly MODE_SIDEBYSIDE: number;
  106413. private _useDirectMapping;
  106414. /**
  106415. * The video texture being displayed on the sphere
  106416. */
  106417. protected _videoTexture: VideoTexture;
  106418. /**
  106419. * Gets the video texture being displayed on the sphere
  106420. */
  106421. readonly videoTexture: VideoTexture;
  106422. /**
  106423. * The skybox material
  106424. */
  106425. protected _material: BackgroundMaterial;
  106426. /**
  106427. * The surface used for the skybox
  106428. */
  106429. protected _mesh: Mesh;
  106430. /**
  106431. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106432. * Also see the options.resolution property.
  106433. */
  106434. fovMultiplier: number;
  106435. private _videoMode;
  106436. /**
  106437. * Gets or set the current video mode for the video. It can be:
  106438. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106439. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106440. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106441. */
  106442. videoMode: number;
  106443. /**
  106444. * Oberserver used in Stereoscopic VR Mode.
  106445. */
  106446. private _onBeforeCameraRenderObserver;
  106447. /**
  106448. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106449. * @param name Element's name, child elements will append suffixes for their own names.
  106450. * @param urlsOrVideo defines the url(s) or the video element to use
  106451. * @param options An object containing optional or exposed sub element properties
  106452. */
  106453. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106454. resolution?: number;
  106455. clickToPlay?: boolean;
  106456. autoPlay?: boolean;
  106457. loop?: boolean;
  106458. size?: number;
  106459. poster?: string;
  106460. faceForward?: boolean;
  106461. useDirectMapping?: boolean;
  106462. }, scene: Scene);
  106463. private _changeVideoMode;
  106464. /**
  106465. * Releases resources associated with this node.
  106466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106468. */
  106469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106470. }
  106471. }
  106472. declare module BABYLON {
  106473. /**
  106474. * This class can be used to get instrumentation data from a Babylon engine
  106475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106476. */
  106477. export class EngineInstrumentation implements IDisposable {
  106478. /**
  106479. * Define the instrumented engine.
  106480. */
  106481. engine: Engine;
  106482. private _captureGPUFrameTime;
  106483. private _gpuFrameTimeToken;
  106484. private _gpuFrameTime;
  106485. private _captureShaderCompilationTime;
  106486. private _shaderCompilationTime;
  106487. private _onBeginFrameObserver;
  106488. private _onEndFrameObserver;
  106489. private _onBeforeShaderCompilationObserver;
  106490. private _onAfterShaderCompilationObserver;
  106491. /**
  106492. * Gets the perf counter used for GPU frame time
  106493. */
  106494. readonly gpuFrameTimeCounter: PerfCounter;
  106495. /**
  106496. * Gets the GPU frame time capture status
  106497. */
  106498. /**
  106499. * Enable or disable the GPU frame time capture
  106500. */
  106501. captureGPUFrameTime: boolean;
  106502. /**
  106503. * Gets the perf counter used for shader compilation time
  106504. */
  106505. readonly shaderCompilationTimeCounter: PerfCounter;
  106506. /**
  106507. * Gets the shader compilation time capture status
  106508. */
  106509. /**
  106510. * Enable or disable the shader compilation time capture
  106511. */
  106512. captureShaderCompilationTime: boolean;
  106513. /**
  106514. * Instantiates a new engine instrumentation.
  106515. * This class can be used to get instrumentation data from a Babylon engine
  106516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106517. * @param engine Defines the engine to instrument
  106518. */
  106519. constructor(
  106520. /**
  106521. * Define the instrumented engine.
  106522. */
  106523. engine: Engine);
  106524. /**
  106525. * Dispose and release associated resources.
  106526. */
  106527. dispose(): void;
  106528. }
  106529. }
  106530. declare module BABYLON {
  106531. /**
  106532. * This class can be used to get instrumentation data from a Babylon engine
  106533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106534. */
  106535. export class SceneInstrumentation implements IDisposable {
  106536. /**
  106537. * Defines the scene to instrument
  106538. */
  106539. scene: Scene;
  106540. private _captureActiveMeshesEvaluationTime;
  106541. private _activeMeshesEvaluationTime;
  106542. private _captureRenderTargetsRenderTime;
  106543. private _renderTargetsRenderTime;
  106544. private _captureFrameTime;
  106545. private _frameTime;
  106546. private _captureRenderTime;
  106547. private _renderTime;
  106548. private _captureInterFrameTime;
  106549. private _interFrameTime;
  106550. private _captureParticlesRenderTime;
  106551. private _particlesRenderTime;
  106552. private _captureSpritesRenderTime;
  106553. private _spritesRenderTime;
  106554. private _capturePhysicsTime;
  106555. private _physicsTime;
  106556. private _captureAnimationsTime;
  106557. private _animationsTime;
  106558. private _captureCameraRenderTime;
  106559. private _cameraRenderTime;
  106560. private _onBeforeActiveMeshesEvaluationObserver;
  106561. private _onAfterActiveMeshesEvaluationObserver;
  106562. private _onBeforeRenderTargetsRenderObserver;
  106563. private _onAfterRenderTargetsRenderObserver;
  106564. private _onAfterRenderObserver;
  106565. private _onBeforeDrawPhaseObserver;
  106566. private _onAfterDrawPhaseObserver;
  106567. private _onBeforeAnimationsObserver;
  106568. private _onBeforeParticlesRenderingObserver;
  106569. private _onAfterParticlesRenderingObserver;
  106570. private _onBeforeSpritesRenderingObserver;
  106571. private _onAfterSpritesRenderingObserver;
  106572. private _onBeforePhysicsObserver;
  106573. private _onAfterPhysicsObserver;
  106574. private _onAfterAnimationsObserver;
  106575. private _onBeforeCameraRenderObserver;
  106576. private _onAfterCameraRenderObserver;
  106577. /**
  106578. * Gets the perf counter used for active meshes evaluation time
  106579. */
  106580. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106581. /**
  106582. * Gets the active meshes evaluation time capture status
  106583. */
  106584. /**
  106585. * Enable or disable the active meshes evaluation time capture
  106586. */
  106587. captureActiveMeshesEvaluationTime: boolean;
  106588. /**
  106589. * Gets the perf counter used for render targets render time
  106590. */
  106591. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106592. /**
  106593. * Gets the render targets render time capture status
  106594. */
  106595. /**
  106596. * Enable or disable the render targets render time capture
  106597. */
  106598. captureRenderTargetsRenderTime: boolean;
  106599. /**
  106600. * Gets the perf counter used for particles render time
  106601. */
  106602. readonly particlesRenderTimeCounter: PerfCounter;
  106603. /**
  106604. * Gets the particles render time capture status
  106605. */
  106606. /**
  106607. * Enable or disable the particles render time capture
  106608. */
  106609. captureParticlesRenderTime: boolean;
  106610. /**
  106611. * Gets the perf counter used for sprites render time
  106612. */
  106613. readonly spritesRenderTimeCounter: PerfCounter;
  106614. /**
  106615. * Gets the sprites render time capture status
  106616. */
  106617. /**
  106618. * Enable or disable the sprites render time capture
  106619. */
  106620. captureSpritesRenderTime: boolean;
  106621. /**
  106622. * Gets the perf counter used for physics time
  106623. */
  106624. readonly physicsTimeCounter: PerfCounter;
  106625. /**
  106626. * Gets the physics time capture status
  106627. */
  106628. /**
  106629. * Enable or disable the physics time capture
  106630. */
  106631. capturePhysicsTime: boolean;
  106632. /**
  106633. * Gets the perf counter used for animations time
  106634. */
  106635. readonly animationsTimeCounter: PerfCounter;
  106636. /**
  106637. * Gets the animations time capture status
  106638. */
  106639. /**
  106640. * Enable or disable the animations time capture
  106641. */
  106642. captureAnimationsTime: boolean;
  106643. /**
  106644. * Gets the perf counter used for frame time capture
  106645. */
  106646. readonly frameTimeCounter: PerfCounter;
  106647. /**
  106648. * Gets the frame time capture status
  106649. */
  106650. /**
  106651. * Enable or disable the frame time capture
  106652. */
  106653. captureFrameTime: boolean;
  106654. /**
  106655. * Gets the perf counter used for inter-frames time capture
  106656. */
  106657. readonly interFrameTimeCounter: PerfCounter;
  106658. /**
  106659. * Gets the inter-frames time capture status
  106660. */
  106661. /**
  106662. * Enable or disable the inter-frames time capture
  106663. */
  106664. captureInterFrameTime: boolean;
  106665. /**
  106666. * Gets the perf counter used for render time capture
  106667. */
  106668. readonly renderTimeCounter: PerfCounter;
  106669. /**
  106670. * Gets the render time capture status
  106671. */
  106672. /**
  106673. * Enable or disable the render time capture
  106674. */
  106675. captureRenderTime: boolean;
  106676. /**
  106677. * Gets the perf counter used for camera render time capture
  106678. */
  106679. readonly cameraRenderTimeCounter: PerfCounter;
  106680. /**
  106681. * Gets the camera render time capture status
  106682. */
  106683. /**
  106684. * Enable or disable the camera render time capture
  106685. */
  106686. captureCameraRenderTime: boolean;
  106687. /**
  106688. * Gets the perf counter used for draw calls
  106689. */
  106690. readonly drawCallsCounter: PerfCounter;
  106691. /**
  106692. * Instantiates a new scene instrumentation.
  106693. * This class can be used to get instrumentation data from a Babylon engine
  106694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106695. * @param scene Defines the scene to instrument
  106696. */
  106697. constructor(
  106698. /**
  106699. * Defines the scene to instrument
  106700. */
  106701. scene: Scene);
  106702. /**
  106703. * Dispose and release associated resources.
  106704. */
  106705. dispose(): void;
  106706. }
  106707. }
  106708. declare module BABYLON {
  106709. /** @hidden */
  106710. export var glowMapGenerationPixelShader: {
  106711. name: string;
  106712. shader: string;
  106713. };
  106714. }
  106715. declare module BABYLON {
  106716. /** @hidden */
  106717. export var glowMapGenerationVertexShader: {
  106718. name: string;
  106719. shader: string;
  106720. };
  106721. }
  106722. declare module BABYLON {
  106723. /**
  106724. * Effect layer options. This helps customizing the behaviour
  106725. * of the effect layer.
  106726. */
  106727. export interface IEffectLayerOptions {
  106728. /**
  106729. * Multiplication factor apply to the canvas size to compute the render target size
  106730. * used to generated the objects (the smaller the faster).
  106731. */
  106732. mainTextureRatio: number;
  106733. /**
  106734. * Enforces a fixed size texture to ensure effect stability across devices.
  106735. */
  106736. mainTextureFixedSize?: number;
  106737. /**
  106738. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106739. */
  106740. alphaBlendingMode: number;
  106741. /**
  106742. * The camera attached to the layer.
  106743. */
  106744. camera: Nullable<Camera>;
  106745. /**
  106746. * The rendering group to draw the layer in.
  106747. */
  106748. renderingGroupId: number;
  106749. }
  106750. /**
  106751. * The effect layer Helps adding post process effect blended with the main pass.
  106752. *
  106753. * This can be for instance use to generate glow or higlight effects on the scene.
  106754. *
  106755. * The effect layer class can not be used directly and is intented to inherited from to be
  106756. * customized per effects.
  106757. */
  106758. export abstract class EffectLayer {
  106759. private _vertexBuffers;
  106760. private _indexBuffer;
  106761. private _cachedDefines;
  106762. private _effectLayerMapGenerationEffect;
  106763. private _effectLayerOptions;
  106764. private _mergeEffect;
  106765. protected _scene: Scene;
  106766. protected _engine: Engine;
  106767. protected _maxSize: number;
  106768. protected _mainTextureDesiredSize: ISize;
  106769. protected _mainTexture: RenderTargetTexture;
  106770. protected _shouldRender: boolean;
  106771. protected _postProcesses: PostProcess[];
  106772. protected _textures: BaseTexture[];
  106773. protected _emissiveTextureAndColor: {
  106774. texture: Nullable<BaseTexture>;
  106775. color: Color4;
  106776. };
  106777. /**
  106778. * The name of the layer
  106779. */
  106780. name: string;
  106781. /**
  106782. * The clear color of the texture used to generate the glow map.
  106783. */
  106784. neutralColor: Color4;
  106785. /**
  106786. * Specifies wether the highlight layer is enabled or not.
  106787. */
  106788. isEnabled: boolean;
  106789. /**
  106790. * Gets the camera attached to the layer.
  106791. */
  106792. readonly camera: Nullable<Camera>;
  106793. /**
  106794. * Gets the rendering group id the layer should render in.
  106795. */
  106796. readonly renderingGroupId: number;
  106797. /**
  106798. * An event triggered when the effect layer has been disposed.
  106799. */
  106800. onDisposeObservable: Observable<EffectLayer>;
  106801. /**
  106802. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106803. */
  106804. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106805. /**
  106806. * An event triggered when the generated texture is being merged in the scene.
  106807. */
  106808. onBeforeComposeObservable: Observable<EffectLayer>;
  106809. /**
  106810. * An event triggered when the generated texture has been merged in the scene.
  106811. */
  106812. onAfterComposeObservable: Observable<EffectLayer>;
  106813. /**
  106814. * An event triggered when the efffect layer changes its size.
  106815. */
  106816. onSizeChangedObservable: Observable<EffectLayer>;
  106817. /** @hidden */
  106818. static _SceneComponentInitialization: (scene: Scene) => void;
  106819. /**
  106820. * Instantiates a new effect Layer and references it in the scene.
  106821. * @param name The name of the layer
  106822. * @param scene The scene to use the layer in
  106823. */
  106824. constructor(
  106825. /** The Friendly of the effect in the scene */
  106826. name: string, scene: Scene);
  106827. /**
  106828. * Get the effect name of the layer.
  106829. * @return The effect name
  106830. */
  106831. abstract getEffectName(): string;
  106832. /**
  106833. * Checks for the readiness of the element composing the layer.
  106834. * @param subMesh the mesh to check for
  106835. * @param useInstances specify wether or not to use instances to render the mesh
  106836. * @return true if ready otherwise, false
  106837. */
  106838. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106839. /**
  106840. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106841. * @returns true if the effect requires stencil during the main canvas render pass.
  106842. */
  106843. abstract needStencil(): boolean;
  106844. /**
  106845. * Create the merge effect. This is the shader use to blit the information back
  106846. * to the main canvas at the end of the scene rendering.
  106847. * @returns The effect containing the shader used to merge the effect on the main canvas
  106848. */
  106849. protected abstract _createMergeEffect(): Effect;
  106850. /**
  106851. * Creates the render target textures and post processes used in the effect layer.
  106852. */
  106853. protected abstract _createTextureAndPostProcesses(): void;
  106854. /**
  106855. * Implementation specific of rendering the generating effect on the main canvas.
  106856. * @param effect The effect used to render through
  106857. */
  106858. protected abstract _internalRender(effect: Effect): void;
  106859. /**
  106860. * Sets the required values for both the emissive texture and and the main color.
  106861. */
  106862. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106863. /**
  106864. * Free any resources and references associated to a mesh.
  106865. * Internal use
  106866. * @param mesh The mesh to free.
  106867. */
  106868. abstract _disposeMesh(mesh: Mesh): void;
  106869. /**
  106870. * Serializes this layer (Glow or Highlight for example)
  106871. * @returns a serialized layer object
  106872. */
  106873. abstract serialize?(): any;
  106874. /**
  106875. * Initializes the effect layer with the required options.
  106876. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106877. */
  106878. protected _init(options: Partial<IEffectLayerOptions>): void;
  106879. /**
  106880. * Generates the index buffer of the full screen quad blending to the main canvas.
  106881. */
  106882. private _generateIndexBuffer;
  106883. /**
  106884. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106885. */
  106886. private _generateVertexBuffer;
  106887. /**
  106888. * Sets the main texture desired size which is the closest power of two
  106889. * of the engine canvas size.
  106890. */
  106891. private _setMainTextureSize;
  106892. /**
  106893. * Creates the main texture for the effect layer.
  106894. */
  106895. protected _createMainTexture(): void;
  106896. /**
  106897. * Adds specific effects defines.
  106898. * @param defines The defines to add specifics to.
  106899. */
  106900. protected _addCustomEffectDefines(defines: string[]): void;
  106901. /**
  106902. * Checks for the readiness of the element composing the layer.
  106903. * @param subMesh the mesh to check for
  106904. * @param useInstances specify wether or not to use instances to render the mesh
  106905. * @param emissiveTexture the associated emissive texture used to generate the glow
  106906. * @return true if ready otherwise, false
  106907. */
  106908. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106909. /**
  106910. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106911. */
  106912. render(): void;
  106913. /**
  106914. * Determine if a given mesh will be used in the current effect.
  106915. * @param mesh mesh to test
  106916. * @returns true if the mesh will be used
  106917. */
  106918. hasMesh(mesh: AbstractMesh): boolean;
  106919. /**
  106920. * Returns true if the layer contains information to display, otherwise false.
  106921. * @returns true if the glow layer should be rendered
  106922. */
  106923. shouldRender(): boolean;
  106924. /**
  106925. * Returns true if the mesh should render, otherwise false.
  106926. * @param mesh The mesh to render
  106927. * @returns true if it should render otherwise false
  106928. */
  106929. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106930. /**
  106931. * Returns true if the mesh can be rendered, otherwise false.
  106932. * @param mesh The mesh to render
  106933. * @param material The material used on the mesh
  106934. * @returns true if it can be rendered otherwise false
  106935. */
  106936. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106937. /**
  106938. * Returns true if the mesh should render, otherwise false.
  106939. * @param mesh The mesh to render
  106940. * @returns true if it should render otherwise false
  106941. */
  106942. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106943. /**
  106944. * Renders the submesh passed in parameter to the generation map.
  106945. */
  106946. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  106947. /**
  106948. * Rebuild the required buffers.
  106949. * @hidden Internal use only.
  106950. */
  106951. _rebuild(): void;
  106952. /**
  106953. * Dispose only the render target textures and post process.
  106954. */
  106955. private _disposeTextureAndPostProcesses;
  106956. /**
  106957. * Dispose the highlight layer and free resources.
  106958. */
  106959. dispose(): void;
  106960. /**
  106961. * Gets the class name of the effect layer
  106962. * @returns the string with the class name of the effect layer
  106963. */
  106964. getClassName(): string;
  106965. /**
  106966. * Creates an effect layer from parsed effect layer data
  106967. * @param parsedEffectLayer defines effect layer data
  106968. * @param scene defines the current scene
  106969. * @param rootUrl defines the root URL containing the effect layer information
  106970. * @returns a parsed effect Layer
  106971. */
  106972. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106973. }
  106974. }
  106975. declare module BABYLON {
  106976. interface AbstractScene {
  106977. /**
  106978. * The list of effect layers (highlights/glow) added to the scene
  106979. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106980. * @see http://doc.babylonjs.com/how_to/glow_layer
  106981. */
  106982. effectLayers: Array<EffectLayer>;
  106983. /**
  106984. * Removes the given effect layer from this scene.
  106985. * @param toRemove defines the effect layer to remove
  106986. * @returns the index of the removed effect layer
  106987. */
  106988. removeEffectLayer(toRemove: EffectLayer): number;
  106989. /**
  106990. * Adds the given effect layer to this scene
  106991. * @param newEffectLayer defines the effect layer to add
  106992. */
  106993. addEffectLayer(newEffectLayer: EffectLayer): void;
  106994. }
  106995. /**
  106996. * Defines the layer scene component responsible to manage any effect layers
  106997. * in a given scene.
  106998. */
  106999. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107000. /**
  107001. * The component name helpfull to identify the component in the list of scene components.
  107002. */
  107003. readonly name: string;
  107004. /**
  107005. * The scene the component belongs to.
  107006. */
  107007. scene: Scene;
  107008. private _engine;
  107009. private _renderEffects;
  107010. private _needStencil;
  107011. private _previousStencilState;
  107012. /**
  107013. * Creates a new instance of the component for the given scene
  107014. * @param scene Defines the scene to register the component in
  107015. */
  107016. constructor(scene: Scene);
  107017. /**
  107018. * Registers the component in a given scene
  107019. */
  107020. register(): void;
  107021. /**
  107022. * Rebuilds the elements related to this component in case of
  107023. * context lost for instance.
  107024. */
  107025. rebuild(): void;
  107026. /**
  107027. * Serializes the component data to the specified json object
  107028. * @param serializationObject The object to serialize to
  107029. */
  107030. serialize(serializationObject: any): void;
  107031. /**
  107032. * Adds all the element from the container to the scene
  107033. * @param container the container holding the elements
  107034. */
  107035. addFromContainer(container: AbstractScene): void;
  107036. /**
  107037. * Removes all the elements in the container from the scene
  107038. * @param container contains the elements to remove
  107039. * @param dispose if the removed element should be disposed (default: false)
  107040. */
  107041. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107042. /**
  107043. * Disposes the component and the associated ressources.
  107044. */
  107045. dispose(): void;
  107046. private _isReadyForMesh;
  107047. private _renderMainTexture;
  107048. private _setStencil;
  107049. private _setStencilBack;
  107050. private _draw;
  107051. private _drawCamera;
  107052. private _drawRenderingGroup;
  107053. }
  107054. }
  107055. declare module BABYLON {
  107056. /** @hidden */
  107057. export var glowMapMergePixelShader: {
  107058. name: string;
  107059. shader: string;
  107060. };
  107061. }
  107062. declare module BABYLON {
  107063. /** @hidden */
  107064. export var glowMapMergeVertexShader: {
  107065. name: string;
  107066. shader: string;
  107067. };
  107068. }
  107069. declare module BABYLON {
  107070. interface AbstractScene {
  107071. /**
  107072. * Return a the first highlight layer of the scene with a given name.
  107073. * @param name The name of the highlight layer to look for.
  107074. * @return The highlight layer if found otherwise null.
  107075. */
  107076. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107077. }
  107078. /**
  107079. * Glow layer options. This helps customizing the behaviour
  107080. * of the glow layer.
  107081. */
  107082. export interface IGlowLayerOptions {
  107083. /**
  107084. * Multiplication factor apply to the canvas size to compute the render target size
  107085. * used to generated the glowing objects (the smaller the faster).
  107086. */
  107087. mainTextureRatio: number;
  107088. /**
  107089. * Enforces a fixed size texture to ensure resize independant blur.
  107090. */
  107091. mainTextureFixedSize?: number;
  107092. /**
  107093. * How big is the kernel of the blur texture.
  107094. */
  107095. blurKernelSize: number;
  107096. /**
  107097. * The camera attached to the layer.
  107098. */
  107099. camera: Nullable<Camera>;
  107100. /**
  107101. * Enable MSAA by chosing the number of samples.
  107102. */
  107103. mainTextureSamples?: number;
  107104. /**
  107105. * The rendering group to draw the layer in.
  107106. */
  107107. renderingGroupId: number;
  107108. }
  107109. /**
  107110. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107111. *
  107112. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107113. * glowy meshes to your scene.
  107114. *
  107115. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107116. */
  107117. export class GlowLayer extends EffectLayer {
  107118. /**
  107119. * Effect Name of the layer.
  107120. */
  107121. static readonly EffectName: string;
  107122. /**
  107123. * The default blur kernel size used for the glow.
  107124. */
  107125. static DefaultBlurKernelSize: number;
  107126. /**
  107127. * The default texture size ratio used for the glow.
  107128. */
  107129. static DefaultTextureRatio: number;
  107130. /**
  107131. * Sets the kernel size of the blur.
  107132. */
  107133. /**
  107134. * Gets the kernel size of the blur.
  107135. */
  107136. blurKernelSize: number;
  107137. /**
  107138. * Sets the glow intensity.
  107139. */
  107140. /**
  107141. * Gets the glow intensity.
  107142. */
  107143. intensity: number;
  107144. private _options;
  107145. private _intensity;
  107146. private _horizontalBlurPostprocess1;
  107147. private _verticalBlurPostprocess1;
  107148. private _horizontalBlurPostprocess2;
  107149. private _verticalBlurPostprocess2;
  107150. private _blurTexture1;
  107151. private _blurTexture2;
  107152. private _postProcesses1;
  107153. private _postProcesses2;
  107154. private _includedOnlyMeshes;
  107155. private _excludedMeshes;
  107156. /**
  107157. * Callback used to let the user override the color selection on a per mesh basis
  107158. */
  107159. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107160. /**
  107161. * Callback used to let the user override the texture selection on a per mesh basis
  107162. */
  107163. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107164. /**
  107165. * Instantiates a new glow Layer and references it to the scene.
  107166. * @param name The name of the layer
  107167. * @param scene The scene to use the layer in
  107168. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107169. */
  107170. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107171. /**
  107172. * Get the effect name of the layer.
  107173. * @return The effect name
  107174. */
  107175. getEffectName(): string;
  107176. /**
  107177. * Create the merge effect. This is the shader use to blit the information back
  107178. * to the main canvas at the end of the scene rendering.
  107179. */
  107180. protected _createMergeEffect(): Effect;
  107181. /**
  107182. * Creates the render target textures and post processes used in the glow layer.
  107183. */
  107184. protected _createTextureAndPostProcesses(): void;
  107185. /**
  107186. * Checks for the readiness of the element composing the layer.
  107187. * @param subMesh the mesh to check for
  107188. * @param useInstances specify wether or not to use instances to render the mesh
  107189. * @param emissiveTexture the associated emissive texture used to generate the glow
  107190. * @return true if ready otherwise, false
  107191. */
  107192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107193. /**
  107194. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107195. */
  107196. needStencil(): boolean;
  107197. /**
  107198. * Returns true if the mesh can be rendered, otherwise false.
  107199. * @param mesh The mesh to render
  107200. * @param material The material used on the mesh
  107201. * @returns true if it can be rendered otherwise false
  107202. */
  107203. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107204. /**
  107205. * Implementation specific of rendering the generating effect on the main canvas.
  107206. * @param effect The effect used to render through
  107207. */
  107208. protected _internalRender(effect: Effect): void;
  107209. /**
  107210. * Sets the required values for both the emissive texture and and the main color.
  107211. */
  107212. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107213. /**
  107214. * Returns true if the mesh should render, otherwise false.
  107215. * @param mesh The mesh to render
  107216. * @returns true if it should render otherwise false
  107217. */
  107218. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107219. /**
  107220. * Adds specific effects defines.
  107221. * @param defines The defines to add specifics to.
  107222. */
  107223. protected _addCustomEffectDefines(defines: string[]): void;
  107224. /**
  107225. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107226. * @param mesh The mesh to exclude from the glow layer
  107227. */
  107228. addExcludedMesh(mesh: Mesh): void;
  107229. /**
  107230. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107231. * @param mesh The mesh to remove
  107232. */
  107233. removeExcludedMesh(mesh: Mesh): void;
  107234. /**
  107235. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107236. * @param mesh The mesh to include in the glow layer
  107237. */
  107238. addIncludedOnlyMesh(mesh: Mesh): void;
  107239. /**
  107240. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107241. * @param mesh The mesh to remove
  107242. */
  107243. removeIncludedOnlyMesh(mesh: Mesh): void;
  107244. /**
  107245. * Determine if a given mesh will be used in the glow layer
  107246. * @param mesh The mesh to test
  107247. * @returns true if the mesh will be highlighted by the current glow layer
  107248. */
  107249. hasMesh(mesh: AbstractMesh): boolean;
  107250. /**
  107251. * Free any resources and references associated to a mesh.
  107252. * Internal use
  107253. * @param mesh The mesh to free.
  107254. * @hidden
  107255. */
  107256. _disposeMesh(mesh: Mesh): void;
  107257. /**
  107258. * Gets the class name of the effect layer
  107259. * @returns the string with the class name of the effect layer
  107260. */
  107261. getClassName(): string;
  107262. /**
  107263. * Serializes this glow layer
  107264. * @returns a serialized glow layer object
  107265. */
  107266. serialize(): any;
  107267. /**
  107268. * Creates a Glow Layer from parsed glow layer data
  107269. * @param parsedGlowLayer defines glow layer data
  107270. * @param scene defines the current scene
  107271. * @param rootUrl defines the root URL containing the glow layer information
  107272. * @returns a parsed Glow Layer
  107273. */
  107274. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107275. }
  107276. }
  107277. declare module BABYLON {
  107278. /** @hidden */
  107279. export var glowBlurPostProcessPixelShader: {
  107280. name: string;
  107281. shader: string;
  107282. };
  107283. }
  107284. declare module BABYLON {
  107285. interface AbstractScene {
  107286. /**
  107287. * Return a the first highlight layer of the scene with a given name.
  107288. * @param name The name of the highlight layer to look for.
  107289. * @return The highlight layer if found otherwise null.
  107290. */
  107291. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107292. }
  107293. /**
  107294. * Highlight layer options. This helps customizing the behaviour
  107295. * of the highlight layer.
  107296. */
  107297. export interface IHighlightLayerOptions {
  107298. /**
  107299. * Multiplication factor apply to the canvas size to compute the render target size
  107300. * used to generated the glowing objects (the smaller the faster).
  107301. */
  107302. mainTextureRatio: number;
  107303. /**
  107304. * Enforces a fixed size texture to ensure resize independant blur.
  107305. */
  107306. mainTextureFixedSize?: number;
  107307. /**
  107308. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107309. * of the picture to blur (the smaller the faster).
  107310. */
  107311. blurTextureSizeRatio: number;
  107312. /**
  107313. * How big in texel of the blur texture is the vertical blur.
  107314. */
  107315. blurVerticalSize: number;
  107316. /**
  107317. * How big in texel of the blur texture is the horizontal blur.
  107318. */
  107319. blurHorizontalSize: number;
  107320. /**
  107321. * Alpha blending mode used to apply the blur. Default is combine.
  107322. */
  107323. alphaBlendingMode: number;
  107324. /**
  107325. * The camera attached to the layer.
  107326. */
  107327. camera: Nullable<Camera>;
  107328. /**
  107329. * Should we display highlight as a solid stroke?
  107330. */
  107331. isStroke?: boolean;
  107332. /**
  107333. * The rendering group to draw the layer in.
  107334. */
  107335. renderingGroupId: number;
  107336. }
  107337. /**
  107338. * The highlight layer Helps adding a glow effect around a mesh.
  107339. *
  107340. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107341. * glowy meshes to your scene.
  107342. *
  107343. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107344. */
  107345. export class HighlightLayer extends EffectLayer {
  107346. name: string;
  107347. /**
  107348. * Effect Name of the highlight layer.
  107349. */
  107350. static readonly EffectName: string;
  107351. /**
  107352. * The neutral color used during the preparation of the glow effect.
  107353. * This is black by default as the blend operation is a blend operation.
  107354. */
  107355. static NeutralColor: Color4;
  107356. /**
  107357. * Stencil value used for glowing meshes.
  107358. */
  107359. static GlowingMeshStencilReference: number;
  107360. /**
  107361. * Stencil value used for the other meshes in the scene.
  107362. */
  107363. static NormalMeshStencilReference: number;
  107364. /**
  107365. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107366. */
  107367. innerGlow: boolean;
  107368. /**
  107369. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107370. */
  107371. outerGlow: boolean;
  107372. /**
  107373. * Specifies the horizontal size of the blur.
  107374. */
  107375. /**
  107376. * Gets the horizontal size of the blur.
  107377. */
  107378. blurHorizontalSize: number;
  107379. /**
  107380. * Specifies the vertical size of the blur.
  107381. */
  107382. /**
  107383. * Gets the vertical size of the blur.
  107384. */
  107385. blurVerticalSize: number;
  107386. /**
  107387. * An event triggered when the highlight layer is being blurred.
  107388. */
  107389. onBeforeBlurObservable: Observable<HighlightLayer>;
  107390. /**
  107391. * An event triggered when the highlight layer has been blurred.
  107392. */
  107393. onAfterBlurObservable: Observable<HighlightLayer>;
  107394. private _instanceGlowingMeshStencilReference;
  107395. private _options;
  107396. private _downSamplePostprocess;
  107397. private _horizontalBlurPostprocess;
  107398. private _verticalBlurPostprocess;
  107399. private _blurTexture;
  107400. private _meshes;
  107401. private _excludedMeshes;
  107402. /**
  107403. * Instantiates a new highlight Layer and references it to the scene..
  107404. * @param name The name of the layer
  107405. * @param scene The scene to use the layer in
  107406. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107407. */
  107408. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107409. /**
  107410. * Get the effect name of the layer.
  107411. * @return The effect name
  107412. */
  107413. getEffectName(): string;
  107414. /**
  107415. * Create the merge effect. This is the shader use to blit the information back
  107416. * to the main canvas at the end of the scene rendering.
  107417. */
  107418. protected _createMergeEffect(): Effect;
  107419. /**
  107420. * Creates the render target textures and post processes used in the highlight layer.
  107421. */
  107422. protected _createTextureAndPostProcesses(): void;
  107423. /**
  107424. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107425. */
  107426. needStencil(): boolean;
  107427. /**
  107428. * Checks for the readiness of the element composing the layer.
  107429. * @param subMesh the mesh to check for
  107430. * @param useInstances specify wether or not to use instances to render the mesh
  107431. * @param emissiveTexture the associated emissive texture used to generate the glow
  107432. * @return true if ready otherwise, false
  107433. */
  107434. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107435. /**
  107436. * Implementation specific of rendering the generating effect on the main canvas.
  107437. * @param effect The effect used to render through
  107438. */
  107439. protected _internalRender(effect: Effect): void;
  107440. /**
  107441. * Returns true if the layer contains information to display, otherwise false.
  107442. */
  107443. shouldRender(): boolean;
  107444. /**
  107445. * Returns true if the mesh should render, otherwise false.
  107446. * @param mesh The mesh to render
  107447. * @returns true if it should render otherwise false
  107448. */
  107449. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107450. /**
  107451. * Sets the required values for both the emissive texture and and the main color.
  107452. */
  107453. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107454. /**
  107455. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107456. * @param mesh The mesh to exclude from the highlight layer
  107457. */
  107458. addExcludedMesh(mesh: Mesh): void;
  107459. /**
  107460. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107461. * @param mesh The mesh to highlight
  107462. */
  107463. removeExcludedMesh(mesh: Mesh): void;
  107464. /**
  107465. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107466. * @param mesh mesh to test
  107467. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107468. */
  107469. hasMesh(mesh: AbstractMesh): boolean;
  107470. /**
  107471. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107472. * @param mesh The mesh to highlight
  107473. * @param color The color of the highlight
  107474. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107475. */
  107476. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107477. /**
  107478. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107479. * @param mesh The mesh to highlight
  107480. */
  107481. removeMesh(mesh: Mesh): void;
  107482. /**
  107483. * Force the stencil to the normal expected value for none glowing parts
  107484. */
  107485. private _defaultStencilReference;
  107486. /**
  107487. * Free any resources and references associated to a mesh.
  107488. * Internal use
  107489. * @param mesh The mesh to free.
  107490. * @hidden
  107491. */
  107492. _disposeMesh(mesh: Mesh): void;
  107493. /**
  107494. * Dispose the highlight layer and free resources.
  107495. */
  107496. dispose(): void;
  107497. /**
  107498. * Gets the class name of the effect layer
  107499. * @returns the string with the class name of the effect layer
  107500. */
  107501. getClassName(): string;
  107502. /**
  107503. * Serializes this Highlight layer
  107504. * @returns a serialized Highlight layer object
  107505. */
  107506. serialize(): any;
  107507. /**
  107508. * Creates a Highlight layer from parsed Highlight layer data
  107509. * @param parsedHightlightLayer defines the Highlight layer data
  107510. * @param scene defines the current scene
  107511. * @param rootUrl defines the root URL containing the Highlight layer information
  107512. * @returns a parsed Highlight layer
  107513. */
  107514. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107515. }
  107516. }
  107517. declare module BABYLON {
  107518. /** @hidden */
  107519. export var lensFlarePixelShader: {
  107520. name: string;
  107521. shader: string;
  107522. };
  107523. }
  107524. declare module BABYLON {
  107525. /** @hidden */
  107526. export var lensFlareVertexShader: {
  107527. name: string;
  107528. shader: string;
  107529. };
  107530. }
  107531. declare module BABYLON {
  107532. /**
  107533. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107534. * It is usually composed of several `lensFlare`.
  107535. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107536. */
  107537. export class LensFlareSystem {
  107538. /**
  107539. * Define the name of the lens flare system
  107540. */
  107541. name: string;
  107542. /**
  107543. * List of lens flares used in this system.
  107544. */
  107545. lensFlares: LensFlare[];
  107546. /**
  107547. * Define a limit from the border the lens flare can be visible.
  107548. */
  107549. borderLimit: number;
  107550. /**
  107551. * Define a viewport border we do not want to see the lens flare in.
  107552. */
  107553. viewportBorder: number;
  107554. /**
  107555. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107556. */
  107557. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107558. /**
  107559. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107560. */
  107561. layerMask: number;
  107562. /**
  107563. * Define the id of the lens flare system in the scene.
  107564. * (equal to name by default)
  107565. */
  107566. id: string;
  107567. private _scene;
  107568. private _emitter;
  107569. private _vertexBuffers;
  107570. private _indexBuffer;
  107571. private _effect;
  107572. private _positionX;
  107573. private _positionY;
  107574. private _isEnabled;
  107575. /** @hidden */
  107576. static _SceneComponentInitialization: (scene: Scene) => void;
  107577. /**
  107578. * Instantiates a lens flare system.
  107579. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107580. * It is usually composed of several `lensFlare`.
  107581. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107582. * @param name Define the name of the lens flare system in the scene
  107583. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107584. * @param scene Define the scene the lens flare system belongs to
  107585. */
  107586. constructor(
  107587. /**
  107588. * Define the name of the lens flare system
  107589. */
  107590. name: string, emitter: any, scene: Scene);
  107591. /**
  107592. * Define if the lens flare system is enabled.
  107593. */
  107594. isEnabled: boolean;
  107595. /**
  107596. * Get the scene the effects belongs to.
  107597. * @returns the scene holding the lens flare system
  107598. */
  107599. getScene(): Scene;
  107600. /**
  107601. * Get the emitter of the lens flare system.
  107602. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107603. * @returns the emitter of the lens flare system
  107604. */
  107605. getEmitter(): any;
  107606. /**
  107607. * Set the emitter of the lens flare system.
  107608. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107609. * @param newEmitter Define the new emitter of the system
  107610. */
  107611. setEmitter(newEmitter: any): void;
  107612. /**
  107613. * Get the lens flare system emitter position.
  107614. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107615. * @returns the position
  107616. */
  107617. getEmitterPosition(): Vector3;
  107618. /**
  107619. * @hidden
  107620. */
  107621. computeEffectivePosition(globalViewport: Viewport): boolean;
  107622. /** @hidden */
  107623. _isVisible(): boolean;
  107624. /**
  107625. * @hidden
  107626. */
  107627. render(): boolean;
  107628. /**
  107629. * Dispose and release the lens flare with its associated resources.
  107630. */
  107631. dispose(): void;
  107632. /**
  107633. * Parse a lens flare system from a JSON repressentation
  107634. * @param parsedLensFlareSystem Define the JSON to parse
  107635. * @param scene Define the scene the parsed system should be instantiated in
  107636. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107637. * @returns the parsed system
  107638. */
  107639. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107640. /**
  107641. * Serialize the current Lens Flare System into a JSON representation.
  107642. * @returns the serialized JSON
  107643. */
  107644. serialize(): any;
  107645. }
  107646. }
  107647. declare module BABYLON {
  107648. /**
  107649. * This represents one of the lens effect in a `lensFlareSystem`.
  107650. * It controls one of the indiviual texture used in the effect.
  107651. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107652. */
  107653. export class LensFlare {
  107654. /**
  107655. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107656. */
  107657. size: number;
  107658. /**
  107659. * 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.
  107660. */
  107661. position: number;
  107662. /**
  107663. * Define the lens color.
  107664. */
  107665. color: Color3;
  107666. /**
  107667. * Define the lens texture.
  107668. */
  107669. texture: Nullable<Texture>;
  107670. /**
  107671. * Define the alpha mode to render this particular lens.
  107672. */
  107673. alphaMode: number;
  107674. private _system;
  107675. /**
  107676. * Creates a new Lens Flare.
  107677. * This represents one of the lens effect in a `lensFlareSystem`.
  107678. * It controls one of the indiviual texture used in the effect.
  107679. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107680. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107681. * @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.
  107682. * @param color Define the lens color
  107683. * @param imgUrl Define the lens texture url
  107684. * @param system Define the `lensFlareSystem` this flare is part of
  107685. * @returns The newly created Lens Flare
  107686. */
  107687. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107688. /**
  107689. * Instantiates a new Lens Flare.
  107690. * This represents one of the lens effect in a `lensFlareSystem`.
  107691. * It controls one of the indiviual texture used in the effect.
  107692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107693. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107694. * @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.
  107695. * @param color Define the lens color
  107696. * @param imgUrl Define the lens texture url
  107697. * @param system Define the `lensFlareSystem` this flare is part of
  107698. */
  107699. constructor(
  107700. /**
  107701. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107702. */
  107703. size: number,
  107704. /**
  107705. * 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.
  107706. */
  107707. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107708. /**
  107709. * Dispose and release the lens flare with its associated resources.
  107710. */
  107711. dispose(): void;
  107712. }
  107713. }
  107714. declare module BABYLON {
  107715. interface AbstractScene {
  107716. /**
  107717. * The list of lens flare system added to the scene
  107718. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107719. */
  107720. lensFlareSystems: Array<LensFlareSystem>;
  107721. /**
  107722. * Removes the given lens flare system from this scene.
  107723. * @param toRemove The lens flare system to remove
  107724. * @returns The index of the removed lens flare system
  107725. */
  107726. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107727. /**
  107728. * Adds the given lens flare system to this scene
  107729. * @param newLensFlareSystem The lens flare system to add
  107730. */
  107731. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107732. /**
  107733. * Gets a lens flare system using its name
  107734. * @param name defines the name to look for
  107735. * @returns the lens flare system or null if not found
  107736. */
  107737. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107738. /**
  107739. * Gets a lens flare system using its id
  107740. * @param id defines the id to look for
  107741. * @returns the lens flare system or null if not found
  107742. */
  107743. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107744. }
  107745. /**
  107746. * Defines the lens flare scene component responsible to manage any lens flares
  107747. * in a given scene.
  107748. */
  107749. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107750. /**
  107751. * The component name helpfull to identify the component in the list of scene components.
  107752. */
  107753. readonly name: string;
  107754. /**
  107755. * The scene the component belongs to.
  107756. */
  107757. scene: Scene;
  107758. /**
  107759. * Creates a new instance of the component for the given scene
  107760. * @param scene Defines the scene to register the component in
  107761. */
  107762. constructor(scene: Scene);
  107763. /**
  107764. * Registers the component in a given scene
  107765. */
  107766. register(): void;
  107767. /**
  107768. * Rebuilds the elements related to this component in case of
  107769. * context lost for instance.
  107770. */
  107771. rebuild(): void;
  107772. /**
  107773. * Adds all the element from the container to the scene
  107774. * @param container the container holding the elements
  107775. */
  107776. addFromContainer(container: AbstractScene): void;
  107777. /**
  107778. * Removes all the elements in the container from the scene
  107779. * @param container contains the elements to remove
  107780. * @param dispose if the removed element should be disposed (default: false)
  107781. */
  107782. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107783. /**
  107784. * Serializes the component data to the specified json object
  107785. * @param serializationObject The object to serialize to
  107786. */
  107787. serialize(serializationObject: any): void;
  107788. /**
  107789. * Disposes the component and the associated ressources.
  107790. */
  107791. dispose(): void;
  107792. private _draw;
  107793. }
  107794. }
  107795. declare module BABYLON {
  107796. /**
  107797. * Defines the shadow generator component responsible to manage any shadow generators
  107798. * in a given scene.
  107799. */
  107800. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107801. /**
  107802. * The component name helpfull to identify the component in the list of scene components.
  107803. */
  107804. readonly name: string;
  107805. /**
  107806. * The scene the component belongs to.
  107807. */
  107808. scene: Scene;
  107809. /**
  107810. * Creates a new instance of the component for the given scene
  107811. * @param scene Defines the scene to register the component in
  107812. */
  107813. constructor(scene: Scene);
  107814. /**
  107815. * Registers the component in a given scene
  107816. */
  107817. register(): void;
  107818. /**
  107819. * Rebuilds the elements related to this component in case of
  107820. * context lost for instance.
  107821. */
  107822. rebuild(): void;
  107823. /**
  107824. * Serializes the component data to the specified json object
  107825. * @param serializationObject The object to serialize to
  107826. */
  107827. serialize(serializationObject: any): void;
  107828. /**
  107829. * Adds all the element from the container to the scene
  107830. * @param container the container holding the elements
  107831. */
  107832. addFromContainer(container: AbstractScene): void;
  107833. /**
  107834. * Removes all the elements in the container from the scene
  107835. * @param container contains the elements to remove
  107836. * @param dispose if the removed element should be disposed (default: false)
  107837. */
  107838. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107839. /**
  107840. * Rebuilds the elements related to this component in case of
  107841. * context lost for instance.
  107842. */
  107843. dispose(): void;
  107844. private _gatherRenderTargets;
  107845. }
  107846. }
  107847. declare module BABYLON {
  107848. /**
  107849. * A point light is a light defined by an unique point in world space.
  107850. * The light is emitted in every direction from this point.
  107851. * A good example of a point light is a standard light bulb.
  107852. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107853. */
  107854. export class PointLight extends ShadowLight {
  107855. private _shadowAngle;
  107856. /**
  107857. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107858. * This specifies what angle the shadow will use to be created.
  107859. *
  107860. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107861. */
  107862. /**
  107863. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107864. * This specifies what angle the shadow will use to be created.
  107865. *
  107866. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107867. */
  107868. shadowAngle: number;
  107869. /**
  107870. * Gets the direction if it has been set.
  107871. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107872. */
  107873. /**
  107874. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107875. */
  107876. direction: Vector3;
  107877. /**
  107878. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107879. * A PointLight emits the light in every direction.
  107880. * It can cast shadows.
  107881. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107882. * ```javascript
  107883. * var pointLight = new PointLight("pl", camera.position, scene);
  107884. * ```
  107885. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107886. * @param name The light friendly name
  107887. * @param position The position of the point light in the scene
  107888. * @param scene The scene the lights belongs to
  107889. */
  107890. constructor(name: string, position: Vector3, scene: Scene);
  107891. /**
  107892. * Returns the string "PointLight"
  107893. * @returns the class name
  107894. */
  107895. getClassName(): string;
  107896. /**
  107897. * Returns the integer 0.
  107898. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107899. */
  107900. getTypeID(): number;
  107901. /**
  107902. * Specifies wether or not the shadowmap should be a cube texture.
  107903. * @returns true if the shadowmap needs to be a cube texture.
  107904. */
  107905. needCube(): boolean;
  107906. /**
  107907. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107908. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107909. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107910. */
  107911. getShadowDirection(faceIndex?: number): Vector3;
  107912. /**
  107913. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107914. * - fov = PI / 2
  107915. * - aspect ratio : 1.0
  107916. * - z-near and far equal to the active camera minZ and maxZ.
  107917. * Returns the PointLight.
  107918. */
  107919. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107920. protected _buildUniformLayout(): void;
  107921. /**
  107922. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107923. * @param effect The effect to update
  107924. * @param lightIndex The index of the light in the effect to update
  107925. * @returns The point light
  107926. */
  107927. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107928. /**
  107929. * Prepares the list of defines specific to the light type.
  107930. * @param defines the list of defines
  107931. * @param lightIndex defines the index of the light for the effect
  107932. */
  107933. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107934. }
  107935. }
  107936. declare module BABYLON {
  107937. /**
  107938. * Header information of HDR texture files.
  107939. */
  107940. export interface HDRInfo {
  107941. /**
  107942. * The height of the texture in pixels.
  107943. */
  107944. height: number;
  107945. /**
  107946. * The width of the texture in pixels.
  107947. */
  107948. width: number;
  107949. /**
  107950. * The index of the beginning of the data in the binary file.
  107951. */
  107952. dataPosition: number;
  107953. }
  107954. /**
  107955. * This groups tools to convert HDR texture to native colors array.
  107956. */
  107957. export class HDRTools {
  107958. private static Ldexp;
  107959. private static Rgbe2float;
  107960. private static readStringLine;
  107961. /**
  107962. * Reads header information from an RGBE texture stored in a native array.
  107963. * More information on this format are available here:
  107964. * https://en.wikipedia.org/wiki/RGBE_image_format
  107965. *
  107966. * @param uint8array The binary file stored in native array.
  107967. * @return The header information.
  107968. */
  107969. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107970. /**
  107971. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107972. * This RGBE texture needs to store the information as a panorama.
  107973. *
  107974. * More information on this format are available here:
  107975. * https://en.wikipedia.org/wiki/RGBE_image_format
  107976. *
  107977. * @param buffer The binary file stored in an array buffer.
  107978. * @param size The expected size of the extracted cubemap.
  107979. * @return The Cube Map information.
  107980. */
  107981. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107982. /**
  107983. * Returns the pixels data extracted from an RGBE texture.
  107984. * This pixels will be stored left to right up to down in the R G B order in one array.
  107985. *
  107986. * More information on this format are available here:
  107987. * https://en.wikipedia.org/wiki/RGBE_image_format
  107988. *
  107989. * @param uint8array The binary file stored in an array buffer.
  107990. * @param hdrInfo The header information of the file.
  107991. * @return The pixels data in RGB right to left up to down order.
  107992. */
  107993. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107994. private static RGBE_ReadPixels_RLE;
  107995. }
  107996. }
  107997. declare module BABYLON {
  107998. /**
  107999. * This represents a texture coming from an HDR input.
  108000. *
  108001. * The only supported format is currently panorama picture stored in RGBE format.
  108002. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108003. */
  108004. export class HDRCubeTexture extends BaseTexture {
  108005. private static _facesMapping;
  108006. private _generateHarmonics;
  108007. private _noMipmap;
  108008. private _textureMatrix;
  108009. private _size;
  108010. private _onLoad;
  108011. private _onError;
  108012. /**
  108013. * The texture URL.
  108014. */
  108015. url: string;
  108016. /**
  108017. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108018. */
  108019. coordinatesMode: number;
  108020. protected _isBlocking: boolean;
  108021. /**
  108022. * Sets wether or not the texture is blocking during loading.
  108023. */
  108024. /**
  108025. * Gets wether or not the texture is blocking during loading.
  108026. */
  108027. isBlocking: boolean;
  108028. protected _rotationY: number;
  108029. /**
  108030. * Sets texture matrix rotation angle around Y axis in radians.
  108031. */
  108032. /**
  108033. * Gets texture matrix rotation angle around Y axis radians.
  108034. */
  108035. rotationY: number;
  108036. /**
  108037. * Gets or sets the center of the bounding box associated with the cube texture
  108038. * It must define where the camera used to render the texture was set
  108039. */
  108040. boundingBoxPosition: Vector3;
  108041. private _boundingBoxSize;
  108042. /**
  108043. * Gets or sets the size of the bounding box associated with the cube texture
  108044. * When defined, the cubemap will switch to local mode
  108045. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108046. * @example https://www.babylonjs-playground.com/#RNASML
  108047. */
  108048. boundingBoxSize: Vector3;
  108049. /**
  108050. * Instantiates an HDRTexture from the following parameters.
  108051. *
  108052. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108053. * @param scene The scene the texture will be used in
  108054. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108055. * @param noMipmap Forces to not generate the mipmap if true
  108056. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108057. * @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)
  108058. * @param reserved Reserved flag for internal use.
  108059. */
  108060. 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>);
  108061. /**
  108062. * Get the current class name of the texture useful for serialization or dynamic coding.
  108063. * @returns "HDRCubeTexture"
  108064. */
  108065. getClassName(): string;
  108066. /**
  108067. * Occurs when the file is raw .hdr file.
  108068. */
  108069. private loadTexture;
  108070. clone(): HDRCubeTexture;
  108071. delayLoad(): void;
  108072. /**
  108073. * Get the texture reflection matrix used to rotate/transform the reflection.
  108074. * @returns the reflection matrix
  108075. */
  108076. getReflectionTextureMatrix(): Matrix;
  108077. /**
  108078. * Set the texture reflection matrix used to rotate/transform the reflection.
  108079. * @param value Define the reflection matrix to set
  108080. */
  108081. setReflectionTextureMatrix(value: Matrix): void;
  108082. /**
  108083. * Parses a JSON representation of an HDR Texture in order to create the texture
  108084. * @param parsedTexture Define the JSON representation
  108085. * @param scene Define the scene the texture should be created in
  108086. * @param rootUrl Define the root url in case we need to load relative dependencies
  108087. * @returns the newly created texture after parsing
  108088. */
  108089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108090. serialize(): any;
  108091. }
  108092. }
  108093. declare module BABYLON {
  108094. /**
  108095. * Class used to control physics engine
  108096. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108097. */
  108098. export class PhysicsEngine implements IPhysicsEngine {
  108099. private _physicsPlugin;
  108100. /**
  108101. * Global value used to control the smallest number supported by the simulation
  108102. */
  108103. static Epsilon: number;
  108104. private _impostors;
  108105. private _joints;
  108106. /**
  108107. * Gets the gravity vector used by the simulation
  108108. */
  108109. gravity: Vector3;
  108110. /**
  108111. * Factory used to create the default physics plugin.
  108112. * @returns The default physics plugin
  108113. */
  108114. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108115. /**
  108116. * Creates a new Physics Engine
  108117. * @param gravity defines the gravity vector used by the simulation
  108118. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108119. */
  108120. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108121. /**
  108122. * Sets the gravity vector used by the simulation
  108123. * @param gravity defines the gravity vector to use
  108124. */
  108125. setGravity(gravity: Vector3): void;
  108126. /**
  108127. * Set the time step of the physics engine.
  108128. * Default is 1/60.
  108129. * To slow it down, enter 1/600 for example.
  108130. * To speed it up, 1/30
  108131. * @param newTimeStep defines the new timestep to apply to this world.
  108132. */
  108133. setTimeStep(newTimeStep?: number): void;
  108134. /**
  108135. * Get the time step of the physics engine.
  108136. * @returns the current time step
  108137. */
  108138. getTimeStep(): number;
  108139. /**
  108140. * Release all resources
  108141. */
  108142. dispose(): void;
  108143. /**
  108144. * Gets the name of the current physics plugin
  108145. * @returns the name of the plugin
  108146. */
  108147. getPhysicsPluginName(): string;
  108148. /**
  108149. * Adding a new impostor for the impostor tracking.
  108150. * This will be done by the impostor itself.
  108151. * @param impostor the impostor to add
  108152. */
  108153. addImpostor(impostor: PhysicsImpostor): void;
  108154. /**
  108155. * Remove an impostor from the engine.
  108156. * This impostor and its mesh will not longer be updated by the physics engine.
  108157. * @param impostor the impostor to remove
  108158. */
  108159. removeImpostor(impostor: PhysicsImpostor): void;
  108160. /**
  108161. * Add a joint to the physics engine
  108162. * @param mainImpostor defines the main impostor to which the joint is added.
  108163. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108164. * @param joint defines the joint that will connect both impostors.
  108165. */
  108166. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108167. /**
  108168. * Removes a joint from the simulation
  108169. * @param mainImpostor defines the impostor used with the joint
  108170. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108171. * @param joint defines the joint to remove
  108172. */
  108173. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108174. /**
  108175. * Called by the scene. No need to call it.
  108176. * @param delta defines the timespam between frames
  108177. */
  108178. _step(delta: number): void;
  108179. /**
  108180. * Gets the current plugin used to run the simulation
  108181. * @returns current plugin
  108182. */
  108183. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108184. /**
  108185. * Gets the list of physic impostors
  108186. * @returns an array of PhysicsImpostor
  108187. */
  108188. getImpostors(): Array<PhysicsImpostor>;
  108189. /**
  108190. * Gets the impostor for a physics enabled object
  108191. * @param object defines the object impersonated by the impostor
  108192. * @returns the PhysicsImpostor or null if not found
  108193. */
  108194. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108195. /**
  108196. * Gets the impostor for a physics body object
  108197. * @param body defines physics body used by the impostor
  108198. * @returns the PhysicsImpostor or null if not found
  108199. */
  108200. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108201. /**
  108202. * Does a raycast in the physics world
  108203. * @param from when should the ray start?
  108204. * @param to when should the ray end?
  108205. * @returns PhysicsRaycastResult
  108206. */
  108207. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108208. }
  108209. }
  108210. declare module BABYLON {
  108211. /** @hidden */
  108212. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108213. private _useDeltaForWorldStep;
  108214. world: any;
  108215. name: string;
  108216. private _physicsMaterials;
  108217. private _fixedTimeStep;
  108218. private _cannonRaycastResult;
  108219. private _raycastResult;
  108220. private _removeAfterStep;
  108221. BJSCANNON: any;
  108222. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108223. setGravity(gravity: Vector3): void;
  108224. setTimeStep(timeStep: number): void;
  108225. getTimeStep(): number;
  108226. executeStep(delta: number): void;
  108227. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108228. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108229. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108230. private _processChildMeshes;
  108231. removePhysicsBody(impostor: PhysicsImpostor): void;
  108232. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108233. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108234. private _addMaterial;
  108235. private _checkWithEpsilon;
  108236. private _createShape;
  108237. private _createHeightmap;
  108238. private _minus90X;
  108239. private _plus90X;
  108240. private _tmpPosition;
  108241. private _tmpDeltaPosition;
  108242. private _tmpUnityRotation;
  108243. private _updatePhysicsBodyTransformation;
  108244. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108245. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108246. isSupported(): boolean;
  108247. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108248. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108249. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108250. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108251. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108252. getBodyMass(impostor: PhysicsImpostor): number;
  108253. getBodyFriction(impostor: PhysicsImpostor): number;
  108254. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108255. getBodyRestitution(impostor: PhysicsImpostor): number;
  108256. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108257. sleepBody(impostor: PhysicsImpostor): void;
  108258. wakeUpBody(impostor: PhysicsImpostor): void;
  108259. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108260. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108261. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108262. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108263. getRadius(impostor: PhysicsImpostor): number;
  108264. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108265. dispose(): void;
  108266. private _extendNamespace;
  108267. /**
  108268. * Does a raycast in the physics world
  108269. * @param from when should the ray start?
  108270. * @param to when should the ray end?
  108271. * @returns PhysicsRaycastResult
  108272. */
  108273. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108274. }
  108275. }
  108276. declare module BABYLON {
  108277. /** @hidden */
  108278. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108279. world: any;
  108280. name: string;
  108281. BJSOIMO: any;
  108282. private _raycastResult;
  108283. constructor(iterations?: number, oimoInjection?: any);
  108284. setGravity(gravity: Vector3): void;
  108285. setTimeStep(timeStep: number): void;
  108286. getTimeStep(): number;
  108287. private _tmpImpostorsArray;
  108288. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108289. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108290. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108291. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108292. private _tmpPositionVector;
  108293. removePhysicsBody(impostor: PhysicsImpostor): void;
  108294. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108295. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108296. isSupported(): boolean;
  108297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108298. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108299. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108300. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108301. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108302. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108303. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108304. getBodyMass(impostor: PhysicsImpostor): number;
  108305. getBodyFriction(impostor: PhysicsImpostor): number;
  108306. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108307. getBodyRestitution(impostor: PhysicsImpostor): number;
  108308. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108309. sleepBody(impostor: PhysicsImpostor): void;
  108310. wakeUpBody(impostor: PhysicsImpostor): void;
  108311. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108312. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108313. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108314. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108315. getRadius(impostor: PhysicsImpostor): number;
  108316. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108317. dispose(): void;
  108318. /**
  108319. * Does a raycast in the physics world
  108320. * @param from when should the ray start?
  108321. * @param to when should the ray end?
  108322. * @returns PhysicsRaycastResult
  108323. */
  108324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108325. }
  108326. }
  108327. declare module BABYLON {
  108328. /**
  108329. * Class containing static functions to help procedurally build meshes
  108330. */
  108331. export class RibbonBuilder {
  108332. /**
  108333. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108334. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108335. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108336. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108337. * * 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
  108338. * * 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
  108339. * * 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
  108340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108343. * * 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
  108344. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108345. * * 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
  108346. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108348. * @param name defines the name of the mesh
  108349. * @param options defines the options used to create the mesh
  108350. * @param scene defines the hosting scene
  108351. * @returns the ribbon mesh
  108352. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108354. */
  108355. static CreateRibbon(name: string, options: {
  108356. pathArray: Vector3[][];
  108357. closeArray?: boolean;
  108358. closePath?: boolean;
  108359. offset?: number;
  108360. updatable?: boolean;
  108361. sideOrientation?: number;
  108362. frontUVs?: Vector4;
  108363. backUVs?: Vector4;
  108364. instance?: Mesh;
  108365. invertUV?: boolean;
  108366. uvs?: Vector2[];
  108367. colors?: Color4[];
  108368. }, scene?: Nullable<Scene>): Mesh;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /**
  108373. * Class containing static functions to help procedurally build meshes
  108374. */
  108375. export class ShapeBuilder {
  108376. /**
  108377. * 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.
  108378. * * 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.
  108379. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108380. * * 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.
  108381. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108382. * * 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
  108383. * * 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
  108384. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108387. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108389. * @param name defines the name of the mesh
  108390. * @param options defines the options used to create the mesh
  108391. * @param scene defines the hosting scene
  108392. * @returns the extruded shape mesh
  108393. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108395. */
  108396. static ExtrudeShape(name: string, options: {
  108397. shape: Vector3[];
  108398. path: Vector3[];
  108399. scale?: number;
  108400. rotation?: number;
  108401. cap?: number;
  108402. updatable?: boolean;
  108403. sideOrientation?: number;
  108404. frontUVs?: Vector4;
  108405. backUVs?: Vector4;
  108406. instance?: Mesh;
  108407. invertUV?: boolean;
  108408. }, scene?: Nullable<Scene>): Mesh;
  108409. /**
  108410. * Creates an custom extruded shape mesh.
  108411. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108412. * * 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.
  108413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108414. * * 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
  108415. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108416. * * 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
  108417. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108418. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108419. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108420. * * 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
  108421. * * 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
  108422. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108427. * @param name defines the name of the mesh
  108428. * @param options defines the options used to create the mesh
  108429. * @param scene defines the hosting scene
  108430. * @returns the custom extruded shape mesh
  108431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108434. */
  108435. static ExtrudeShapeCustom(name: string, options: {
  108436. shape: Vector3[];
  108437. path: Vector3[];
  108438. scaleFunction?: any;
  108439. rotationFunction?: any;
  108440. ribbonCloseArray?: boolean;
  108441. ribbonClosePath?: boolean;
  108442. cap?: number;
  108443. updatable?: boolean;
  108444. sideOrientation?: number;
  108445. frontUVs?: Vector4;
  108446. backUVs?: Vector4;
  108447. instance?: Mesh;
  108448. invertUV?: boolean;
  108449. }, scene?: Nullable<Scene>): Mesh;
  108450. private static _ExtrudeShapeGeneric;
  108451. }
  108452. }
  108453. declare module BABYLON {
  108454. /**
  108455. * AmmoJS Physics plugin
  108456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108457. * @see https://github.com/kripken/ammo.js/
  108458. */
  108459. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108460. private _useDeltaForWorldStep;
  108461. /**
  108462. * Reference to the Ammo library
  108463. */
  108464. bjsAMMO: any;
  108465. /**
  108466. * Created ammoJS world which physics bodies are added to
  108467. */
  108468. world: any;
  108469. /**
  108470. * Name of the plugin
  108471. */
  108472. name: string;
  108473. private _timeStep;
  108474. private _fixedTimeStep;
  108475. private _maxSteps;
  108476. private _tmpQuaternion;
  108477. private _tmpAmmoTransform;
  108478. private _tmpAmmoQuaternion;
  108479. private _tmpAmmoConcreteContactResultCallback;
  108480. private _collisionConfiguration;
  108481. private _dispatcher;
  108482. private _overlappingPairCache;
  108483. private _solver;
  108484. private _softBodySolver;
  108485. private _tmpAmmoVectorA;
  108486. private _tmpAmmoVectorB;
  108487. private _tmpAmmoVectorC;
  108488. private _tmpAmmoVectorD;
  108489. private _tmpContactCallbackResult;
  108490. private _tmpAmmoVectorRCA;
  108491. private _tmpAmmoVectorRCB;
  108492. private _raycastResult;
  108493. private static readonly DISABLE_COLLISION_FLAG;
  108494. private static readonly KINEMATIC_FLAG;
  108495. private static readonly DISABLE_DEACTIVATION_FLAG;
  108496. /**
  108497. * Initializes the ammoJS plugin
  108498. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108499. * @param ammoInjection can be used to inject your own ammo reference
  108500. */
  108501. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108502. /**
  108503. * Sets the gravity of the physics world (m/(s^2))
  108504. * @param gravity Gravity to set
  108505. */
  108506. setGravity(gravity: Vector3): void;
  108507. /**
  108508. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108509. * @param timeStep timestep to use in seconds
  108510. */
  108511. setTimeStep(timeStep: number): void;
  108512. /**
  108513. * 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)
  108514. * @param fixedTimeStep fixedTimeStep to use in seconds
  108515. */
  108516. setFixedTimeStep(fixedTimeStep: number): void;
  108517. /**
  108518. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108519. * @param maxSteps the maximum number of steps by the physics engine per frame
  108520. */
  108521. setMaxSteps(maxSteps: number): void;
  108522. /**
  108523. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108524. * @returns the current timestep in seconds
  108525. */
  108526. getTimeStep(): number;
  108527. private _isImpostorInContact;
  108528. private _isImpostorPairInContact;
  108529. private _stepSimulation;
  108530. /**
  108531. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108532. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108533. * After the step the babylon meshes are set to the position of the physics imposters
  108534. * @param delta amount of time to step forward
  108535. * @param impostors array of imposters to update before/after the step
  108536. */
  108537. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108538. /**
  108539. * Update babylon mesh to match physics world object
  108540. * @param impostor imposter to match
  108541. */
  108542. private _afterSoftStep;
  108543. /**
  108544. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108545. * @param impostor imposter to match
  108546. */
  108547. private _ropeStep;
  108548. /**
  108549. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108550. * @param impostor imposter to match
  108551. */
  108552. private _softbodyOrClothStep;
  108553. private _tmpVector;
  108554. private _tmpMatrix;
  108555. /**
  108556. * Applies an impulse on the imposter
  108557. * @param impostor imposter to apply impulse to
  108558. * @param force amount of force to be applied to the imposter
  108559. * @param contactPoint the location to apply the impulse on the imposter
  108560. */
  108561. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108562. /**
  108563. * Applies a force on the imposter
  108564. * @param impostor imposter to apply force
  108565. * @param force amount of force to be applied to the imposter
  108566. * @param contactPoint the location to apply the force on the imposter
  108567. */
  108568. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108569. /**
  108570. * Creates a physics body using the plugin
  108571. * @param impostor the imposter to create the physics body on
  108572. */
  108573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108574. /**
  108575. * Removes the physics body from the imposter and disposes of the body's memory
  108576. * @param impostor imposter to remove the physics body from
  108577. */
  108578. removePhysicsBody(impostor: PhysicsImpostor): void;
  108579. /**
  108580. * Generates a joint
  108581. * @param impostorJoint the imposter joint to create the joint with
  108582. */
  108583. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108584. /**
  108585. * Removes a joint
  108586. * @param impostorJoint the imposter joint to remove the joint from
  108587. */
  108588. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108589. private _addMeshVerts;
  108590. /**
  108591. * Initialise the soft body vertices to match its object's (mesh) vertices
  108592. * Softbody vertices (nodes) are in world space and to match this
  108593. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108594. * @param impostor to create the softbody for
  108595. */
  108596. private _softVertexData;
  108597. /**
  108598. * Create an impostor's soft body
  108599. * @param impostor to create the softbody for
  108600. */
  108601. private _createSoftbody;
  108602. /**
  108603. * Create cloth for an impostor
  108604. * @param impostor to create the softbody for
  108605. */
  108606. private _createCloth;
  108607. /**
  108608. * Create rope for an impostor
  108609. * @param impostor to create the softbody for
  108610. */
  108611. private _createRope;
  108612. private _addHullVerts;
  108613. private _createShape;
  108614. /**
  108615. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108616. * @param impostor imposter containing the physics body and babylon object
  108617. */
  108618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108619. /**
  108620. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108621. * @param impostor imposter containing the physics body and babylon object
  108622. * @param newPosition new position
  108623. * @param newRotation new rotation
  108624. */
  108625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108626. /**
  108627. * If this plugin is supported
  108628. * @returns true if its supported
  108629. */
  108630. isSupported(): boolean;
  108631. /**
  108632. * Sets the linear velocity of the physics body
  108633. * @param impostor imposter to set the velocity on
  108634. * @param velocity velocity to set
  108635. */
  108636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108637. /**
  108638. * Sets the angular velocity of the physics body
  108639. * @param impostor imposter to set the velocity on
  108640. * @param velocity velocity to set
  108641. */
  108642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108643. /**
  108644. * gets the linear velocity
  108645. * @param impostor imposter to get linear velocity from
  108646. * @returns linear velocity
  108647. */
  108648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108649. /**
  108650. * gets the angular velocity
  108651. * @param impostor imposter to get angular velocity from
  108652. * @returns angular velocity
  108653. */
  108654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108655. /**
  108656. * Sets the mass of physics body
  108657. * @param impostor imposter to set the mass on
  108658. * @param mass mass to set
  108659. */
  108660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108661. /**
  108662. * Gets the mass of the physics body
  108663. * @param impostor imposter to get the mass from
  108664. * @returns mass
  108665. */
  108666. getBodyMass(impostor: PhysicsImpostor): number;
  108667. /**
  108668. * Gets friction of the impostor
  108669. * @param impostor impostor to get friction from
  108670. * @returns friction value
  108671. */
  108672. getBodyFriction(impostor: PhysicsImpostor): number;
  108673. /**
  108674. * Sets friction of the impostor
  108675. * @param impostor impostor to set friction on
  108676. * @param friction friction value
  108677. */
  108678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108679. /**
  108680. * Gets restitution of the impostor
  108681. * @param impostor impostor to get restitution from
  108682. * @returns restitution value
  108683. */
  108684. getBodyRestitution(impostor: PhysicsImpostor): number;
  108685. /**
  108686. * Sets resitution of the impostor
  108687. * @param impostor impostor to set resitution on
  108688. * @param restitution resitution value
  108689. */
  108690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108691. /**
  108692. * Gets pressure inside the impostor
  108693. * @param impostor impostor to get pressure from
  108694. * @returns pressure value
  108695. */
  108696. getBodyPressure(impostor: PhysicsImpostor): number;
  108697. /**
  108698. * Sets pressure inside a soft body impostor
  108699. * Cloth and rope must remain 0 pressure
  108700. * @param impostor impostor to set pressure on
  108701. * @param pressure pressure value
  108702. */
  108703. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108704. /**
  108705. * Gets stiffness of the impostor
  108706. * @param impostor impostor to get stiffness from
  108707. * @returns pressure value
  108708. */
  108709. getBodyStiffness(impostor: PhysicsImpostor): number;
  108710. /**
  108711. * Sets stiffness of the impostor
  108712. * @param impostor impostor to set stiffness on
  108713. * @param stiffness stiffness value from 0 to 1
  108714. */
  108715. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108716. /**
  108717. * Gets velocityIterations of the impostor
  108718. * @param impostor impostor to get velocity iterations from
  108719. * @returns velocityIterations value
  108720. */
  108721. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108722. /**
  108723. * Sets velocityIterations of the impostor
  108724. * @param impostor impostor to set velocity iterations on
  108725. * @param velocityIterations velocityIterations value
  108726. */
  108727. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108728. /**
  108729. * Gets positionIterations of the impostor
  108730. * @param impostor impostor to get position iterations from
  108731. * @returns positionIterations value
  108732. */
  108733. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108734. /**
  108735. * Sets positionIterations of the impostor
  108736. * @param impostor impostor to set position on
  108737. * @param positionIterations positionIterations value
  108738. */
  108739. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108740. /**
  108741. * Append an anchor to a cloth object
  108742. * @param impostor is the cloth impostor to add anchor to
  108743. * @param otherImpostor is the rigid impostor to anchor to
  108744. * @param width ratio across width from 0 to 1
  108745. * @param height ratio up height from 0 to 1
  108746. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108748. */
  108749. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108750. /**
  108751. * Append an hook to a rope object
  108752. * @param impostor is the rope impostor to add hook to
  108753. * @param otherImpostor is the rigid impostor to hook to
  108754. * @param length ratio along the rope from 0 to 1
  108755. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108756. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108757. */
  108758. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108759. /**
  108760. * Sleeps the physics body and stops it from being active
  108761. * @param impostor impostor to sleep
  108762. */
  108763. sleepBody(impostor: PhysicsImpostor): void;
  108764. /**
  108765. * Activates the physics body
  108766. * @param impostor impostor to activate
  108767. */
  108768. wakeUpBody(impostor: PhysicsImpostor): void;
  108769. /**
  108770. * Updates the distance parameters of the joint
  108771. * @param joint joint to update
  108772. * @param maxDistance maximum distance of the joint
  108773. * @param minDistance minimum distance of the joint
  108774. */
  108775. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108776. /**
  108777. * Sets a motor on the joint
  108778. * @param joint joint to set motor on
  108779. * @param speed speed of the motor
  108780. * @param maxForce maximum force of the motor
  108781. * @param motorIndex index of the motor
  108782. */
  108783. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108784. /**
  108785. * Sets the motors limit
  108786. * @param joint joint to set limit on
  108787. * @param upperLimit upper limit
  108788. * @param lowerLimit lower limit
  108789. */
  108790. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108791. /**
  108792. * Syncs the position and rotation of a mesh with the impostor
  108793. * @param mesh mesh to sync
  108794. * @param impostor impostor to update the mesh with
  108795. */
  108796. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108797. /**
  108798. * Gets the radius of the impostor
  108799. * @param impostor impostor to get radius from
  108800. * @returns the radius
  108801. */
  108802. getRadius(impostor: PhysicsImpostor): number;
  108803. /**
  108804. * Gets the box size of the impostor
  108805. * @param impostor impostor to get box size from
  108806. * @param result the resulting box size
  108807. */
  108808. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108809. /**
  108810. * Disposes of the impostor
  108811. */
  108812. dispose(): void;
  108813. /**
  108814. * Does a raycast in the physics world
  108815. * @param from when should the ray start?
  108816. * @param to when should the ray end?
  108817. * @returns PhysicsRaycastResult
  108818. */
  108819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108820. }
  108821. }
  108822. declare module BABYLON {
  108823. interface AbstractScene {
  108824. /**
  108825. * The list of reflection probes added to the scene
  108826. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108827. */
  108828. reflectionProbes: Array<ReflectionProbe>;
  108829. /**
  108830. * Removes the given reflection probe from this scene.
  108831. * @param toRemove The reflection probe to remove
  108832. * @returns The index of the removed reflection probe
  108833. */
  108834. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108835. /**
  108836. * Adds the given reflection probe to this scene.
  108837. * @param newReflectionProbe The reflection probe to add
  108838. */
  108839. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108840. }
  108841. /**
  108842. * Class used to generate realtime reflection / refraction cube textures
  108843. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108844. */
  108845. export class ReflectionProbe {
  108846. /** defines the name of the probe */
  108847. name: string;
  108848. private _scene;
  108849. private _renderTargetTexture;
  108850. private _projectionMatrix;
  108851. private _viewMatrix;
  108852. private _target;
  108853. private _add;
  108854. private _attachedMesh;
  108855. private _invertYAxis;
  108856. /** Gets or sets probe position (center of the cube map) */
  108857. position: Vector3;
  108858. /**
  108859. * Creates a new reflection probe
  108860. * @param name defines the name of the probe
  108861. * @param size defines the texture resolution (for each face)
  108862. * @param scene defines the hosting scene
  108863. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108864. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108865. */
  108866. constructor(
  108867. /** defines the name of the probe */
  108868. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108869. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108870. samples: number;
  108871. /** Gets or sets the refresh rate to use (on every frame by default) */
  108872. refreshRate: number;
  108873. /**
  108874. * Gets the hosting scene
  108875. * @returns a Scene
  108876. */
  108877. getScene(): Scene;
  108878. /** Gets the internal CubeTexture used to render to */
  108879. readonly cubeTexture: RenderTargetTexture;
  108880. /** Gets the list of meshes to render */
  108881. readonly renderList: Nullable<AbstractMesh[]>;
  108882. /**
  108883. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108884. * @param mesh defines the mesh to attach to
  108885. */
  108886. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108887. /**
  108888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108889. * @param renderingGroupId The rendering group id corresponding to its index
  108890. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108891. */
  108892. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108893. /**
  108894. * Clean all associated resources
  108895. */
  108896. dispose(): void;
  108897. /**
  108898. * Converts the reflection probe information to a readable string for debug purpose.
  108899. * @param fullDetails Supports for multiple levels of logging within scene loading
  108900. * @returns the human readable reflection probe info
  108901. */
  108902. toString(fullDetails?: boolean): string;
  108903. /**
  108904. * Get the class name of the relfection probe.
  108905. * @returns "ReflectionProbe"
  108906. */
  108907. getClassName(): string;
  108908. /**
  108909. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108910. * @returns The JSON representation of the texture
  108911. */
  108912. serialize(): any;
  108913. /**
  108914. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108915. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108916. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108917. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108918. * @returns The parsed reflection probe if successful
  108919. */
  108920. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108921. }
  108922. }
  108923. declare module BABYLON {
  108924. /** @hidden */
  108925. export var _BabylonLoaderRegistered: boolean;
  108926. }
  108927. declare module BABYLON {
  108928. /**
  108929. * The Physically based simple base material of BJS.
  108930. *
  108931. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108932. * It is used as the base class for both the specGloss and metalRough conventions.
  108933. */
  108934. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108935. /**
  108936. * Number of Simultaneous lights allowed on the material.
  108937. */
  108938. maxSimultaneousLights: number;
  108939. /**
  108940. * If sets to true, disables all the lights affecting the material.
  108941. */
  108942. disableLighting: boolean;
  108943. /**
  108944. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108945. */
  108946. environmentTexture: BaseTexture;
  108947. /**
  108948. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108949. */
  108950. invertNormalMapX: boolean;
  108951. /**
  108952. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108953. */
  108954. invertNormalMapY: boolean;
  108955. /**
  108956. * Normal map used in the model.
  108957. */
  108958. normalTexture: BaseTexture;
  108959. /**
  108960. * Emissivie color used to self-illuminate the model.
  108961. */
  108962. emissiveColor: Color3;
  108963. /**
  108964. * Emissivie texture used to self-illuminate the model.
  108965. */
  108966. emissiveTexture: BaseTexture;
  108967. /**
  108968. * Occlusion Channel Strenght.
  108969. */
  108970. occlusionStrength: number;
  108971. /**
  108972. * Occlusion Texture of the material (adding extra occlusion effects).
  108973. */
  108974. occlusionTexture: BaseTexture;
  108975. /**
  108976. * Defines the alpha limits in alpha test mode.
  108977. */
  108978. alphaCutOff: number;
  108979. /**
  108980. * Gets the current double sided mode.
  108981. */
  108982. /**
  108983. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108984. */
  108985. doubleSided: boolean;
  108986. /**
  108987. * Stores the pre-calculated light information of a mesh in a texture.
  108988. */
  108989. lightmapTexture: BaseTexture;
  108990. /**
  108991. * If true, the light map contains occlusion information instead of lighting info.
  108992. */
  108993. useLightmapAsShadowmap: boolean;
  108994. /**
  108995. * Instantiates a new PBRMaterial instance.
  108996. *
  108997. * @param name The material name
  108998. * @param scene The scene the material will be use in.
  108999. */
  109000. constructor(name: string, scene: Scene);
  109001. getClassName(): string;
  109002. }
  109003. }
  109004. declare module BABYLON {
  109005. /**
  109006. * The PBR material of BJS following the metal roughness convention.
  109007. *
  109008. * This fits to the PBR convention in the GLTF definition:
  109009. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109010. */
  109011. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109012. /**
  109013. * The base color has two different interpretations depending on the value of metalness.
  109014. * When the material is a metal, the base color is the specific measured reflectance value
  109015. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109016. * of the material.
  109017. */
  109018. baseColor: Color3;
  109019. /**
  109020. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109021. * well as opacity information in the alpha channel.
  109022. */
  109023. baseTexture: BaseTexture;
  109024. /**
  109025. * Specifies the metallic scalar value of the material.
  109026. * Can also be used to scale the metalness values of the metallic texture.
  109027. */
  109028. metallic: number;
  109029. /**
  109030. * Specifies the roughness scalar value of the material.
  109031. * Can also be used to scale the roughness values of the metallic texture.
  109032. */
  109033. roughness: number;
  109034. /**
  109035. * Texture containing both the metallic value in the B channel and the
  109036. * roughness value in the G channel to keep better precision.
  109037. */
  109038. metallicRoughnessTexture: BaseTexture;
  109039. /**
  109040. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109041. *
  109042. * @param name The material name
  109043. * @param scene The scene the material will be use in.
  109044. */
  109045. constructor(name: string, scene: Scene);
  109046. /**
  109047. * Return the currrent class name of the material.
  109048. */
  109049. getClassName(): string;
  109050. /**
  109051. * Makes a duplicate of the current material.
  109052. * @param name - name to use for the new material.
  109053. */
  109054. clone(name: string): PBRMetallicRoughnessMaterial;
  109055. /**
  109056. * Serialize the material to a parsable JSON object.
  109057. */
  109058. serialize(): any;
  109059. /**
  109060. * Parses a JSON object correponding to the serialize function.
  109061. */
  109062. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109063. }
  109064. }
  109065. declare module BABYLON {
  109066. /**
  109067. * The PBR material of BJS following the specular glossiness convention.
  109068. *
  109069. * This fits to the PBR convention in the GLTF definition:
  109070. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109071. */
  109072. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109073. /**
  109074. * Specifies the diffuse color of the material.
  109075. */
  109076. diffuseColor: Color3;
  109077. /**
  109078. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109079. * channel.
  109080. */
  109081. diffuseTexture: BaseTexture;
  109082. /**
  109083. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109084. */
  109085. specularColor: Color3;
  109086. /**
  109087. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109088. */
  109089. glossiness: number;
  109090. /**
  109091. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109092. */
  109093. specularGlossinessTexture: BaseTexture;
  109094. /**
  109095. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109096. *
  109097. * @param name The material name
  109098. * @param scene The scene the material will be use in.
  109099. */
  109100. constructor(name: string, scene: Scene);
  109101. /**
  109102. * Return the currrent class name of the material.
  109103. */
  109104. getClassName(): string;
  109105. /**
  109106. * Makes a duplicate of the current material.
  109107. * @param name - name to use for the new material.
  109108. */
  109109. clone(name: string): PBRSpecularGlossinessMaterial;
  109110. /**
  109111. * Serialize the material to a parsable JSON object.
  109112. */
  109113. serialize(): any;
  109114. /**
  109115. * Parses a JSON object correponding to the serialize function.
  109116. */
  109117. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109118. }
  109119. }
  109120. declare module BABYLON {
  109121. /**
  109122. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109123. * It can help converting any input color in a desired output one. This can then be used to create effects
  109124. * from sepia, black and white to sixties or futuristic rendering...
  109125. *
  109126. * The only supported format is currently 3dl.
  109127. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109128. */
  109129. export class ColorGradingTexture extends BaseTexture {
  109130. /**
  109131. * The current texture matrix. (will always be identity in color grading texture)
  109132. */
  109133. private _textureMatrix;
  109134. /**
  109135. * The texture URL.
  109136. */
  109137. url: string;
  109138. /**
  109139. * Empty line regex stored for GC.
  109140. */
  109141. private static _noneEmptyLineRegex;
  109142. private _engine;
  109143. /**
  109144. * Instantiates a ColorGradingTexture from the following parameters.
  109145. *
  109146. * @param url The location of the color gradind data (currently only supporting 3dl)
  109147. * @param scene The scene the texture will be used in
  109148. */
  109149. constructor(url: string, scene: Scene);
  109150. /**
  109151. * Returns the texture matrix used in most of the material.
  109152. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109153. */
  109154. getTextureMatrix(): Matrix;
  109155. /**
  109156. * Occurs when the file being loaded is a .3dl LUT file.
  109157. */
  109158. private load3dlTexture;
  109159. /**
  109160. * Starts the loading process of the texture.
  109161. */
  109162. private loadTexture;
  109163. /**
  109164. * Clones the color gradind texture.
  109165. */
  109166. clone(): ColorGradingTexture;
  109167. /**
  109168. * Called during delayed load for textures.
  109169. */
  109170. delayLoad(): void;
  109171. /**
  109172. * Parses a color grading texture serialized by Babylon.
  109173. * @param parsedTexture The texture information being parsedTexture
  109174. * @param scene The scene to load the texture in
  109175. * @param rootUrl The root url of the data assets to load
  109176. * @return A color gradind texture
  109177. */
  109178. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109179. /**
  109180. * Serializes the LUT texture to json format.
  109181. */
  109182. serialize(): any;
  109183. }
  109184. }
  109185. declare module BABYLON {
  109186. /**
  109187. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109188. */
  109189. export class EquiRectangularCubeTexture extends BaseTexture {
  109190. /** The six faces of the cube. */
  109191. private static _FacesMapping;
  109192. private _noMipmap;
  109193. private _onLoad;
  109194. private _onError;
  109195. /** The size of the cubemap. */
  109196. private _size;
  109197. /** The buffer of the image. */
  109198. private _buffer;
  109199. /** The width of the input image. */
  109200. private _width;
  109201. /** The height of the input image. */
  109202. private _height;
  109203. /** The URL to the image. */
  109204. url: string;
  109205. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109206. coordinatesMode: number;
  109207. /**
  109208. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109209. * @param url The location of the image
  109210. * @param scene The scene the texture will be used in
  109211. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109212. * @param noMipmap Forces to not generate the mipmap if true
  109213. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109214. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109215. * @param onLoad — defines a callback called when texture is loaded
  109216. * @param onError — defines a callback called if there is an error
  109217. */
  109218. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109219. /**
  109220. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109221. */
  109222. private loadImage;
  109223. /**
  109224. * Convert the image buffer into a cubemap and create a CubeTexture.
  109225. */
  109226. private loadTexture;
  109227. /**
  109228. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109229. * @param buffer The ArrayBuffer that should be converted.
  109230. * @returns The buffer as Float32Array.
  109231. */
  109232. private getFloat32ArrayFromArrayBuffer;
  109233. /**
  109234. * Get the current class name of the texture useful for serialization or dynamic coding.
  109235. * @returns "EquiRectangularCubeTexture"
  109236. */
  109237. getClassName(): string;
  109238. /**
  109239. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109240. * @returns A clone of the current EquiRectangularCubeTexture.
  109241. */
  109242. clone(): EquiRectangularCubeTexture;
  109243. }
  109244. }
  109245. declare module BABYLON {
  109246. /**
  109247. * Based on jsTGALoader - Javascript loader for TGA file
  109248. * By Vincent Thibault
  109249. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109250. */
  109251. export class TGATools {
  109252. private static _TYPE_INDEXED;
  109253. private static _TYPE_RGB;
  109254. private static _TYPE_GREY;
  109255. private static _TYPE_RLE_INDEXED;
  109256. private static _TYPE_RLE_RGB;
  109257. private static _TYPE_RLE_GREY;
  109258. private static _ORIGIN_MASK;
  109259. private static _ORIGIN_SHIFT;
  109260. private static _ORIGIN_BL;
  109261. private static _ORIGIN_BR;
  109262. private static _ORIGIN_UL;
  109263. private static _ORIGIN_UR;
  109264. /**
  109265. * Gets the header of a TGA file
  109266. * @param data defines the TGA data
  109267. * @returns the header
  109268. */
  109269. static GetTGAHeader(data: Uint8Array): any;
  109270. /**
  109271. * Uploads TGA content to a Babylon Texture
  109272. * @hidden
  109273. */
  109274. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109275. /** @hidden */
  109276. 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;
  109277. /** @hidden */
  109278. 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;
  109279. /** @hidden */
  109280. 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;
  109281. /** @hidden */
  109282. 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;
  109283. /** @hidden */
  109284. 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;
  109285. /** @hidden */
  109286. 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;
  109287. }
  109288. }
  109289. declare module BABYLON {
  109290. /**
  109291. * Implementation of the TGA Texture Loader.
  109292. * @hidden
  109293. */
  109294. export class _TGATextureLoader implements IInternalTextureLoader {
  109295. /**
  109296. * Defines wether the loader supports cascade loading the different faces.
  109297. */
  109298. readonly supportCascades: boolean;
  109299. /**
  109300. * This returns if the loader support the current file information.
  109301. * @param extension defines the file extension of the file being loaded
  109302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109303. * @param fallback defines the fallback internal texture if any
  109304. * @param isBase64 defines whether the texture is encoded as a base64
  109305. * @param isBuffer defines whether the texture data are stored as a buffer
  109306. * @returns true if the loader can load the specified file
  109307. */
  109308. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109309. /**
  109310. * Transform the url before loading if required.
  109311. * @param rootUrl the url of the texture
  109312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109313. * @returns the transformed texture
  109314. */
  109315. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109316. /**
  109317. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109318. * @param rootUrl the url of the texture
  109319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109320. * @returns the fallback texture
  109321. */
  109322. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109323. /**
  109324. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109325. * @param data contains the texture data
  109326. * @param texture defines the BabylonJS internal texture
  109327. * @param createPolynomials will be true if polynomials have been requested
  109328. * @param onLoad defines the callback to trigger once the texture is ready
  109329. * @param onError defines the callback to trigger in case of error
  109330. */
  109331. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109332. /**
  109333. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109334. * @param data contains the texture data
  109335. * @param texture defines the BabylonJS internal texture
  109336. * @param callback defines the method to call once ready to upload
  109337. */
  109338. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109339. }
  109340. }
  109341. declare module BABYLON {
  109342. /**
  109343. * 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.
  109344. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109345. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109346. */
  109347. export class CustomProceduralTexture extends ProceduralTexture {
  109348. private _animate;
  109349. private _time;
  109350. private _config;
  109351. private _texturePath;
  109352. /**
  109353. * Instantiates a new Custom Procedural Texture.
  109354. * 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.
  109355. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109356. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109357. * @param name Define the name of the texture
  109358. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109359. * @param size Define the size of the texture to create
  109360. * @param scene Define the scene the texture belongs to
  109361. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109362. * @param generateMipMaps Define if the texture should creates mip maps or not
  109363. */
  109364. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109365. private _loadJson;
  109366. /**
  109367. * Is the texture ready to be used ? (rendered at least once)
  109368. * @returns true if ready, otherwise, false.
  109369. */
  109370. isReady(): boolean;
  109371. /**
  109372. * Render the texture to its associated render target.
  109373. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109374. */
  109375. render(useCameraPostProcess?: boolean): void;
  109376. /**
  109377. * Update the list of dependant textures samplers in the shader.
  109378. */
  109379. updateTextures(): void;
  109380. /**
  109381. * Update the uniform values of the procedural texture in the shader.
  109382. */
  109383. updateShaderUniforms(): void;
  109384. /**
  109385. * Define if the texture animates or not.
  109386. */
  109387. animate: boolean;
  109388. }
  109389. }
  109390. declare module BABYLON {
  109391. /** @hidden */
  109392. export var noisePixelShader: {
  109393. name: string;
  109394. shader: string;
  109395. };
  109396. }
  109397. declare module BABYLON {
  109398. /**
  109399. * Class used to generate noise procedural textures
  109400. */
  109401. export class NoiseProceduralTexture extends ProceduralTexture {
  109402. private _time;
  109403. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109404. brightness: number;
  109405. /** Defines the number of octaves to process */
  109406. octaves: number;
  109407. /** Defines the level of persistence (0.8 by default) */
  109408. persistence: number;
  109409. /** Gets or sets animation speed factor (default is 1) */
  109410. animationSpeedFactor: number;
  109411. /**
  109412. * Creates a new NoiseProceduralTexture
  109413. * @param name defines the name fo the texture
  109414. * @param size defines the size of the texture (default is 256)
  109415. * @param scene defines the hosting scene
  109416. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109417. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109418. */
  109419. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109420. private _updateShaderUniforms;
  109421. protected _getDefines(): string;
  109422. /** Generate the current state of the procedural texture */
  109423. render(useCameraPostProcess?: boolean): void;
  109424. /**
  109425. * Serializes this noise procedural texture
  109426. * @returns a serialized noise procedural texture object
  109427. */
  109428. serialize(): any;
  109429. /**
  109430. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109431. * @param parsedTexture defines parsed texture data
  109432. * @param scene defines the current scene
  109433. * @param rootUrl defines the root URL containing noise procedural texture information
  109434. * @returns a parsed NoiseProceduralTexture
  109435. */
  109436. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109437. }
  109438. }
  109439. declare module BABYLON {
  109440. /**
  109441. * Raw cube texture where the raw buffers are passed in
  109442. */
  109443. export class RawCubeTexture extends CubeTexture {
  109444. /**
  109445. * Creates a cube texture where the raw buffers are passed in.
  109446. * @param scene defines the scene the texture is attached to
  109447. * @param data defines the array of data to use to create each face
  109448. * @param size defines the size of the textures
  109449. * @param format defines the format of the data
  109450. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109451. * @param generateMipMaps defines if the engine should generate the mip levels
  109452. * @param invertY defines if data must be stored with Y axis inverted
  109453. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109454. * @param compression defines the compression used (null by default)
  109455. */
  109456. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109457. /**
  109458. * Updates the raw cube texture.
  109459. * @param data defines the data to store
  109460. * @param format defines the data format
  109461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109462. * @param invertY defines if data must be stored with Y axis inverted
  109463. * @param compression defines the compression used (null by default)
  109464. * @param level defines which level of the texture to update
  109465. */
  109466. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109467. /**
  109468. * Updates a raw cube texture with RGBD encoded data.
  109469. * @param data defines the array of data [mipmap][face] to use to create each face
  109470. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109471. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109472. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109473. * @returns a promsie that resolves when the operation is complete
  109474. */
  109475. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109476. /**
  109477. * Clones the raw cube texture.
  109478. * @return a new cube texture
  109479. */
  109480. clone(): CubeTexture;
  109481. /** @hidden */
  109482. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109483. }
  109484. }
  109485. declare module BABYLON {
  109486. /**
  109487. * Class used to store 3D textures containing user data
  109488. */
  109489. export class RawTexture3D extends Texture {
  109490. /** Gets or sets the texture format to use */
  109491. format: number;
  109492. private _engine;
  109493. /**
  109494. * Create a new RawTexture3D
  109495. * @param data defines the data of the texture
  109496. * @param width defines the width of the texture
  109497. * @param height defines the height of the texture
  109498. * @param depth defines the depth of the texture
  109499. * @param format defines the texture format to use
  109500. * @param scene defines the hosting scene
  109501. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109502. * @param invertY defines if texture must be stored with Y axis inverted
  109503. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109504. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109505. */
  109506. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109507. /** Gets or sets the texture format to use */
  109508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109509. /**
  109510. * Update the texture with new data
  109511. * @param data defines the data to store in the texture
  109512. */
  109513. update(data: ArrayBufferView): void;
  109514. }
  109515. }
  109516. declare module BABYLON {
  109517. /**
  109518. * Creates a refraction texture used by refraction channel of the standard material.
  109519. * It is like a mirror but to see through a material.
  109520. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109521. */
  109522. export class RefractionTexture extends RenderTargetTexture {
  109523. /**
  109524. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109525. * 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.
  109526. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109527. */
  109528. refractionPlane: Plane;
  109529. /**
  109530. * Define how deep under the surface we should see.
  109531. */
  109532. depth: number;
  109533. /**
  109534. * Creates a refraction texture used by refraction channel of the standard material.
  109535. * It is like a mirror but to see through a material.
  109536. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109537. * @param name Define the texture name
  109538. * @param size Define the size of the underlying texture
  109539. * @param scene Define the scene the refraction belongs to
  109540. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109541. */
  109542. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109543. /**
  109544. * Clone the refraction texture.
  109545. * @returns the cloned texture
  109546. */
  109547. clone(): RefractionTexture;
  109548. /**
  109549. * Serialize the texture to a JSON representation you could use in Parse later on
  109550. * @returns the serialized JSON representation
  109551. */
  109552. serialize(): any;
  109553. }
  109554. }
  109555. declare module BABYLON {
  109556. /**
  109557. * Defines the options related to the creation of an HtmlElementTexture
  109558. */
  109559. export interface IHtmlElementTextureOptions {
  109560. /**
  109561. * Defines wether mip maps should be created or not.
  109562. */
  109563. generateMipMaps?: boolean;
  109564. /**
  109565. * Defines the sampling mode of the texture.
  109566. */
  109567. samplingMode?: number;
  109568. /**
  109569. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109570. */
  109571. engine: Nullable<Engine>;
  109572. /**
  109573. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109574. */
  109575. scene: Nullable<Scene>;
  109576. }
  109577. /**
  109578. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109579. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109580. * is automatically managed.
  109581. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109582. * in your application.
  109583. *
  109584. * As the update is not automatic, you need to call them manually.
  109585. */
  109586. export class HtmlElementTexture extends BaseTexture {
  109587. /**
  109588. * The texture URL.
  109589. */
  109590. element: HTMLVideoElement | HTMLCanvasElement;
  109591. private static readonly DefaultOptions;
  109592. private _textureMatrix;
  109593. private _engine;
  109594. private _isVideo;
  109595. private _generateMipMaps;
  109596. private _samplingMode;
  109597. /**
  109598. * Instantiates a HtmlElementTexture from the following parameters.
  109599. *
  109600. * @param name Defines the name of the texture
  109601. * @param element Defines the video or canvas the texture is filled with
  109602. * @param options Defines the other none mandatory texture creation options
  109603. */
  109604. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109605. private _createInternalTexture;
  109606. /**
  109607. * Returns the texture matrix used in most of the material.
  109608. */
  109609. getTextureMatrix(): Matrix;
  109610. /**
  109611. * Updates the content of the texture.
  109612. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109613. */
  109614. update(invertY?: Nullable<boolean>): void;
  109615. }
  109616. }
  109617. declare module BABYLON {
  109618. /**
  109619. * Helper class to push actions to a pool of workers.
  109620. */
  109621. export class WorkerPool implements IDisposable {
  109622. private _workerInfos;
  109623. private _pendingActions;
  109624. /**
  109625. * Constructor
  109626. * @param workers Array of workers to use for actions
  109627. */
  109628. constructor(workers: Array<Worker>);
  109629. /**
  109630. * Terminates all workers and clears any pending actions.
  109631. */
  109632. dispose(): void;
  109633. /**
  109634. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109635. * pended until a worker has completed its action.
  109636. * @param action The action to perform. Call onComplete when the action is complete.
  109637. */
  109638. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109639. private _execute;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * Configuration for Draco compression
  109645. */
  109646. export interface IDracoCompressionConfiguration {
  109647. /**
  109648. * Configuration for the decoder.
  109649. */
  109650. decoder: {
  109651. /**
  109652. * The url to the WebAssembly module.
  109653. */
  109654. wasmUrl?: string;
  109655. /**
  109656. * The url to the WebAssembly binary.
  109657. */
  109658. wasmBinaryUrl?: string;
  109659. /**
  109660. * The url to the fallback JavaScript module.
  109661. */
  109662. fallbackUrl?: string;
  109663. };
  109664. }
  109665. /**
  109666. * Draco compression (https://google.github.io/draco/)
  109667. *
  109668. * This class wraps the Draco module.
  109669. *
  109670. * **Encoder**
  109671. *
  109672. * The encoder is not currently implemented.
  109673. *
  109674. * **Decoder**
  109675. *
  109676. * 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.
  109677. *
  109678. * To update the configuration, use the following code:
  109679. * ```javascript
  109680. * DracoCompression.Configuration = {
  109681. * decoder: {
  109682. * wasmUrl: "<url to the WebAssembly library>",
  109683. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109684. * fallbackUrl: "<url to the fallback JavaScript library>",
  109685. * }
  109686. * };
  109687. * ```
  109688. *
  109689. * 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.
  109690. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109691. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109692. *
  109693. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109694. * ```javascript
  109695. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109696. * ```
  109697. *
  109698. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109699. */
  109700. export class DracoCompression implements IDisposable {
  109701. private _workerPoolPromise?;
  109702. private _decoderModulePromise?;
  109703. /**
  109704. * The configuration. Defaults to the following urls:
  109705. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109706. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109707. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109708. */
  109709. static Configuration: IDracoCompressionConfiguration;
  109710. /**
  109711. * Returns true if the decoder configuration is available.
  109712. */
  109713. static readonly DecoderAvailable: boolean;
  109714. /**
  109715. * Default number of workers to create when creating the draco compression object.
  109716. */
  109717. static DefaultNumWorkers: number;
  109718. private static GetDefaultNumWorkers;
  109719. private static _Default;
  109720. /**
  109721. * Default instance for the draco compression object.
  109722. */
  109723. static readonly Default: DracoCompression;
  109724. /**
  109725. * Constructor
  109726. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109727. */
  109728. constructor(numWorkers?: number);
  109729. /**
  109730. * Stop all async operations and release resources.
  109731. */
  109732. dispose(): void;
  109733. /**
  109734. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109735. * @returns a promise that resolves when ready
  109736. */
  109737. whenReadyAsync(): Promise<void>;
  109738. /**
  109739. * Decode Draco compressed mesh data to vertex data.
  109740. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109741. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109742. * @returns A promise that resolves with the decoded vertex data
  109743. */
  109744. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109745. [kind: string]: number;
  109746. }): Promise<VertexData>;
  109747. }
  109748. }
  109749. declare module BABYLON {
  109750. /**
  109751. * Class for building Constructive Solid Geometry
  109752. */
  109753. export class CSG {
  109754. private polygons;
  109755. /**
  109756. * The world matrix
  109757. */
  109758. matrix: Matrix;
  109759. /**
  109760. * Stores the position
  109761. */
  109762. position: Vector3;
  109763. /**
  109764. * Stores the rotation
  109765. */
  109766. rotation: Vector3;
  109767. /**
  109768. * Stores the rotation quaternion
  109769. */
  109770. rotationQuaternion: Nullable<Quaternion>;
  109771. /**
  109772. * Stores the scaling vector
  109773. */
  109774. scaling: Vector3;
  109775. /**
  109776. * Convert the Mesh to CSG
  109777. * @param mesh The Mesh to convert to CSG
  109778. * @returns A new CSG from the Mesh
  109779. */
  109780. static FromMesh(mesh: Mesh): CSG;
  109781. /**
  109782. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109783. * @param polygons Polygons used to construct a CSG solid
  109784. */
  109785. private static FromPolygons;
  109786. /**
  109787. * Clones, or makes a deep copy, of the CSG
  109788. * @returns A new CSG
  109789. */
  109790. clone(): CSG;
  109791. /**
  109792. * Unions this CSG with another CSG
  109793. * @param csg The CSG to union against this CSG
  109794. * @returns The unioned CSG
  109795. */
  109796. union(csg: CSG): CSG;
  109797. /**
  109798. * Unions this CSG with another CSG in place
  109799. * @param csg The CSG to union against this CSG
  109800. */
  109801. unionInPlace(csg: CSG): void;
  109802. /**
  109803. * Subtracts this CSG with another CSG
  109804. * @param csg The CSG to subtract against this CSG
  109805. * @returns A new CSG
  109806. */
  109807. subtract(csg: CSG): CSG;
  109808. /**
  109809. * Subtracts this CSG with another CSG in place
  109810. * @param csg The CSG to subtact against this CSG
  109811. */
  109812. subtractInPlace(csg: CSG): void;
  109813. /**
  109814. * Intersect this CSG with another CSG
  109815. * @param csg The CSG to intersect against this CSG
  109816. * @returns A new CSG
  109817. */
  109818. intersect(csg: CSG): CSG;
  109819. /**
  109820. * Intersects this CSG with another CSG in place
  109821. * @param csg The CSG to intersect against this CSG
  109822. */
  109823. intersectInPlace(csg: CSG): void;
  109824. /**
  109825. * Return a new CSG solid with solid and empty space switched. This solid is
  109826. * not modified.
  109827. * @returns A new CSG solid with solid and empty space switched
  109828. */
  109829. inverse(): CSG;
  109830. /**
  109831. * Inverses the CSG in place
  109832. */
  109833. inverseInPlace(): void;
  109834. /**
  109835. * This is used to keep meshes transformations so they can be restored
  109836. * when we build back a Babylon Mesh
  109837. * NB : All CSG operations are performed in world coordinates
  109838. * @param csg The CSG to copy the transform attributes from
  109839. * @returns This CSG
  109840. */
  109841. copyTransformAttributes(csg: CSG): CSG;
  109842. /**
  109843. * Build Raw mesh from CSG
  109844. * Coordinates here are in world space
  109845. * @param name The name of the mesh geometry
  109846. * @param scene The Scene
  109847. * @param keepSubMeshes Specifies if the submeshes should be kept
  109848. * @returns A new Mesh
  109849. */
  109850. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109851. /**
  109852. * Build Mesh from CSG taking material and transforms into account
  109853. * @param name The name of the Mesh
  109854. * @param material The material of the Mesh
  109855. * @param scene The Scene
  109856. * @param keepSubMeshes Specifies if submeshes should be kept
  109857. * @returns The new Mesh
  109858. */
  109859. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109860. }
  109861. }
  109862. declare module BABYLON {
  109863. /**
  109864. * Class used to create a trail following a mesh
  109865. */
  109866. export class TrailMesh extends Mesh {
  109867. private _generator;
  109868. private _autoStart;
  109869. private _running;
  109870. private _diameter;
  109871. private _length;
  109872. private _sectionPolygonPointsCount;
  109873. private _sectionVectors;
  109874. private _sectionNormalVectors;
  109875. private _beforeRenderObserver;
  109876. /**
  109877. * @constructor
  109878. * @param name The value used by scene.getMeshByName() to do a lookup.
  109879. * @param generator The mesh to generate a trail.
  109880. * @param scene The scene to add this mesh to.
  109881. * @param diameter Diameter of trailing mesh. Default is 1.
  109882. * @param length Length of trailing mesh. Default is 60.
  109883. * @param autoStart Automatically start trailing mesh. Default true.
  109884. */
  109885. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109886. /**
  109887. * "TrailMesh"
  109888. * @returns "TrailMesh"
  109889. */
  109890. getClassName(): string;
  109891. private _createMesh;
  109892. /**
  109893. * Start trailing mesh.
  109894. */
  109895. start(): void;
  109896. /**
  109897. * Stop trailing mesh.
  109898. */
  109899. stop(): void;
  109900. /**
  109901. * Update trailing mesh geometry.
  109902. */
  109903. update(): void;
  109904. /**
  109905. * Returns a new TrailMesh object.
  109906. * @param name is a string, the name given to the new mesh
  109907. * @param newGenerator use new generator object for cloned trail mesh
  109908. * @returns a new mesh
  109909. */
  109910. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109911. /**
  109912. * Serializes this trail mesh
  109913. * @param serializationObject object to write serialization to
  109914. */
  109915. serialize(serializationObject: any): void;
  109916. /**
  109917. * Parses a serialized trail mesh
  109918. * @param parsedMesh the serialized mesh
  109919. * @param scene the scene to create the trail mesh in
  109920. * @returns the created trail mesh
  109921. */
  109922. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109923. }
  109924. }
  109925. declare module BABYLON {
  109926. /**
  109927. * Class containing static functions to help procedurally build meshes
  109928. */
  109929. export class TorusKnotBuilder {
  109930. /**
  109931. * Creates a torus knot mesh
  109932. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109933. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109934. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109935. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109939. * @param name defines the name of the mesh
  109940. * @param options defines the options used to create the mesh
  109941. * @param scene defines the hosting scene
  109942. * @returns the torus knot mesh
  109943. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109944. */
  109945. static CreateTorusKnot(name: string, options: {
  109946. radius?: number;
  109947. tube?: number;
  109948. radialSegments?: number;
  109949. tubularSegments?: number;
  109950. p?: number;
  109951. q?: number;
  109952. updatable?: boolean;
  109953. sideOrientation?: number;
  109954. frontUVs?: Vector4;
  109955. backUVs?: Vector4;
  109956. }, scene: any): Mesh;
  109957. }
  109958. }
  109959. declare module BABYLON {
  109960. /**
  109961. * Polygon
  109962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109963. */
  109964. export class Polygon {
  109965. /**
  109966. * Creates a rectangle
  109967. * @param xmin bottom X coord
  109968. * @param ymin bottom Y coord
  109969. * @param xmax top X coord
  109970. * @param ymax top Y coord
  109971. * @returns points that make the resulting rectation
  109972. */
  109973. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109974. /**
  109975. * Creates a circle
  109976. * @param radius radius of circle
  109977. * @param cx scale in x
  109978. * @param cy scale in y
  109979. * @param numberOfSides number of sides that make up the circle
  109980. * @returns points that make the resulting circle
  109981. */
  109982. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109983. /**
  109984. * Creates a polygon from input string
  109985. * @param input Input polygon data
  109986. * @returns the parsed points
  109987. */
  109988. static Parse(input: string): Vector2[];
  109989. /**
  109990. * Starts building a polygon from x and y coordinates
  109991. * @param x x coordinate
  109992. * @param y y coordinate
  109993. * @returns the started path2
  109994. */
  109995. static StartingAt(x: number, y: number): Path2;
  109996. }
  109997. /**
  109998. * Builds a polygon
  109999. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110000. */
  110001. export class PolygonMeshBuilder {
  110002. private _points;
  110003. private _outlinepoints;
  110004. private _holes;
  110005. private _name;
  110006. private _scene;
  110007. private _epoints;
  110008. private _eholes;
  110009. private _addToepoint;
  110010. /**
  110011. * Babylon reference to the earcut plugin.
  110012. */
  110013. bjsEarcut: any;
  110014. /**
  110015. * Creates a PolygonMeshBuilder
  110016. * @param name name of the builder
  110017. * @param contours Path of the polygon
  110018. * @param scene scene to add to when creating the mesh
  110019. * @param earcutInjection can be used to inject your own earcut reference
  110020. */
  110021. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110022. /**
  110023. * Adds a whole within the polygon
  110024. * @param hole Array of points defining the hole
  110025. * @returns this
  110026. */
  110027. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110028. /**
  110029. * Creates the polygon
  110030. * @param updatable If the mesh should be updatable
  110031. * @param depth The depth of the mesh created
  110032. * @returns the created mesh
  110033. */
  110034. build(updatable?: boolean, depth?: number): Mesh;
  110035. /**
  110036. * Creates the polygon
  110037. * @param depth The depth of the mesh created
  110038. * @returns the created VertexData
  110039. */
  110040. buildVertexData(depth?: number): VertexData;
  110041. /**
  110042. * Adds a side to the polygon
  110043. * @param positions points that make the polygon
  110044. * @param normals normals of the polygon
  110045. * @param uvs uvs of the polygon
  110046. * @param indices indices of the polygon
  110047. * @param bounds bounds of the polygon
  110048. * @param points points of the polygon
  110049. * @param depth depth of the polygon
  110050. * @param flip flip of the polygon
  110051. */
  110052. private addSide;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. /**
  110057. * Class containing static functions to help procedurally build meshes
  110058. */
  110059. export class PolygonBuilder {
  110060. /**
  110061. * Creates a polygon mesh
  110062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110063. * * 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
  110064. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110067. * * Remember you can only change the shape positions, not their number when updating a polygon
  110068. * @param name defines the name of the mesh
  110069. * @param options defines the options used to create the mesh
  110070. * @param scene defines the hosting scene
  110071. * @param earcutInjection can be used to inject your own earcut reference
  110072. * @returns the polygon mesh
  110073. */
  110074. static CreatePolygon(name: string, options: {
  110075. shape: Vector3[];
  110076. holes?: Vector3[][];
  110077. depth?: number;
  110078. faceUV?: Vector4[];
  110079. faceColors?: Color4[];
  110080. updatable?: boolean;
  110081. sideOrientation?: number;
  110082. frontUVs?: Vector4;
  110083. backUVs?: Vector4;
  110084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110085. /**
  110086. * Creates an extruded polygon mesh, with depth in the Y direction.
  110087. * * 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)
  110088. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110089. * @param name defines the name of the mesh
  110090. * @param options defines the options used to create the mesh
  110091. * @param scene defines the hosting scene
  110092. * @param earcutInjection can be used to inject your own earcut reference
  110093. * @returns the polygon mesh
  110094. */
  110095. static ExtrudePolygon(name: string, options: {
  110096. shape: Vector3[];
  110097. holes?: Vector3[][];
  110098. depth?: number;
  110099. faceUV?: Vector4[];
  110100. faceColors?: Color4[];
  110101. updatable?: boolean;
  110102. sideOrientation?: number;
  110103. frontUVs?: Vector4;
  110104. backUVs?: Vector4;
  110105. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * Class containing static functions to help procedurally build meshes
  110111. */
  110112. export class LatheBuilder {
  110113. /**
  110114. * Creates lathe mesh.
  110115. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110116. * * 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
  110117. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110118. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110119. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110120. * * 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
  110121. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110122. * * 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
  110123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110127. * @param name defines the name of the mesh
  110128. * @param options defines the options used to create the mesh
  110129. * @param scene defines the hosting scene
  110130. * @returns the lathe mesh
  110131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110132. */
  110133. static CreateLathe(name: string, options: {
  110134. shape: Vector3[];
  110135. radius?: number;
  110136. tessellation?: number;
  110137. clip?: number;
  110138. arc?: number;
  110139. closed?: boolean;
  110140. updatable?: boolean;
  110141. sideOrientation?: number;
  110142. frontUVs?: Vector4;
  110143. backUVs?: Vector4;
  110144. cap?: number;
  110145. invertUV?: boolean;
  110146. }, scene?: Nullable<Scene>): Mesh;
  110147. }
  110148. }
  110149. declare module BABYLON {
  110150. /**
  110151. * Class containing static functions to help procedurally build meshes
  110152. */
  110153. export class TubeBuilder {
  110154. /**
  110155. * Creates a tube mesh.
  110156. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110157. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110158. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110159. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110160. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110161. * * 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)
  110162. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110163. * * 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
  110164. * * 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
  110165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110169. * @param name defines the name of the mesh
  110170. * @param options defines the options used to create the mesh
  110171. * @param scene defines the hosting scene
  110172. * @returns the tube mesh
  110173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110174. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110175. */
  110176. static CreateTube(name: string, options: {
  110177. path: Vector3[];
  110178. radius?: number;
  110179. tessellation?: number;
  110180. radiusFunction?: {
  110181. (i: number, distance: number): number;
  110182. };
  110183. cap?: number;
  110184. arc?: number;
  110185. updatable?: boolean;
  110186. sideOrientation?: number;
  110187. frontUVs?: Vector4;
  110188. backUVs?: Vector4;
  110189. instance?: Mesh;
  110190. invertUV?: boolean;
  110191. }, scene?: Nullable<Scene>): Mesh;
  110192. }
  110193. }
  110194. declare module BABYLON {
  110195. /**
  110196. * Class containing static functions to help procedurally build meshes
  110197. */
  110198. export class IcoSphereBuilder {
  110199. /**
  110200. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110201. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110202. * * 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`)
  110203. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110204. * * 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
  110205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110208. * @param name defines the name of the mesh
  110209. * @param options defines the options used to create the mesh
  110210. * @param scene defines the hosting scene
  110211. * @returns the icosahedron mesh
  110212. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110213. */
  110214. static CreateIcoSphere(name: string, options: {
  110215. radius?: number;
  110216. radiusX?: number;
  110217. radiusY?: number;
  110218. radiusZ?: number;
  110219. flat?: boolean;
  110220. subdivisions?: number;
  110221. sideOrientation?: number;
  110222. frontUVs?: Vector4;
  110223. backUVs?: Vector4;
  110224. updatable?: boolean;
  110225. }, scene?: Nullable<Scene>): Mesh;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * Class containing static functions to help procedurally build meshes
  110231. */
  110232. export class DecalBuilder {
  110233. /**
  110234. * Creates a decal mesh.
  110235. * 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
  110236. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110237. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110238. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110239. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110240. * @param name defines the name of the mesh
  110241. * @param sourceMesh defines the mesh where the decal must be applied
  110242. * @param options defines the options used to create the mesh
  110243. * @param scene defines the hosting scene
  110244. * @returns the decal mesh
  110245. * @see https://doc.babylonjs.com/how_to/decals
  110246. */
  110247. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110248. position?: Vector3;
  110249. normal?: Vector3;
  110250. size?: Vector3;
  110251. angle?: number;
  110252. }): Mesh;
  110253. }
  110254. }
  110255. declare module BABYLON {
  110256. /**
  110257. * Class containing static functions to help procedurally build meshes
  110258. */
  110259. export class MeshBuilder {
  110260. /**
  110261. * Creates a box mesh
  110262. * * The parameter `size` sets the size (float) of each box side (default 1)
  110263. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110264. * * 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)
  110265. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110269. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110270. * @param name defines the name of the mesh
  110271. * @param options defines the options used to create the mesh
  110272. * @param scene defines the hosting scene
  110273. * @returns the box mesh
  110274. */
  110275. static CreateBox(name: string, options: {
  110276. size?: number;
  110277. width?: number;
  110278. height?: number;
  110279. depth?: number;
  110280. faceUV?: Vector4[];
  110281. faceColors?: Color4[];
  110282. sideOrientation?: number;
  110283. frontUVs?: Vector4;
  110284. backUVs?: Vector4;
  110285. updatable?: boolean;
  110286. }, scene?: Nullable<Scene>): Mesh;
  110287. /**
  110288. * Creates a sphere mesh
  110289. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110290. * * 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`)
  110291. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110292. * * 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
  110293. * * 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)
  110294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110297. * @param name defines the name of the mesh
  110298. * @param options defines the options used to create the mesh
  110299. * @param scene defines the hosting scene
  110300. * @returns the sphere mesh
  110301. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110302. */
  110303. static CreateSphere(name: string, options: {
  110304. segments?: number;
  110305. diameter?: number;
  110306. diameterX?: number;
  110307. diameterY?: number;
  110308. diameterZ?: number;
  110309. arc?: number;
  110310. slice?: number;
  110311. sideOrientation?: number;
  110312. frontUVs?: Vector4;
  110313. backUVs?: Vector4;
  110314. updatable?: boolean;
  110315. }, scene?: Nullable<Scene>): Mesh;
  110316. /**
  110317. * Creates a plane polygonal mesh. By default, this is a disc
  110318. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110319. * * 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
  110320. * * 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
  110321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110324. * @param name defines the name of the mesh
  110325. * @param options defines the options used to create the mesh
  110326. * @param scene defines the hosting scene
  110327. * @returns the plane polygonal mesh
  110328. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110329. */
  110330. static CreateDisc(name: string, options: {
  110331. radius?: number;
  110332. tessellation?: number;
  110333. arc?: number;
  110334. updatable?: boolean;
  110335. sideOrientation?: number;
  110336. frontUVs?: Vector4;
  110337. backUVs?: Vector4;
  110338. }, scene?: Nullable<Scene>): Mesh;
  110339. /**
  110340. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110341. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110342. * * 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`)
  110343. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110344. * * 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
  110345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110348. * @param name defines the name of the mesh
  110349. * @param options defines the options used to create the mesh
  110350. * @param scene defines the hosting scene
  110351. * @returns the icosahedron mesh
  110352. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110353. */
  110354. static CreateIcoSphere(name: string, options: {
  110355. radius?: number;
  110356. radiusX?: number;
  110357. radiusY?: number;
  110358. radiusZ?: number;
  110359. flat?: boolean;
  110360. subdivisions?: number;
  110361. sideOrientation?: number;
  110362. frontUVs?: Vector4;
  110363. backUVs?: Vector4;
  110364. updatable?: boolean;
  110365. }, scene?: Nullable<Scene>): Mesh;
  110366. /**
  110367. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110368. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110369. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110370. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110371. * * 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
  110372. * * 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
  110373. * * 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
  110374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110377. * * 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
  110378. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110379. * * 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
  110380. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110382. * @param name defines the name of the mesh
  110383. * @param options defines the options used to create the mesh
  110384. * @param scene defines the hosting scene
  110385. * @returns the ribbon mesh
  110386. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110388. */
  110389. static CreateRibbon(name: string, options: {
  110390. pathArray: Vector3[][];
  110391. closeArray?: boolean;
  110392. closePath?: boolean;
  110393. offset?: number;
  110394. updatable?: boolean;
  110395. sideOrientation?: number;
  110396. frontUVs?: Vector4;
  110397. backUVs?: Vector4;
  110398. instance?: Mesh;
  110399. invertUV?: boolean;
  110400. uvs?: Vector2[];
  110401. colors?: Color4[];
  110402. }, scene?: Nullable<Scene>): Mesh;
  110403. /**
  110404. * Creates a cylinder or a cone mesh
  110405. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110406. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110407. * * 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.
  110408. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110409. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110410. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110411. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110412. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110413. * * 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).
  110414. * * 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
  110415. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110416. * * 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
  110417. * * 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.
  110418. * * If `enclose` is false, a ring surface is one element.
  110419. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110420. * * 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
  110421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110424. * @param name defines the name of the mesh
  110425. * @param options defines the options used to create the mesh
  110426. * @param scene defines the hosting scene
  110427. * @returns the cylinder mesh
  110428. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110429. */
  110430. static CreateCylinder(name: string, options: {
  110431. height?: number;
  110432. diameterTop?: number;
  110433. diameterBottom?: number;
  110434. diameter?: number;
  110435. tessellation?: number;
  110436. subdivisions?: number;
  110437. arc?: number;
  110438. faceColors?: Color4[];
  110439. faceUV?: Vector4[];
  110440. updatable?: boolean;
  110441. hasRings?: boolean;
  110442. enclose?: boolean;
  110443. sideOrientation?: number;
  110444. frontUVs?: Vector4;
  110445. backUVs?: Vector4;
  110446. }, scene?: Nullable<Scene>): Mesh;
  110447. /**
  110448. * Creates a torus mesh
  110449. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110450. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110451. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110455. * @param name defines the name of the mesh
  110456. * @param options defines the options used to create the mesh
  110457. * @param scene defines the hosting scene
  110458. * @returns the torus mesh
  110459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110460. */
  110461. static CreateTorus(name: string, options: {
  110462. diameter?: number;
  110463. thickness?: number;
  110464. tessellation?: number;
  110465. updatable?: boolean;
  110466. sideOrientation?: number;
  110467. frontUVs?: Vector4;
  110468. backUVs?: Vector4;
  110469. }, scene?: Nullable<Scene>): Mesh;
  110470. /**
  110471. * Creates a torus knot mesh
  110472. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110473. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110474. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110475. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110479. * @param name defines the name of the mesh
  110480. * @param options defines the options used to create the mesh
  110481. * @param scene defines the hosting scene
  110482. * @returns the torus knot mesh
  110483. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110484. */
  110485. static CreateTorusKnot(name: string, options: {
  110486. radius?: number;
  110487. tube?: number;
  110488. radialSegments?: number;
  110489. tubularSegments?: number;
  110490. p?: number;
  110491. q?: number;
  110492. updatable?: boolean;
  110493. sideOrientation?: number;
  110494. frontUVs?: Vector4;
  110495. backUVs?: Vector4;
  110496. }, scene?: Nullable<Scene>): Mesh;
  110497. /**
  110498. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110499. * * 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
  110500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110501. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110502. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110503. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110504. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110505. * * 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
  110506. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110509. * @param name defines the name of the new line system
  110510. * @param options defines the options used to create the line system
  110511. * @param scene defines the hosting scene
  110512. * @returns a new line system mesh
  110513. */
  110514. static CreateLineSystem(name: string, options: {
  110515. lines: Vector3[][];
  110516. updatable?: boolean;
  110517. instance?: Nullable<LinesMesh>;
  110518. colors?: Nullable<Color4[][]>;
  110519. useVertexAlpha?: boolean;
  110520. }, scene: Nullable<Scene>): LinesMesh;
  110521. /**
  110522. * Creates a line mesh
  110523. * 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
  110524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110525. * * The parameter `points` is an array successive Vector3
  110526. * * 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
  110527. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110528. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110529. * * When updating an instance, remember that only point positions can change, not the number of points
  110530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110532. * @param name defines the name of the new line system
  110533. * @param options defines the options used to create the line system
  110534. * @param scene defines the hosting scene
  110535. * @returns a new line mesh
  110536. */
  110537. static CreateLines(name: string, options: {
  110538. points: Vector3[];
  110539. updatable?: boolean;
  110540. instance?: Nullable<LinesMesh>;
  110541. colors?: Color4[];
  110542. useVertexAlpha?: boolean;
  110543. }, scene?: Nullable<Scene>): LinesMesh;
  110544. /**
  110545. * Creates a dashed line mesh
  110546. * * 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
  110547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110548. * * The parameter `points` is an array successive Vector3
  110549. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110550. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110551. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110552. * * 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
  110553. * * When updating an instance, remember that only point positions can change, not the number of points
  110554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110555. * @param name defines the name of the mesh
  110556. * @param options defines the options used to create the mesh
  110557. * @param scene defines the hosting scene
  110558. * @returns the dashed line mesh
  110559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110560. */
  110561. static CreateDashedLines(name: string, options: {
  110562. points: Vector3[];
  110563. dashSize?: number;
  110564. gapSize?: number;
  110565. dashNb?: number;
  110566. updatable?: boolean;
  110567. instance?: LinesMesh;
  110568. }, scene?: Nullable<Scene>): LinesMesh;
  110569. /**
  110570. * 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.
  110571. * * 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.
  110572. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110573. * * 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.
  110574. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110575. * * 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
  110576. * * 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
  110577. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110582. * @param name defines the name of the mesh
  110583. * @param options defines the options used to create the mesh
  110584. * @param scene defines the hosting scene
  110585. * @returns the extruded shape mesh
  110586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110588. */
  110589. static ExtrudeShape(name: string, options: {
  110590. shape: Vector3[];
  110591. path: Vector3[];
  110592. scale?: number;
  110593. rotation?: number;
  110594. cap?: number;
  110595. updatable?: boolean;
  110596. sideOrientation?: number;
  110597. frontUVs?: Vector4;
  110598. backUVs?: Vector4;
  110599. instance?: Mesh;
  110600. invertUV?: boolean;
  110601. }, scene?: Nullable<Scene>): Mesh;
  110602. /**
  110603. * Creates an custom extruded shape mesh.
  110604. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110605. * * 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.
  110606. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110607. * * 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
  110608. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110609. * * 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
  110610. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110611. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110612. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110613. * * 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
  110614. * * 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
  110615. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110620. * @param name defines the name of the mesh
  110621. * @param options defines the options used to create the mesh
  110622. * @param scene defines the hosting scene
  110623. * @returns the custom extruded shape mesh
  110624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110627. */
  110628. static ExtrudeShapeCustom(name: string, options: {
  110629. shape: Vector3[];
  110630. path: Vector3[];
  110631. scaleFunction?: any;
  110632. rotationFunction?: any;
  110633. ribbonCloseArray?: boolean;
  110634. ribbonClosePath?: boolean;
  110635. cap?: number;
  110636. updatable?: boolean;
  110637. sideOrientation?: number;
  110638. frontUVs?: Vector4;
  110639. backUVs?: Vector4;
  110640. instance?: Mesh;
  110641. invertUV?: boolean;
  110642. }, scene?: Nullable<Scene>): Mesh;
  110643. /**
  110644. * Creates lathe mesh.
  110645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110646. * * 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
  110647. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110648. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110649. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110650. * * 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
  110651. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110652. * * 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
  110653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110657. * @param name defines the name of the mesh
  110658. * @param options defines the options used to create the mesh
  110659. * @param scene defines the hosting scene
  110660. * @returns the lathe mesh
  110661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110662. */
  110663. static CreateLathe(name: string, options: {
  110664. shape: Vector3[];
  110665. radius?: number;
  110666. tessellation?: number;
  110667. clip?: number;
  110668. arc?: number;
  110669. closed?: boolean;
  110670. updatable?: boolean;
  110671. sideOrientation?: number;
  110672. frontUVs?: Vector4;
  110673. backUVs?: Vector4;
  110674. cap?: number;
  110675. invertUV?: boolean;
  110676. }, scene?: Nullable<Scene>): Mesh;
  110677. /**
  110678. * Creates a plane mesh
  110679. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110680. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110681. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110685. * @param name defines the name of the mesh
  110686. * @param options defines the options used to create the mesh
  110687. * @param scene defines the hosting scene
  110688. * @returns the plane mesh
  110689. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110690. */
  110691. static CreatePlane(name: string, options: {
  110692. size?: number;
  110693. width?: number;
  110694. height?: number;
  110695. sideOrientation?: number;
  110696. frontUVs?: Vector4;
  110697. backUVs?: Vector4;
  110698. updatable?: boolean;
  110699. sourcePlane?: Plane;
  110700. }, scene?: Nullable<Scene>): Mesh;
  110701. /**
  110702. * Creates a ground mesh
  110703. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110704. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110706. * @param name defines the name of the mesh
  110707. * @param options defines the options used to create the mesh
  110708. * @param scene defines the hosting scene
  110709. * @returns the ground mesh
  110710. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110711. */
  110712. static CreateGround(name: string, options: {
  110713. width?: number;
  110714. height?: number;
  110715. subdivisions?: number;
  110716. subdivisionsX?: number;
  110717. subdivisionsY?: number;
  110718. updatable?: boolean;
  110719. }, scene?: Nullable<Scene>): Mesh;
  110720. /**
  110721. * Creates a tiled ground mesh
  110722. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110723. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110724. * * 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
  110725. * * 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
  110726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110727. * @param name defines the name of the mesh
  110728. * @param options defines the options used to create the mesh
  110729. * @param scene defines the hosting scene
  110730. * @returns the tiled ground mesh
  110731. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110732. */
  110733. static CreateTiledGround(name: string, options: {
  110734. xmin: number;
  110735. zmin: number;
  110736. xmax: number;
  110737. zmax: number;
  110738. subdivisions?: {
  110739. w: number;
  110740. h: number;
  110741. };
  110742. precision?: {
  110743. w: number;
  110744. h: number;
  110745. };
  110746. updatable?: boolean;
  110747. }, scene?: Nullable<Scene>): Mesh;
  110748. /**
  110749. * Creates a ground mesh from a height map
  110750. * * The parameter `url` sets the URL of the height map image resource.
  110751. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110752. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110753. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110754. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110755. * * 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.
  110756. * * 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).
  110757. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110759. * @param name defines the name of the mesh
  110760. * @param url defines the url to the height map
  110761. * @param options defines the options used to create the mesh
  110762. * @param scene defines the hosting scene
  110763. * @returns the ground mesh
  110764. * @see https://doc.babylonjs.com/babylon101/height_map
  110765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110766. */
  110767. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110768. width?: number;
  110769. height?: number;
  110770. subdivisions?: number;
  110771. minHeight?: number;
  110772. maxHeight?: number;
  110773. colorFilter?: Color3;
  110774. alphaFilter?: number;
  110775. updatable?: boolean;
  110776. onReady?: (mesh: GroundMesh) => void;
  110777. }, scene?: Nullable<Scene>): GroundMesh;
  110778. /**
  110779. * Creates a polygon mesh
  110780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110781. * * 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
  110782. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110785. * * Remember you can only change the shape positions, not their number when updating a polygon
  110786. * @param name defines the name of the mesh
  110787. * @param options defines the options used to create the mesh
  110788. * @param scene defines the hosting scene
  110789. * @param earcutInjection can be used to inject your own earcut reference
  110790. * @returns the polygon mesh
  110791. */
  110792. static CreatePolygon(name: string, options: {
  110793. shape: Vector3[];
  110794. holes?: Vector3[][];
  110795. depth?: number;
  110796. faceUV?: Vector4[];
  110797. faceColors?: Color4[];
  110798. updatable?: boolean;
  110799. sideOrientation?: number;
  110800. frontUVs?: Vector4;
  110801. backUVs?: Vector4;
  110802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110803. /**
  110804. * Creates an extruded polygon mesh, with depth in the Y direction.
  110805. * * 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)
  110806. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110807. * @param name defines the name of the mesh
  110808. * @param options defines the options used to create the mesh
  110809. * @param scene defines the hosting scene
  110810. * @param earcutInjection can be used to inject your own earcut reference
  110811. * @returns the polygon mesh
  110812. */
  110813. static ExtrudePolygon(name: string, options: {
  110814. shape: Vector3[];
  110815. holes?: Vector3[][];
  110816. depth?: number;
  110817. faceUV?: Vector4[];
  110818. faceColors?: Color4[];
  110819. updatable?: boolean;
  110820. sideOrientation?: number;
  110821. frontUVs?: Vector4;
  110822. backUVs?: Vector4;
  110823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110824. /**
  110825. * Creates a tube mesh.
  110826. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110827. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110828. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110829. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110830. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110831. * * 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)
  110832. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110833. * * 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
  110834. * * 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
  110835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110839. * @param name defines the name of the mesh
  110840. * @param options defines the options used to create the mesh
  110841. * @param scene defines the hosting scene
  110842. * @returns the tube mesh
  110843. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110844. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110845. */
  110846. static CreateTube(name: string, options: {
  110847. path: Vector3[];
  110848. radius?: number;
  110849. tessellation?: number;
  110850. radiusFunction?: {
  110851. (i: number, distance: number): number;
  110852. };
  110853. cap?: number;
  110854. arc?: number;
  110855. updatable?: boolean;
  110856. sideOrientation?: number;
  110857. frontUVs?: Vector4;
  110858. backUVs?: Vector4;
  110859. instance?: Mesh;
  110860. invertUV?: boolean;
  110861. }, scene?: Nullable<Scene>): Mesh;
  110862. /**
  110863. * Creates a polyhedron mesh
  110864. * * 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
  110865. * * The parameter `size` (positive float, default 1) sets the polygon size
  110866. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110867. * * 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`
  110868. * * 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
  110869. * * 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)`)
  110870. * * 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
  110871. * * 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
  110872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110875. * @param name defines the name of the mesh
  110876. * @param options defines the options used to create the mesh
  110877. * @param scene defines the hosting scene
  110878. * @returns the polyhedron mesh
  110879. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110880. */
  110881. static CreatePolyhedron(name: string, options: {
  110882. type?: number;
  110883. size?: number;
  110884. sizeX?: number;
  110885. sizeY?: number;
  110886. sizeZ?: number;
  110887. custom?: any;
  110888. faceUV?: Vector4[];
  110889. faceColors?: Color4[];
  110890. flat?: boolean;
  110891. updatable?: boolean;
  110892. sideOrientation?: number;
  110893. frontUVs?: Vector4;
  110894. backUVs?: Vector4;
  110895. }, scene?: Nullable<Scene>): Mesh;
  110896. /**
  110897. * Creates a decal mesh.
  110898. * 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
  110899. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110900. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110901. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110902. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110903. * @param name defines the name of the mesh
  110904. * @param sourceMesh defines the mesh where the decal must be applied
  110905. * @param options defines the options used to create the mesh
  110906. * @param scene defines the hosting scene
  110907. * @returns the decal mesh
  110908. * @see https://doc.babylonjs.com/how_to/decals
  110909. */
  110910. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110911. position?: Vector3;
  110912. normal?: Vector3;
  110913. size?: Vector3;
  110914. angle?: number;
  110915. }): Mesh;
  110916. }
  110917. }
  110918. declare module BABYLON {
  110919. /**
  110920. * A simplifier interface for future simplification implementations
  110921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110922. */
  110923. export interface ISimplifier {
  110924. /**
  110925. * Simplification of a given mesh according to the given settings.
  110926. * Since this requires computation, it is assumed that the function runs async.
  110927. * @param settings The settings of the simplification, including quality and distance
  110928. * @param successCallback A callback that will be called after the mesh was simplified.
  110929. * @param errorCallback in case of an error, this callback will be called. optional.
  110930. */
  110931. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110932. }
  110933. /**
  110934. * Expected simplification settings.
  110935. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110936. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110937. */
  110938. export interface ISimplificationSettings {
  110939. /**
  110940. * Gets or sets the expected quality
  110941. */
  110942. quality: number;
  110943. /**
  110944. * Gets or sets the distance when this optimized version should be used
  110945. */
  110946. distance: number;
  110947. /**
  110948. * Gets an already optimized mesh
  110949. */
  110950. optimizeMesh?: boolean;
  110951. }
  110952. /**
  110953. * Class used to specify simplification options
  110954. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110955. */
  110956. export class SimplificationSettings implements ISimplificationSettings {
  110957. /** expected quality */
  110958. quality: number;
  110959. /** distance when this optimized version should be used */
  110960. distance: number;
  110961. /** already optimized mesh */
  110962. optimizeMesh?: boolean | undefined;
  110963. /**
  110964. * Creates a SimplificationSettings
  110965. * @param quality expected quality
  110966. * @param distance distance when this optimized version should be used
  110967. * @param optimizeMesh already optimized mesh
  110968. */
  110969. constructor(
  110970. /** expected quality */
  110971. quality: number,
  110972. /** distance when this optimized version should be used */
  110973. distance: number,
  110974. /** already optimized mesh */
  110975. optimizeMesh?: boolean | undefined);
  110976. }
  110977. /**
  110978. * Interface used to define a simplification task
  110979. */
  110980. export interface ISimplificationTask {
  110981. /**
  110982. * Array of settings
  110983. */
  110984. settings: Array<ISimplificationSettings>;
  110985. /**
  110986. * Simplification type
  110987. */
  110988. simplificationType: SimplificationType;
  110989. /**
  110990. * Mesh to simplify
  110991. */
  110992. mesh: Mesh;
  110993. /**
  110994. * Callback called on success
  110995. */
  110996. successCallback?: () => void;
  110997. /**
  110998. * Defines if parallel processing can be used
  110999. */
  111000. parallelProcessing: boolean;
  111001. }
  111002. /**
  111003. * Queue used to order the simplification tasks
  111004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111005. */
  111006. export class SimplificationQueue {
  111007. private _simplificationArray;
  111008. /**
  111009. * Gets a boolean indicating that the process is still running
  111010. */
  111011. running: boolean;
  111012. /**
  111013. * Creates a new queue
  111014. */
  111015. constructor();
  111016. /**
  111017. * Adds a new simplification task
  111018. * @param task defines a task to add
  111019. */
  111020. addTask(task: ISimplificationTask): void;
  111021. /**
  111022. * Execute next task
  111023. */
  111024. executeNext(): void;
  111025. /**
  111026. * Execute a simplification task
  111027. * @param task defines the task to run
  111028. */
  111029. runSimplification(task: ISimplificationTask): void;
  111030. private getSimplifier;
  111031. }
  111032. /**
  111033. * The implemented types of simplification
  111034. * At the moment only Quadratic Error Decimation is implemented
  111035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111036. */
  111037. export enum SimplificationType {
  111038. /** Quadratic error decimation */
  111039. QUADRATIC = 0
  111040. }
  111041. }
  111042. declare module BABYLON {
  111043. interface Scene {
  111044. /** @hidden (Backing field) */
  111045. _simplificationQueue: SimplificationQueue;
  111046. /**
  111047. * Gets or sets the simplification queue attached to the scene
  111048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111049. */
  111050. simplificationQueue: SimplificationQueue;
  111051. }
  111052. interface Mesh {
  111053. /**
  111054. * Simplify the mesh according to the given array of settings.
  111055. * Function will return immediately and will simplify async
  111056. * @param settings a collection of simplification settings
  111057. * @param parallelProcessing should all levels calculate parallel or one after the other
  111058. * @param simplificationType the type of simplification to run
  111059. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111060. * @returns the current mesh
  111061. */
  111062. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111063. }
  111064. /**
  111065. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111066. * created in a scene
  111067. */
  111068. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111069. /**
  111070. * The component name helpfull to identify the component in the list of scene components.
  111071. */
  111072. readonly name: string;
  111073. /**
  111074. * The scene the component belongs to.
  111075. */
  111076. scene: Scene;
  111077. /**
  111078. * Creates a new instance of the component for the given scene
  111079. * @param scene Defines the scene to register the component in
  111080. */
  111081. constructor(scene: Scene);
  111082. /**
  111083. * Registers the component in a given scene
  111084. */
  111085. register(): void;
  111086. /**
  111087. * Rebuilds the elements related to this component in case of
  111088. * context lost for instance.
  111089. */
  111090. rebuild(): void;
  111091. /**
  111092. * Disposes the component and the associated ressources
  111093. */
  111094. dispose(): void;
  111095. private _beforeCameraUpdate;
  111096. }
  111097. }
  111098. declare module BABYLON {
  111099. /**
  111100. * Class used to enable access to IndexedDB
  111101. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111102. */
  111103. export class Database implements IOfflineProvider {
  111104. private _callbackManifestChecked;
  111105. private _currentSceneUrl;
  111106. private _db;
  111107. private _enableSceneOffline;
  111108. private _enableTexturesOffline;
  111109. private _manifestVersionFound;
  111110. private _mustUpdateRessources;
  111111. private _hasReachedQuota;
  111112. private _isSupported;
  111113. private _idbFactory;
  111114. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111115. private static IsUASupportingBlobStorage;
  111116. /**
  111117. * Gets a boolean indicating if Database storate is enabled (off by default)
  111118. */
  111119. static IDBStorageEnabled: boolean;
  111120. /**
  111121. * Gets a boolean indicating if scene must be saved in the database
  111122. */
  111123. readonly enableSceneOffline: boolean;
  111124. /**
  111125. * Gets a boolean indicating if textures must be saved in the database
  111126. */
  111127. readonly enableTexturesOffline: boolean;
  111128. /**
  111129. * Creates a new Database
  111130. * @param urlToScene defines the url to load the scene
  111131. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111132. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111133. */
  111134. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111135. private static _ParseURL;
  111136. private static _ReturnFullUrlLocation;
  111137. private _checkManifestFile;
  111138. /**
  111139. * Open the database and make it available
  111140. * @param successCallback defines the callback to call on success
  111141. * @param errorCallback defines the callback to call on error
  111142. */
  111143. open(successCallback: () => void, errorCallback: () => void): void;
  111144. /**
  111145. * Loads an image from the database
  111146. * @param url defines the url to load from
  111147. * @param image defines the target DOM image
  111148. */
  111149. loadImage(url: string, image: HTMLImageElement): void;
  111150. private _loadImageFromDBAsync;
  111151. private _saveImageIntoDBAsync;
  111152. private _checkVersionFromDB;
  111153. private _loadVersionFromDBAsync;
  111154. private _saveVersionIntoDBAsync;
  111155. /**
  111156. * Loads a file from database
  111157. * @param url defines the URL to load from
  111158. * @param sceneLoaded defines a callback to call on success
  111159. * @param progressCallBack defines a callback to call when progress changed
  111160. * @param errorCallback defines a callback to call on error
  111161. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111162. */
  111163. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111164. private _loadFileAsync;
  111165. private _saveFileAsync;
  111166. /**
  111167. * Validates if xhr data is correct
  111168. * @param xhr defines the request to validate
  111169. * @param dataType defines the expected data type
  111170. * @returns true if data is correct
  111171. */
  111172. private static _ValidateXHRData;
  111173. }
  111174. }
  111175. declare module BABYLON {
  111176. /** @hidden */
  111177. export var gpuUpdateParticlesPixelShader: {
  111178. name: string;
  111179. shader: string;
  111180. };
  111181. }
  111182. declare module BABYLON {
  111183. /** @hidden */
  111184. export var gpuUpdateParticlesVertexShader: {
  111185. name: string;
  111186. shader: string;
  111187. };
  111188. }
  111189. declare module BABYLON {
  111190. /** @hidden */
  111191. export var clipPlaneFragmentDeclaration2: {
  111192. name: string;
  111193. shader: string;
  111194. };
  111195. }
  111196. declare module BABYLON {
  111197. /** @hidden */
  111198. export var gpuRenderParticlesPixelShader: {
  111199. name: string;
  111200. shader: string;
  111201. };
  111202. }
  111203. declare module BABYLON {
  111204. /** @hidden */
  111205. export var clipPlaneVertexDeclaration2: {
  111206. name: string;
  111207. shader: string;
  111208. };
  111209. }
  111210. declare module BABYLON {
  111211. /** @hidden */
  111212. export var gpuRenderParticlesVertexShader: {
  111213. name: string;
  111214. shader: string;
  111215. };
  111216. }
  111217. declare module BABYLON {
  111218. /**
  111219. * This represents a GPU particle system in Babylon
  111220. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111221. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111222. */
  111223. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111224. /**
  111225. * The layer mask we are rendering the particles through.
  111226. */
  111227. layerMask: number;
  111228. private _capacity;
  111229. private _activeCount;
  111230. private _currentActiveCount;
  111231. private _accumulatedCount;
  111232. private _renderEffect;
  111233. private _updateEffect;
  111234. private _buffer0;
  111235. private _buffer1;
  111236. private _spriteBuffer;
  111237. private _updateVAO;
  111238. private _renderVAO;
  111239. private _targetIndex;
  111240. private _sourceBuffer;
  111241. private _targetBuffer;
  111242. private _engine;
  111243. private _currentRenderId;
  111244. private _started;
  111245. private _stopped;
  111246. private _timeDelta;
  111247. private _randomTexture;
  111248. private _randomTexture2;
  111249. private _attributesStrideSize;
  111250. private _updateEffectOptions;
  111251. private _randomTextureSize;
  111252. private _actualFrame;
  111253. private readonly _rawTextureWidth;
  111254. /**
  111255. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111256. */
  111257. static readonly IsSupported: boolean;
  111258. /**
  111259. * An event triggered when the system is disposed.
  111260. */
  111261. onDisposeObservable: Observable<GPUParticleSystem>;
  111262. /**
  111263. * Gets the maximum number of particles active at the same time.
  111264. * @returns The max number of active particles.
  111265. */
  111266. getCapacity(): number;
  111267. /**
  111268. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111269. * to override the particles.
  111270. */
  111271. forceDepthWrite: boolean;
  111272. /**
  111273. * Gets or set the number of active particles
  111274. */
  111275. activeParticleCount: number;
  111276. private _preWarmDone;
  111277. /**
  111278. * Is this system ready to be used/rendered
  111279. * @return true if the system is ready
  111280. */
  111281. isReady(): boolean;
  111282. /**
  111283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111284. * @returns True if it has been started, otherwise false.
  111285. */
  111286. isStarted(): boolean;
  111287. /**
  111288. * Starts the particle system and begins to emit
  111289. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111290. */
  111291. start(delay?: number): void;
  111292. /**
  111293. * Stops the particle system.
  111294. */
  111295. stop(): void;
  111296. /**
  111297. * Remove all active particles
  111298. */
  111299. reset(): void;
  111300. /**
  111301. * Returns the string "GPUParticleSystem"
  111302. * @returns a string containing the class name
  111303. */
  111304. getClassName(): string;
  111305. private _colorGradientsTexture;
  111306. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111307. /**
  111308. * Adds a new color gradient
  111309. * @param gradient defines the gradient to use (between 0 and 1)
  111310. * @param color1 defines the color to affect to the specified gradient
  111311. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111312. * @returns the current particle system
  111313. */
  111314. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111315. /**
  111316. * Remove a specific color gradient
  111317. * @param gradient defines the gradient to remove
  111318. * @returns the current particle system
  111319. */
  111320. removeColorGradient(gradient: number): GPUParticleSystem;
  111321. private _angularSpeedGradientsTexture;
  111322. private _sizeGradientsTexture;
  111323. private _velocityGradientsTexture;
  111324. private _limitVelocityGradientsTexture;
  111325. private _dragGradientsTexture;
  111326. private _addFactorGradient;
  111327. /**
  111328. * Adds a new size gradient
  111329. * @param gradient defines the gradient to use (between 0 and 1)
  111330. * @param factor defines the size factor to affect to the specified gradient
  111331. * @returns the current particle system
  111332. */
  111333. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111334. /**
  111335. * Remove a specific size gradient
  111336. * @param gradient defines the gradient to remove
  111337. * @returns the current particle system
  111338. */
  111339. removeSizeGradient(gradient: number): GPUParticleSystem;
  111340. /**
  111341. * Adds a new angular speed gradient
  111342. * @param gradient defines the gradient to use (between 0 and 1)
  111343. * @param factor defines the angular speed to affect to the specified gradient
  111344. * @returns the current particle system
  111345. */
  111346. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111347. /**
  111348. * Remove a specific angular speed gradient
  111349. * @param gradient defines the gradient to remove
  111350. * @returns the current particle system
  111351. */
  111352. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111353. /**
  111354. * Adds a new velocity gradient
  111355. * @param gradient defines the gradient to use (between 0 and 1)
  111356. * @param factor defines the velocity to affect to the specified gradient
  111357. * @returns the current particle system
  111358. */
  111359. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111360. /**
  111361. * Remove a specific velocity gradient
  111362. * @param gradient defines the gradient to remove
  111363. * @returns the current particle system
  111364. */
  111365. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111366. /**
  111367. * Adds a new limit velocity gradient
  111368. * @param gradient defines the gradient to use (between 0 and 1)
  111369. * @param factor defines the limit velocity value to affect to the specified gradient
  111370. * @returns the current particle system
  111371. */
  111372. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111373. /**
  111374. * Remove a specific limit velocity gradient
  111375. * @param gradient defines the gradient to remove
  111376. * @returns the current particle system
  111377. */
  111378. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111379. /**
  111380. * Adds a new drag gradient
  111381. * @param gradient defines the gradient to use (between 0 and 1)
  111382. * @param factor defines the drag value to affect to the specified gradient
  111383. * @returns the current particle system
  111384. */
  111385. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111386. /**
  111387. * Remove a specific drag gradient
  111388. * @param gradient defines the gradient to remove
  111389. * @returns the current particle system
  111390. */
  111391. removeDragGradient(gradient: number): GPUParticleSystem;
  111392. /**
  111393. * Not supported by GPUParticleSystem
  111394. * @param gradient defines the gradient to use (between 0 and 1)
  111395. * @param factor defines the emit rate value to affect to the specified gradient
  111396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111397. * @returns the current particle system
  111398. */
  111399. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111400. /**
  111401. * Not supported by GPUParticleSystem
  111402. * @param gradient defines the gradient to remove
  111403. * @returns the current particle system
  111404. */
  111405. removeEmitRateGradient(gradient: number): IParticleSystem;
  111406. /**
  111407. * Not supported by GPUParticleSystem
  111408. * @param gradient defines the gradient to use (between 0 and 1)
  111409. * @param factor defines the start size value to affect to the specified gradient
  111410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111411. * @returns the current particle system
  111412. */
  111413. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111414. /**
  111415. * Not supported by GPUParticleSystem
  111416. * @param gradient defines the gradient to remove
  111417. * @returns the current particle system
  111418. */
  111419. removeStartSizeGradient(gradient: number): IParticleSystem;
  111420. /**
  111421. * Not supported by GPUParticleSystem
  111422. * @param gradient defines the gradient to use (between 0 and 1)
  111423. * @param min defines the color remap minimal range
  111424. * @param max defines the color remap maximal range
  111425. * @returns the current particle system
  111426. */
  111427. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111428. /**
  111429. * Not supported by GPUParticleSystem
  111430. * @param gradient defines the gradient to remove
  111431. * @returns the current particle system
  111432. */
  111433. removeColorRemapGradient(): IParticleSystem;
  111434. /**
  111435. * Not supported by GPUParticleSystem
  111436. * @param gradient defines the gradient to use (between 0 and 1)
  111437. * @param min defines the alpha remap minimal range
  111438. * @param max defines the alpha remap maximal range
  111439. * @returns the current particle system
  111440. */
  111441. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111442. /**
  111443. * Not supported by GPUParticleSystem
  111444. * @param gradient defines the gradient to remove
  111445. * @returns the current particle system
  111446. */
  111447. removeAlphaRemapGradient(): IParticleSystem;
  111448. /**
  111449. * Not supported by GPUParticleSystem
  111450. * @param gradient defines the gradient to use (between 0 and 1)
  111451. * @param color defines the color to affect to the specified gradient
  111452. * @returns the current particle system
  111453. */
  111454. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111455. /**
  111456. * Not supported by GPUParticleSystem
  111457. * @param gradient defines the gradient to remove
  111458. * @returns the current particle system
  111459. */
  111460. removeRampGradient(): IParticleSystem;
  111461. /**
  111462. * Not supported by GPUParticleSystem
  111463. * @returns the list of ramp gradients
  111464. */
  111465. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111466. /**
  111467. * Not supported by GPUParticleSystem
  111468. * Gets or sets a boolean indicating that ramp gradients must be used
  111469. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111470. */
  111471. useRampGradients: boolean;
  111472. /**
  111473. * Not supported by GPUParticleSystem
  111474. * @param gradient defines the gradient to use (between 0 and 1)
  111475. * @param factor defines the life time factor to affect to the specified gradient
  111476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111477. * @returns the current particle system
  111478. */
  111479. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111480. /**
  111481. * Not supported by GPUParticleSystem
  111482. * @param gradient defines the gradient to remove
  111483. * @returns the current particle system
  111484. */
  111485. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111486. /**
  111487. * Instantiates a GPU particle system.
  111488. * 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.
  111489. * @param name The name of the particle system
  111490. * @param options The options used to create the system
  111491. * @param scene The scene the particle system belongs to
  111492. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111493. */
  111494. constructor(name: string, options: Partial<{
  111495. capacity: number;
  111496. randomTextureSize: number;
  111497. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111498. protected _reset(): void;
  111499. private _createUpdateVAO;
  111500. private _createRenderVAO;
  111501. private _initialize;
  111502. /** @hidden */
  111503. _recreateUpdateEffect(): void;
  111504. /** @hidden */
  111505. _recreateRenderEffect(): void;
  111506. /**
  111507. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111508. * @param preWarm defines if we are in the pre-warmimg phase
  111509. */
  111510. animate(preWarm?: boolean): void;
  111511. private _createFactorGradientTexture;
  111512. private _createSizeGradientTexture;
  111513. private _createAngularSpeedGradientTexture;
  111514. private _createVelocityGradientTexture;
  111515. private _createLimitVelocityGradientTexture;
  111516. private _createDragGradientTexture;
  111517. private _createColorGradientTexture;
  111518. /**
  111519. * Renders the particle system in its current state
  111520. * @param preWarm defines if the system should only update the particles but not render them
  111521. * @returns the current number of particles
  111522. */
  111523. render(preWarm?: boolean): number;
  111524. /**
  111525. * Rebuilds the particle system
  111526. */
  111527. rebuild(): void;
  111528. private _releaseBuffers;
  111529. private _releaseVAOs;
  111530. /**
  111531. * Disposes the particle system and free the associated resources
  111532. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111533. */
  111534. dispose(disposeTexture?: boolean): void;
  111535. /**
  111536. * Clones the particle system.
  111537. * @param name The name of the cloned object
  111538. * @param newEmitter The new emitter to use
  111539. * @returns the cloned particle system
  111540. */
  111541. clone(name: string, newEmitter: any): GPUParticleSystem;
  111542. /**
  111543. * Serializes the particle system to a JSON object.
  111544. * @returns the JSON object
  111545. */
  111546. serialize(): any;
  111547. /**
  111548. * Parses a JSON object to create a GPU particle system.
  111549. * @param parsedParticleSystem The JSON object to parse
  111550. * @param scene The scene to create the particle system in
  111551. * @param rootUrl The root url to use to load external dependencies like texture
  111552. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111553. * @returns the parsed GPU particle system
  111554. */
  111555. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111556. }
  111557. }
  111558. declare module BABYLON {
  111559. /**
  111560. * Represents a set of particle systems working together to create a specific effect
  111561. */
  111562. export class ParticleSystemSet implements IDisposable {
  111563. private _emitterCreationOptions;
  111564. private _emitterNode;
  111565. /**
  111566. * Gets the particle system list
  111567. */
  111568. systems: IParticleSystem[];
  111569. /**
  111570. * Gets the emitter node used with this set
  111571. */
  111572. readonly emitterNode: Nullable<TransformNode>;
  111573. /**
  111574. * Creates a new emitter mesh as a sphere
  111575. * @param options defines the options used to create the sphere
  111576. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111577. * @param scene defines the hosting scene
  111578. */
  111579. setEmitterAsSphere(options: {
  111580. diameter: number;
  111581. segments: number;
  111582. color: Color3;
  111583. }, renderingGroupId: number, scene: Scene): void;
  111584. /**
  111585. * Starts all particle systems of the set
  111586. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111587. */
  111588. start(emitter?: AbstractMesh): void;
  111589. /**
  111590. * Release all associated resources
  111591. */
  111592. dispose(): void;
  111593. /**
  111594. * Serialize the set into a JSON compatible object
  111595. * @returns a JSON compatible representation of the set
  111596. */
  111597. serialize(): any;
  111598. /**
  111599. * Parse a new ParticleSystemSet from a serialized source
  111600. * @param data defines a JSON compatible representation of the set
  111601. * @param scene defines the hosting scene
  111602. * @param gpu defines if we want GPU particles or CPU particles
  111603. * @returns a new ParticleSystemSet
  111604. */
  111605. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111606. }
  111607. }
  111608. declare module BABYLON {
  111609. /**
  111610. * This class is made for on one-liner static method to help creating particle system set.
  111611. */
  111612. export class ParticleHelper {
  111613. /**
  111614. * Gets or sets base Assets URL
  111615. */
  111616. static BaseAssetsUrl: string;
  111617. /**
  111618. * Create a default particle system that you can tweak
  111619. * @param emitter defines the emitter to use
  111620. * @param capacity defines the system capacity (default is 500 particles)
  111621. * @param scene defines the hosting scene
  111622. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111623. * @returns the new Particle system
  111624. */
  111625. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111626. /**
  111627. * This is the main static method (one-liner) of this helper to create different particle systems
  111628. * @param type This string represents the type to the particle system to create
  111629. * @param scene The scene where the particle system should live
  111630. * @param gpu If the system will use gpu
  111631. * @returns the ParticleSystemSet created
  111632. */
  111633. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111634. /**
  111635. * Static function used to export a particle system to a ParticleSystemSet variable.
  111636. * Please note that the emitter shape is not exported
  111637. * @param systems defines the particle systems to export
  111638. * @returns the created particle system set
  111639. */
  111640. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111641. }
  111642. }
  111643. declare module BABYLON {
  111644. interface Engine {
  111645. /**
  111646. * Create an effect to use with particle systems.
  111647. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111648. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111649. * @param uniformsNames defines a list of attribute names
  111650. * @param samplers defines an array of string used to represent textures
  111651. * @param defines defines the string containing the defines to use to compile the shaders
  111652. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111653. * @param onCompiled defines a function to call when the effect creation is successful
  111654. * @param onError defines a function to call when the effect creation has failed
  111655. * @returns the new Effect
  111656. */
  111657. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111658. }
  111659. interface Mesh {
  111660. /**
  111661. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111662. * @returns an array of IParticleSystem
  111663. */
  111664. getEmittedParticleSystems(): IParticleSystem[];
  111665. /**
  111666. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111667. * @returns an array of IParticleSystem
  111668. */
  111669. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111670. }
  111671. /**
  111672. * @hidden
  111673. */
  111674. export var _IDoNeedToBeInTheBuild: number;
  111675. }
  111676. declare module BABYLON {
  111677. interface Scene {
  111678. /** @hidden (Backing field) */
  111679. _physicsEngine: Nullable<IPhysicsEngine>;
  111680. /**
  111681. * Gets the current physics engine
  111682. * @returns a IPhysicsEngine or null if none attached
  111683. */
  111684. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111685. /**
  111686. * Enables physics to the current scene
  111687. * @param gravity defines the scene's gravity for the physics engine
  111688. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111689. * @return a boolean indicating if the physics engine was initialized
  111690. */
  111691. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111692. /**
  111693. * Disables and disposes the physics engine associated with the scene
  111694. */
  111695. disablePhysicsEngine(): void;
  111696. /**
  111697. * Gets a boolean indicating if there is an active physics engine
  111698. * @returns a boolean indicating if there is an active physics engine
  111699. */
  111700. isPhysicsEnabled(): boolean;
  111701. /**
  111702. * Deletes a physics compound impostor
  111703. * @param compound defines the compound to delete
  111704. */
  111705. deleteCompoundImpostor(compound: any): void;
  111706. /**
  111707. * An event triggered when physic simulation is about to be run
  111708. */
  111709. onBeforePhysicsObservable: Observable<Scene>;
  111710. /**
  111711. * An event triggered when physic simulation has been done
  111712. */
  111713. onAfterPhysicsObservable: Observable<Scene>;
  111714. }
  111715. interface AbstractMesh {
  111716. /** @hidden */
  111717. _physicsImpostor: Nullable<PhysicsImpostor>;
  111718. /**
  111719. * Gets or sets impostor used for physic simulation
  111720. * @see http://doc.babylonjs.com/features/physics_engine
  111721. */
  111722. physicsImpostor: Nullable<PhysicsImpostor>;
  111723. /**
  111724. * Gets the current physics impostor
  111725. * @see http://doc.babylonjs.com/features/physics_engine
  111726. * @returns a physics impostor or null
  111727. */
  111728. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111729. /** Apply a physic impulse to the mesh
  111730. * @param force defines the force to apply
  111731. * @param contactPoint defines where to apply the force
  111732. * @returns the current mesh
  111733. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111734. */
  111735. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111736. /**
  111737. * Creates a physic joint between two meshes
  111738. * @param otherMesh defines the other mesh to use
  111739. * @param pivot1 defines the pivot to use on this mesh
  111740. * @param pivot2 defines the pivot to use on the other mesh
  111741. * @param options defines additional options (can be plugin dependent)
  111742. * @returns the current mesh
  111743. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111744. */
  111745. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111746. /** @hidden */
  111747. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111748. }
  111749. /**
  111750. * Defines the physics engine scene component responsible to manage a physics engine
  111751. */
  111752. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111753. /**
  111754. * The component name helpful to identify the component in the list of scene components.
  111755. */
  111756. readonly name: string;
  111757. /**
  111758. * The scene the component belongs to.
  111759. */
  111760. scene: Scene;
  111761. /**
  111762. * Creates a new instance of the component for the given scene
  111763. * @param scene Defines the scene to register the component in
  111764. */
  111765. constructor(scene: Scene);
  111766. /**
  111767. * Registers the component in a given scene
  111768. */
  111769. register(): void;
  111770. /**
  111771. * Rebuilds the elements related to this component in case of
  111772. * context lost for instance.
  111773. */
  111774. rebuild(): void;
  111775. /**
  111776. * Disposes the component and the associated ressources
  111777. */
  111778. dispose(): void;
  111779. }
  111780. }
  111781. declare module BABYLON {
  111782. /**
  111783. * A helper for physics simulations
  111784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111785. */
  111786. export class PhysicsHelper {
  111787. private _scene;
  111788. private _physicsEngine;
  111789. /**
  111790. * Initializes the Physics helper
  111791. * @param scene Babylon.js scene
  111792. */
  111793. constructor(scene: Scene);
  111794. /**
  111795. * Applies a radial explosion impulse
  111796. * @param origin the origin of the explosion
  111797. * @param radiusOrEventOptions the radius or the options of radial explosion
  111798. * @param strength the explosion strength
  111799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111800. * @returns A physics radial explosion event, or null
  111801. */
  111802. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111803. /**
  111804. * Applies a radial explosion force
  111805. * @param origin the origin of the explosion
  111806. * @param radiusOrEventOptions the radius or the options of radial explosion
  111807. * @param strength the explosion strength
  111808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111809. * @returns A physics radial explosion event, or null
  111810. */
  111811. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111812. /**
  111813. * Creates a gravitational field
  111814. * @param origin the origin of the explosion
  111815. * @param radiusOrEventOptions the radius or the options of radial explosion
  111816. * @param strength the explosion strength
  111817. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111818. * @returns A physics gravitational field event, or null
  111819. */
  111820. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111821. /**
  111822. * Creates a physics updraft event
  111823. * @param origin the origin of the updraft
  111824. * @param radiusOrEventOptions the radius or the options of the updraft
  111825. * @param strength the strength of the updraft
  111826. * @param height the height of the updraft
  111827. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111828. * @returns A physics updraft event, or null
  111829. */
  111830. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111831. /**
  111832. * Creates a physics vortex event
  111833. * @param origin the of the vortex
  111834. * @param radiusOrEventOptions the radius or the options of the vortex
  111835. * @param strength the strength of the vortex
  111836. * @param height the height of the vortex
  111837. * @returns a Physics vortex event, or null
  111838. * A physics vortex event or null
  111839. */
  111840. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111841. }
  111842. /**
  111843. * Represents a physics radial explosion event
  111844. */
  111845. class PhysicsRadialExplosionEvent {
  111846. private _scene;
  111847. private _options;
  111848. private _sphere;
  111849. private _dataFetched;
  111850. /**
  111851. * Initializes a radial explosioin event
  111852. * @param _scene BabylonJS scene
  111853. * @param _options The options for the vortex event
  111854. */
  111855. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111856. /**
  111857. * Returns the data related to the radial explosion event (sphere).
  111858. * @returns The radial explosion event data
  111859. */
  111860. getData(): PhysicsRadialExplosionEventData;
  111861. /**
  111862. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111863. * @param impostor A physics imposter
  111864. * @param origin the origin of the explosion
  111865. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111866. */
  111867. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111868. /**
  111869. * Triggers affecterd impostors callbacks
  111870. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111871. */
  111872. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111873. /**
  111874. * Disposes the sphere.
  111875. * @param force Specifies if the sphere should be disposed by force
  111876. */
  111877. dispose(force?: boolean): void;
  111878. /*** Helpers ***/
  111879. private _prepareSphere;
  111880. private _intersectsWithSphere;
  111881. }
  111882. /**
  111883. * Represents a gravitational field event
  111884. */
  111885. class PhysicsGravitationalFieldEvent {
  111886. private _physicsHelper;
  111887. private _scene;
  111888. private _origin;
  111889. private _options;
  111890. private _tickCallback;
  111891. private _sphere;
  111892. private _dataFetched;
  111893. /**
  111894. * Initializes the physics gravitational field event
  111895. * @param _physicsHelper A physics helper
  111896. * @param _scene BabylonJS scene
  111897. * @param _origin The origin position of the gravitational field event
  111898. * @param _options The options for the vortex event
  111899. */
  111900. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111901. /**
  111902. * Returns the data related to the gravitational field event (sphere).
  111903. * @returns A gravitational field event
  111904. */
  111905. getData(): PhysicsGravitationalFieldEventData;
  111906. /**
  111907. * Enables the gravitational field.
  111908. */
  111909. enable(): void;
  111910. /**
  111911. * Disables the gravitational field.
  111912. */
  111913. disable(): void;
  111914. /**
  111915. * Disposes the sphere.
  111916. * @param force The force to dispose from the gravitational field event
  111917. */
  111918. dispose(force?: boolean): void;
  111919. private _tick;
  111920. }
  111921. /**
  111922. * Represents a physics updraft event
  111923. */
  111924. class PhysicsUpdraftEvent {
  111925. private _scene;
  111926. private _origin;
  111927. private _options;
  111928. private _physicsEngine;
  111929. private _originTop;
  111930. private _originDirection;
  111931. private _tickCallback;
  111932. private _cylinder;
  111933. private _cylinderPosition;
  111934. private _dataFetched;
  111935. /**
  111936. * Initializes the physics updraft event
  111937. * @param _scene BabylonJS scene
  111938. * @param _origin The origin position of the updraft
  111939. * @param _options The options for the updraft event
  111940. */
  111941. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111942. /**
  111943. * Returns the data related to the updraft event (cylinder).
  111944. * @returns A physics updraft event
  111945. */
  111946. getData(): PhysicsUpdraftEventData;
  111947. /**
  111948. * Enables the updraft.
  111949. */
  111950. enable(): void;
  111951. /**
  111952. * Disables the updraft.
  111953. */
  111954. disable(): void;
  111955. /**
  111956. * Disposes the cylinder.
  111957. * @param force Specifies if the updraft should be disposed by force
  111958. */
  111959. dispose(force?: boolean): void;
  111960. private getImpostorHitData;
  111961. private _tick;
  111962. /*** Helpers ***/
  111963. private _prepareCylinder;
  111964. private _intersectsWithCylinder;
  111965. }
  111966. /**
  111967. * Represents a physics vortex event
  111968. */
  111969. class PhysicsVortexEvent {
  111970. private _scene;
  111971. private _origin;
  111972. private _options;
  111973. private _physicsEngine;
  111974. private _originTop;
  111975. private _tickCallback;
  111976. private _cylinder;
  111977. private _cylinderPosition;
  111978. private _dataFetched;
  111979. /**
  111980. * Initializes the physics vortex event
  111981. * @param _scene The BabylonJS scene
  111982. * @param _origin The origin position of the vortex
  111983. * @param _options The options for the vortex event
  111984. */
  111985. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111986. /**
  111987. * Returns the data related to the vortex event (cylinder).
  111988. * @returns The physics vortex event data
  111989. */
  111990. getData(): PhysicsVortexEventData;
  111991. /**
  111992. * Enables the vortex.
  111993. */
  111994. enable(): void;
  111995. /**
  111996. * Disables the cortex.
  111997. */
  111998. disable(): void;
  111999. /**
  112000. * Disposes the sphere.
  112001. * @param force
  112002. */
  112003. dispose(force?: boolean): void;
  112004. private getImpostorHitData;
  112005. private _tick;
  112006. /*** Helpers ***/
  112007. private _prepareCylinder;
  112008. private _intersectsWithCylinder;
  112009. }
  112010. /**
  112011. * Options fot the radial explosion event
  112012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112013. */
  112014. export class PhysicsRadialExplosionEventOptions {
  112015. /**
  112016. * The radius of the sphere for the radial explosion.
  112017. */
  112018. radius: number;
  112019. /**
  112020. * The strenth of the explosion.
  112021. */
  112022. strength: number;
  112023. /**
  112024. * The strenght of the force in correspondence to the distance of the affected object
  112025. */
  112026. falloff: PhysicsRadialImpulseFalloff;
  112027. /**
  112028. * Sphere options for the radial explosion.
  112029. */
  112030. sphere: {
  112031. segments: number;
  112032. diameter: number;
  112033. };
  112034. /**
  112035. * Sphere options for the radial explosion.
  112036. */
  112037. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112038. }
  112039. /**
  112040. * Options fot the updraft event
  112041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112042. */
  112043. export class PhysicsUpdraftEventOptions {
  112044. /**
  112045. * The radius of the cylinder for the vortex
  112046. */
  112047. radius: number;
  112048. /**
  112049. * The strenth of the updraft.
  112050. */
  112051. strength: number;
  112052. /**
  112053. * The height of the cylinder for the updraft.
  112054. */
  112055. height: number;
  112056. /**
  112057. * The mode for the the updraft.
  112058. */
  112059. updraftMode: PhysicsUpdraftMode;
  112060. }
  112061. /**
  112062. * Options fot the vortex event
  112063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112064. */
  112065. export class PhysicsVortexEventOptions {
  112066. /**
  112067. * The radius of the cylinder for the vortex
  112068. */
  112069. radius: number;
  112070. /**
  112071. * The strenth of the vortex.
  112072. */
  112073. strength: number;
  112074. /**
  112075. * The height of the cylinder for the vortex.
  112076. */
  112077. height: number;
  112078. /**
  112079. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112080. */
  112081. centripetalForceThreshold: number;
  112082. /**
  112083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112084. */
  112085. centripetalForceMultiplier: number;
  112086. /**
  112087. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112088. */
  112089. centrifugalForceMultiplier: number;
  112090. /**
  112091. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112092. */
  112093. updraftForceMultiplier: number;
  112094. }
  112095. /**
  112096. * The strenght of the force in correspondence to the distance of the affected object
  112097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112098. */
  112099. export enum PhysicsRadialImpulseFalloff {
  112100. /** Defines that impulse is constant in strength across it's whole radius */
  112101. Constant = 0,
  112102. /** Defines that impulse gets weaker if it's further from the origin */
  112103. Linear = 1
  112104. }
  112105. /**
  112106. * The strength of the force in correspondence to the distance of the affected object
  112107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112108. */
  112109. export enum PhysicsUpdraftMode {
  112110. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112111. Center = 0,
  112112. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112113. Perpendicular = 1
  112114. }
  112115. /**
  112116. * Interface for a physics hit data
  112117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112118. */
  112119. export interface PhysicsHitData {
  112120. /**
  112121. * The force applied at the contact point
  112122. */
  112123. force: Vector3;
  112124. /**
  112125. * The contact point
  112126. */
  112127. contactPoint: Vector3;
  112128. /**
  112129. * The distance from the origin to the contact point
  112130. */
  112131. distanceFromOrigin: number;
  112132. }
  112133. /**
  112134. * Interface for radial explosion event data
  112135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112136. */
  112137. export interface PhysicsRadialExplosionEventData {
  112138. /**
  112139. * A sphere used for the radial explosion event
  112140. */
  112141. sphere: Mesh;
  112142. }
  112143. /**
  112144. * Interface for gravitational field event data
  112145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112146. */
  112147. export interface PhysicsGravitationalFieldEventData {
  112148. /**
  112149. * A sphere mesh used for the gravitational field event
  112150. */
  112151. sphere: Mesh;
  112152. }
  112153. /**
  112154. * Interface for updraft event data
  112155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112156. */
  112157. export interface PhysicsUpdraftEventData {
  112158. /**
  112159. * A cylinder used for the updraft event
  112160. */
  112161. cylinder: Mesh;
  112162. }
  112163. /**
  112164. * Interface for vortex event data
  112165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112166. */
  112167. export interface PhysicsVortexEventData {
  112168. /**
  112169. * A cylinder used for the vortex event
  112170. */
  112171. cylinder: Mesh;
  112172. }
  112173. /**
  112174. * Interface for an affected physics impostor
  112175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112176. */
  112177. export interface PhysicsAffectedImpostorWithData {
  112178. /**
  112179. * The impostor affected by the effect
  112180. */
  112181. impostor: PhysicsImpostor;
  112182. /**
  112183. * The data about the hit/horce from the explosion
  112184. */
  112185. hitData: PhysicsHitData;
  112186. }
  112187. }
  112188. declare module BABYLON {
  112189. /** @hidden */
  112190. export var blackAndWhitePixelShader: {
  112191. name: string;
  112192. shader: string;
  112193. };
  112194. }
  112195. declare module BABYLON {
  112196. /**
  112197. * Post process used to render in black and white
  112198. */
  112199. export class BlackAndWhitePostProcess extends PostProcess {
  112200. /**
  112201. * Linear about to convert he result to black and white (default: 1)
  112202. */
  112203. degree: number;
  112204. /**
  112205. * Creates a black and white post process
  112206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112207. * @param name The name of the effect.
  112208. * @param options The required width/height ratio to downsize to before computing the render pass.
  112209. * @param camera The camera to apply the render pass to.
  112210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112211. * @param engine The engine which the post process will be applied. (default: current engine)
  112212. * @param reusable If the post process can be reused on the same frame. (default: false)
  112213. */
  112214. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112215. }
  112216. }
  112217. declare module BABYLON {
  112218. /**
  112219. * This represents a set of one or more post processes in Babylon.
  112220. * A post process can be used to apply a shader to a texture after it is rendered.
  112221. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112222. */
  112223. export class PostProcessRenderEffect {
  112224. private _postProcesses;
  112225. private _getPostProcesses;
  112226. private _singleInstance;
  112227. private _cameras;
  112228. private _indicesForCamera;
  112229. /**
  112230. * Name of the effect
  112231. * @hidden
  112232. */
  112233. _name: string;
  112234. /**
  112235. * Instantiates a post process render effect.
  112236. * A post process can be used to apply a shader to a texture after it is rendered.
  112237. * @param engine The engine the effect is tied to
  112238. * @param name The name of the effect
  112239. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112240. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112241. */
  112242. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112243. /**
  112244. * Checks if all the post processes in the effect are supported.
  112245. */
  112246. readonly isSupported: boolean;
  112247. /**
  112248. * Updates the current state of the effect
  112249. * @hidden
  112250. */
  112251. _update(): void;
  112252. /**
  112253. * Attaches the effect on cameras
  112254. * @param cameras The camera to attach to.
  112255. * @hidden
  112256. */
  112257. _attachCameras(cameras: Camera): void;
  112258. /**
  112259. * Attaches the effect on cameras
  112260. * @param cameras The camera to attach to.
  112261. * @hidden
  112262. */
  112263. _attachCameras(cameras: Camera[]): void;
  112264. /**
  112265. * Detaches the effect on cameras
  112266. * @param cameras The camera to detatch from.
  112267. * @hidden
  112268. */
  112269. _detachCameras(cameras: Camera): void;
  112270. /**
  112271. * Detatches the effect on cameras
  112272. * @param cameras The camera to detatch from.
  112273. * @hidden
  112274. */
  112275. _detachCameras(cameras: Camera[]): void;
  112276. /**
  112277. * Enables the effect on given cameras
  112278. * @param cameras The camera to enable.
  112279. * @hidden
  112280. */
  112281. _enable(cameras: Camera): void;
  112282. /**
  112283. * Enables the effect on given cameras
  112284. * @param cameras The camera to enable.
  112285. * @hidden
  112286. */
  112287. _enable(cameras: Nullable<Camera[]>): void;
  112288. /**
  112289. * Disables the effect on the given cameras
  112290. * @param cameras The camera to disable.
  112291. * @hidden
  112292. */
  112293. _disable(cameras: Camera): void;
  112294. /**
  112295. * Disables the effect on the given cameras
  112296. * @param cameras The camera to disable.
  112297. * @hidden
  112298. */
  112299. _disable(cameras: Nullable<Camera[]>): void;
  112300. /**
  112301. * Gets a list of the post processes contained in the effect.
  112302. * @param camera The camera to get the post processes on.
  112303. * @returns The list of the post processes in the effect.
  112304. */
  112305. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112306. }
  112307. }
  112308. declare module BABYLON {
  112309. /** @hidden */
  112310. export var extractHighlightsPixelShader: {
  112311. name: string;
  112312. shader: string;
  112313. };
  112314. }
  112315. declare module BABYLON {
  112316. /**
  112317. * 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.
  112318. */
  112319. export class ExtractHighlightsPostProcess extends PostProcess {
  112320. /**
  112321. * The luminance threshold, pixels below this value will be set to black.
  112322. */
  112323. threshold: number;
  112324. /** @hidden */
  112325. _exposure: number;
  112326. /**
  112327. * Post process which has the input texture to be used when performing highlight extraction
  112328. * @hidden
  112329. */
  112330. _inputPostProcess: Nullable<PostProcess>;
  112331. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112332. }
  112333. }
  112334. declare module BABYLON {
  112335. /** @hidden */
  112336. export var bloomMergePixelShader: {
  112337. name: string;
  112338. shader: string;
  112339. };
  112340. }
  112341. declare module BABYLON {
  112342. /**
  112343. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112344. */
  112345. export class BloomMergePostProcess extends PostProcess {
  112346. /** Weight of the bloom to be added to the original input. */
  112347. weight: number;
  112348. /**
  112349. * Creates a new instance of @see BloomMergePostProcess
  112350. * @param name The name of the effect.
  112351. * @param originalFromInput Post process which's input will be used for the merge.
  112352. * @param blurred Blurred highlights post process which's output will be used.
  112353. * @param weight Weight of the bloom to be added to the original input.
  112354. * @param options The required width/height ratio to downsize to before computing the render pass.
  112355. * @param camera The camera to apply the render pass to.
  112356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112357. * @param engine The engine which the post process will be applied. (default: current engine)
  112358. * @param reusable If the post process can be reused on the same frame. (default: false)
  112359. * @param textureType Type of textures used when performing the post process. (default: 0)
  112360. * @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)
  112361. */
  112362. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112363. /** Weight of the bloom to be added to the original input. */
  112364. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112365. }
  112366. }
  112367. declare module BABYLON {
  112368. /**
  112369. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112370. */
  112371. export class BloomEffect extends PostProcessRenderEffect {
  112372. private bloomScale;
  112373. /**
  112374. * @hidden Internal
  112375. */
  112376. _effects: Array<PostProcess>;
  112377. /**
  112378. * @hidden Internal
  112379. */
  112380. _downscale: ExtractHighlightsPostProcess;
  112381. private _blurX;
  112382. private _blurY;
  112383. private _merge;
  112384. /**
  112385. * The luminance threshold to find bright areas of the image to bloom.
  112386. */
  112387. threshold: number;
  112388. /**
  112389. * The strength of the bloom.
  112390. */
  112391. weight: number;
  112392. /**
  112393. * Specifies the size of the bloom blur kernel, relative to the final output size
  112394. */
  112395. kernel: number;
  112396. /**
  112397. * Creates a new instance of @see BloomEffect
  112398. * @param scene The scene the effect belongs to.
  112399. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112400. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112401. * @param bloomWeight The the strength of bloom.
  112402. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112403. * @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)
  112404. */
  112405. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112406. /**
  112407. * Disposes each of the internal effects for a given camera.
  112408. * @param camera The camera to dispose the effect on.
  112409. */
  112410. disposeEffects(camera: Camera): void;
  112411. /**
  112412. * @hidden Internal
  112413. */
  112414. _updateEffects(): void;
  112415. /**
  112416. * Internal
  112417. * @returns if all the contained post processes are ready.
  112418. * @hidden
  112419. */
  112420. _isReady(): boolean;
  112421. }
  112422. }
  112423. declare module BABYLON {
  112424. /** @hidden */
  112425. export var chromaticAberrationPixelShader: {
  112426. name: string;
  112427. shader: string;
  112428. };
  112429. }
  112430. declare module BABYLON {
  112431. /**
  112432. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112433. */
  112434. export class ChromaticAberrationPostProcess extends PostProcess {
  112435. /**
  112436. * The amount of seperation of rgb channels (default: 30)
  112437. */
  112438. aberrationAmount: number;
  112439. /**
  112440. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112441. */
  112442. radialIntensity: number;
  112443. /**
  112444. * 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))
  112445. */
  112446. direction: Vector2;
  112447. /**
  112448. * 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))
  112449. */
  112450. centerPosition: Vector2;
  112451. /**
  112452. * Creates a new instance ChromaticAberrationPostProcess
  112453. * @param name The name of the effect.
  112454. * @param screenWidth The width of the screen to apply the effect on.
  112455. * @param screenHeight The height of the screen to apply the effect on.
  112456. * @param options The required width/height ratio to downsize to before computing the render pass.
  112457. * @param camera The camera to apply the render pass to.
  112458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112459. * @param engine The engine which the post process will be applied. (default: current engine)
  112460. * @param reusable If the post process can be reused on the same frame. (default: false)
  112461. * @param textureType Type of textures used when performing the post process. (default: 0)
  112462. * @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)
  112463. */
  112464. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112465. }
  112466. }
  112467. declare module BABYLON {
  112468. /** @hidden */
  112469. export var circleOfConfusionPixelShader: {
  112470. name: string;
  112471. shader: string;
  112472. };
  112473. }
  112474. declare module BABYLON {
  112475. /**
  112476. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112477. */
  112478. export class CircleOfConfusionPostProcess extends PostProcess {
  112479. /**
  112480. * 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.
  112481. */
  112482. lensSize: number;
  112483. /**
  112484. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112485. */
  112486. fStop: number;
  112487. /**
  112488. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112489. */
  112490. focusDistance: number;
  112491. /**
  112492. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112493. */
  112494. focalLength: number;
  112495. private _depthTexture;
  112496. /**
  112497. * Creates a new instance CircleOfConfusionPostProcess
  112498. * @param name The name of the effect.
  112499. * @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.
  112500. * @param options The required width/height ratio to downsize to before computing the render pass.
  112501. * @param camera The camera to apply the render pass to.
  112502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112503. * @param engine The engine which the post process will be applied. (default: current engine)
  112504. * @param reusable If the post process can be reused on the same frame. (default: false)
  112505. * @param textureType Type of textures used when performing the post process. (default: 0)
  112506. * @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)
  112507. */
  112508. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112509. /**
  112510. * 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.
  112511. */
  112512. depthTexture: RenderTargetTexture;
  112513. }
  112514. }
  112515. declare module BABYLON {
  112516. /** @hidden */
  112517. export var colorCorrectionPixelShader: {
  112518. name: string;
  112519. shader: string;
  112520. };
  112521. }
  112522. declare module BABYLON {
  112523. /**
  112524. *
  112525. * This post-process allows the modification of rendered colors by using
  112526. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112527. *
  112528. * The object needs to be provided an url to a texture containing the color
  112529. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112530. * Use an image editing software to tweak the LUT to match your needs.
  112531. *
  112532. * For an example of a color LUT, see here:
  112533. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112534. * For explanations on color grading, see here:
  112535. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112536. *
  112537. */
  112538. export class ColorCorrectionPostProcess extends PostProcess {
  112539. private _colorTableTexture;
  112540. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112541. }
  112542. }
  112543. declare module BABYLON {
  112544. /** @hidden */
  112545. export var convolutionPixelShader: {
  112546. name: string;
  112547. shader: string;
  112548. };
  112549. }
  112550. declare module BABYLON {
  112551. /**
  112552. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112553. * input texture to perform effects such as edge detection or sharpening
  112554. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112555. */
  112556. export class ConvolutionPostProcess extends PostProcess {
  112557. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112558. kernel: number[];
  112559. /**
  112560. * Creates a new instance ConvolutionPostProcess
  112561. * @param name The name of the effect.
  112562. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112563. * @param options The required width/height ratio to downsize to before computing the render pass.
  112564. * @param camera The camera to apply the render pass to.
  112565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112566. * @param engine The engine which the post process will be applied. (default: current engine)
  112567. * @param reusable If the post process can be reused on the same frame. (default: false)
  112568. * @param textureType Type of textures used when performing the post process. (default: 0)
  112569. */
  112570. constructor(name: string,
  112571. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112572. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112573. /**
  112574. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112575. */
  112576. static EdgeDetect0Kernel: number[];
  112577. /**
  112578. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112579. */
  112580. static EdgeDetect1Kernel: number[];
  112581. /**
  112582. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112583. */
  112584. static EdgeDetect2Kernel: number[];
  112585. /**
  112586. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112587. */
  112588. static SharpenKernel: number[];
  112589. /**
  112590. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112591. */
  112592. static EmbossKernel: number[];
  112593. /**
  112594. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112595. */
  112596. static GaussianKernel: number[];
  112597. }
  112598. }
  112599. declare module BABYLON {
  112600. /**
  112601. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112602. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112603. * based on samples that have a large difference in distance than the center pixel.
  112604. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112605. */
  112606. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112607. direction: Vector2;
  112608. /**
  112609. * Creates a new instance CircleOfConfusionPostProcess
  112610. * @param name The name of the effect.
  112611. * @param scene The scene the effect belongs to.
  112612. * @param direction The direction the blur should be applied.
  112613. * @param kernel The size of the kernel used to blur.
  112614. * @param options The required width/height ratio to downsize to before computing the render pass.
  112615. * @param camera The camera to apply the render pass to.
  112616. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112617. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112619. * @param engine The engine which the post process will be applied. (default: current engine)
  112620. * @param reusable If the post process can be reused on the same frame. (default: false)
  112621. * @param textureType Type of textures used when performing the post process. (default: 0)
  112622. * @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)
  112623. */
  112624. 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);
  112625. }
  112626. }
  112627. declare module BABYLON {
  112628. /** @hidden */
  112629. export var depthOfFieldMergePixelShader: {
  112630. name: string;
  112631. shader: string;
  112632. };
  112633. }
  112634. declare module BABYLON {
  112635. /**
  112636. * Options to be set when merging outputs from the default pipeline.
  112637. */
  112638. export class DepthOfFieldMergePostProcessOptions {
  112639. /**
  112640. * The original image to merge on top of
  112641. */
  112642. originalFromInput: PostProcess;
  112643. /**
  112644. * Parameters to perform the merge of the depth of field effect
  112645. */
  112646. depthOfField?: {
  112647. circleOfConfusion: PostProcess;
  112648. blurSteps: Array<PostProcess>;
  112649. };
  112650. /**
  112651. * Parameters to perform the merge of bloom effect
  112652. */
  112653. bloom?: {
  112654. blurred: PostProcess;
  112655. weight: number;
  112656. };
  112657. }
  112658. /**
  112659. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112660. */
  112661. export class DepthOfFieldMergePostProcess extends PostProcess {
  112662. private blurSteps;
  112663. /**
  112664. * Creates a new instance of DepthOfFieldMergePostProcess
  112665. * @param name The name of the effect.
  112666. * @param originalFromInput Post process which's input will be used for the merge.
  112667. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112668. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112669. * @param options The required width/height ratio to downsize to before computing the render pass.
  112670. * @param camera The camera to apply the render pass to.
  112671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112672. * @param engine The engine which the post process will be applied. (default: current engine)
  112673. * @param reusable If the post process can be reused on the same frame. (default: false)
  112674. * @param textureType Type of textures used when performing the post process. (default: 0)
  112675. * @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)
  112676. */
  112677. 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);
  112678. /**
  112679. * Updates the effect with the current post process compile time values and recompiles the shader.
  112680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112683. * @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
  112684. * @param onCompiled Called when the shader has been compiled.
  112685. * @param onError Called if there is an error when compiling a shader.
  112686. */
  112687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112688. }
  112689. }
  112690. declare module BABYLON {
  112691. /**
  112692. * Specifies the level of max blur that should be applied when using the depth of field effect
  112693. */
  112694. export enum DepthOfFieldEffectBlurLevel {
  112695. /**
  112696. * Subtle blur
  112697. */
  112698. Low = 0,
  112699. /**
  112700. * Medium blur
  112701. */
  112702. Medium = 1,
  112703. /**
  112704. * Large blur
  112705. */
  112706. High = 2
  112707. }
  112708. /**
  112709. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112710. */
  112711. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112712. private _circleOfConfusion;
  112713. /**
  112714. * @hidden Internal, blurs from high to low
  112715. */
  112716. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112717. private _depthOfFieldBlurY;
  112718. private _dofMerge;
  112719. /**
  112720. * @hidden Internal post processes in depth of field effect
  112721. */
  112722. _effects: Array<PostProcess>;
  112723. /**
  112724. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112725. */
  112726. focalLength: number;
  112727. /**
  112728. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112729. */
  112730. fStop: number;
  112731. /**
  112732. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112733. */
  112734. focusDistance: number;
  112735. /**
  112736. * 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.
  112737. */
  112738. lensSize: number;
  112739. /**
  112740. * Creates a new instance DepthOfFieldEffect
  112741. * @param scene The scene the effect belongs to.
  112742. * @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.
  112743. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112744. * @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)
  112745. */
  112746. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112747. /**
  112748. * Get the current class name of the current effet
  112749. * @returns "DepthOfFieldEffect"
  112750. */
  112751. getClassName(): string;
  112752. /**
  112753. * 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.
  112754. */
  112755. depthTexture: RenderTargetTexture;
  112756. /**
  112757. * Disposes each of the internal effects for a given camera.
  112758. * @param camera The camera to dispose the effect on.
  112759. */
  112760. disposeEffects(camera: Camera): void;
  112761. /**
  112762. * @hidden Internal
  112763. */
  112764. _updateEffects(): void;
  112765. /**
  112766. * Internal
  112767. * @returns if all the contained post processes are ready.
  112768. * @hidden
  112769. */
  112770. _isReady(): boolean;
  112771. }
  112772. }
  112773. declare module BABYLON {
  112774. /** @hidden */
  112775. export var displayPassPixelShader: {
  112776. name: string;
  112777. shader: string;
  112778. };
  112779. }
  112780. declare module BABYLON {
  112781. /**
  112782. * DisplayPassPostProcess which produces an output the same as it's input
  112783. */
  112784. export class DisplayPassPostProcess extends PostProcess {
  112785. /**
  112786. * Creates the DisplayPassPostProcess
  112787. * @param name The name of the effect.
  112788. * @param options The required width/height ratio to downsize to before computing the render pass.
  112789. * @param camera The camera to apply the render pass to.
  112790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112791. * @param engine The engine which the post process will be applied. (default: current engine)
  112792. * @param reusable If the post process can be reused on the same frame. (default: false)
  112793. */
  112794. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112795. }
  112796. }
  112797. declare module BABYLON {
  112798. /** @hidden */
  112799. export var filterPixelShader: {
  112800. name: string;
  112801. shader: string;
  112802. };
  112803. }
  112804. declare module BABYLON {
  112805. /**
  112806. * Applies a kernel filter to the image
  112807. */
  112808. export class FilterPostProcess extends PostProcess {
  112809. /** The matrix to be applied to the image */
  112810. kernelMatrix: Matrix;
  112811. /**
  112812. *
  112813. * @param name The name of the effect.
  112814. * @param kernelMatrix The matrix to be applied to the image
  112815. * @param options The required width/height ratio to downsize to before computing the render pass.
  112816. * @param camera The camera to apply the render pass to.
  112817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112818. * @param engine The engine which the post process will be applied. (default: current engine)
  112819. * @param reusable If the post process can be reused on the same frame. (default: false)
  112820. */
  112821. constructor(name: string,
  112822. /** The matrix to be applied to the image */
  112823. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112824. }
  112825. }
  112826. declare module BABYLON {
  112827. /** @hidden */
  112828. export var fxaaPixelShader: {
  112829. name: string;
  112830. shader: string;
  112831. };
  112832. }
  112833. declare module BABYLON {
  112834. /** @hidden */
  112835. export var fxaaVertexShader: {
  112836. name: string;
  112837. shader: string;
  112838. };
  112839. }
  112840. declare module BABYLON {
  112841. /**
  112842. * Fxaa post process
  112843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112844. */
  112845. export class FxaaPostProcess extends PostProcess {
  112846. /** @hidden */
  112847. texelWidth: number;
  112848. /** @hidden */
  112849. texelHeight: number;
  112850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112851. private _getDefines;
  112852. }
  112853. }
  112854. declare module BABYLON {
  112855. /** @hidden */
  112856. export var grainPixelShader: {
  112857. name: string;
  112858. shader: string;
  112859. };
  112860. }
  112861. declare module BABYLON {
  112862. /**
  112863. * The GrainPostProcess adds noise to the image at mid luminance levels
  112864. */
  112865. export class GrainPostProcess extends PostProcess {
  112866. /**
  112867. * The intensity of the grain added (default: 30)
  112868. */
  112869. intensity: number;
  112870. /**
  112871. * If the grain should be randomized on every frame
  112872. */
  112873. animated: boolean;
  112874. /**
  112875. * Creates a new instance of @see GrainPostProcess
  112876. * @param name The name of the effect.
  112877. * @param options The required width/height ratio to downsize to before computing the render pass.
  112878. * @param camera The camera to apply the render pass to.
  112879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112880. * @param engine The engine which the post process will be applied. (default: current engine)
  112881. * @param reusable If the post process can be reused on the same frame. (default: false)
  112882. * @param textureType Type of textures used when performing the post process. (default: 0)
  112883. * @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)
  112884. */
  112885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112886. }
  112887. }
  112888. declare module BABYLON {
  112889. /** @hidden */
  112890. export var highlightsPixelShader: {
  112891. name: string;
  112892. shader: string;
  112893. };
  112894. }
  112895. declare module BABYLON {
  112896. /**
  112897. * Extracts highlights from the image
  112898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112899. */
  112900. export class HighlightsPostProcess extends PostProcess {
  112901. /**
  112902. * Extracts highlights from the image
  112903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112904. * @param name The name of the effect.
  112905. * @param options The required width/height ratio to downsize to before computing the render pass.
  112906. * @param camera The camera to apply the render pass to.
  112907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112908. * @param engine The engine which the post process will be applied. (default: current engine)
  112909. * @param reusable If the post process can be reused on the same frame. (default: false)
  112910. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112911. */
  112912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112913. }
  112914. }
  112915. declare module BABYLON {
  112916. /** @hidden */
  112917. export var mrtFragmentDeclaration: {
  112918. name: string;
  112919. shader: string;
  112920. };
  112921. }
  112922. declare module BABYLON {
  112923. /** @hidden */
  112924. export var geometryPixelShader: {
  112925. name: string;
  112926. shader: string;
  112927. };
  112928. }
  112929. declare module BABYLON {
  112930. /** @hidden */
  112931. export var geometryVertexShader: {
  112932. name: string;
  112933. shader: string;
  112934. };
  112935. }
  112936. declare module BABYLON {
  112937. /**
  112938. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112939. */
  112940. export class GeometryBufferRenderer {
  112941. /**
  112942. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112943. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112944. */
  112945. static readonly POSITION_TEXTURE_TYPE: number;
  112946. /**
  112947. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112948. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112949. */
  112950. static readonly VELOCITY_TEXTURE_TYPE: number;
  112951. /**
  112952. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112953. * in order to compute objects velocities when enableVelocity is set to "true"
  112954. * @hidden
  112955. */
  112956. _previousTransformationMatrices: {
  112957. [index: number]: Matrix;
  112958. };
  112959. private _scene;
  112960. private _multiRenderTarget;
  112961. private _ratio;
  112962. private _enablePosition;
  112963. private _enableVelocity;
  112964. private _positionIndex;
  112965. private _velocityIndex;
  112966. protected _effect: Effect;
  112967. protected _cachedDefines: string;
  112968. /**
  112969. * Set the render list (meshes to be rendered) used in the G buffer.
  112970. */
  112971. renderList: Mesh[];
  112972. /**
  112973. * Gets wether or not G buffer are supported by the running hardware.
  112974. * This requires draw buffer supports
  112975. */
  112976. readonly isSupported: boolean;
  112977. /**
  112978. * Returns the index of the given texture type in the G-Buffer textures array
  112979. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112980. * @returns the index of the given texture type in the G-Buffer textures array
  112981. */
  112982. getTextureIndex(textureType: number): number;
  112983. /**
  112984. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112985. */
  112986. /**
  112987. * Sets whether or not objects positions are enabled for the G buffer.
  112988. */
  112989. enablePosition: boolean;
  112990. /**
  112991. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112992. */
  112993. /**
  112994. * Sets wether or not objects velocities are enabled for the G buffer.
  112995. */
  112996. enableVelocity: boolean;
  112997. /**
  112998. * Gets the scene associated with the buffer.
  112999. */
  113000. readonly scene: Scene;
  113001. /**
  113002. * Gets the ratio used by the buffer during its creation.
  113003. * How big is the buffer related to the main canvas.
  113004. */
  113005. readonly ratio: number;
  113006. /** @hidden */
  113007. static _SceneComponentInitialization: (scene: Scene) => void;
  113008. /**
  113009. * Creates a new G Buffer for the scene
  113010. * @param scene The scene the buffer belongs to
  113011. * @param ratio How big is the buffer related to the main canvas.
  113012. */
  113013. constructor(scene: Scene, ratio?: number);
  113014. /**
  113015. * Checks wether everything is ready to render a submesh to the G buffer.
  113016. * @param subMesh the submesh to check readiness for
  113017. * @param useInstances is the mesh drawn using instance or not
  113018. * @returns true if ready otherwise false
  113019. */
  113020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113021. /**
  113022. * Gets the current underlying G Buffer.
  113023. * @returns the buffer
  113024. */
  113025. getGBuffer(): MultiRenderTarget;
  113026. /**
  113027. * Gets the number of samples used to render the buffer (anti aliasing).
  113028. */
  113029. /**
  113030. * Sets the number of samples used to render the buffer (anti aliasing).
  113031. */
  113032. samples: number;
  113033. /**
  113034. * Disposes the renderer and frees up associated resources.
  113035. */
  113036. dispose(): void;
  113037. protected _createRenderTargets(): void;
  113038. }
  113039. }
  113040. declare module BABYLON {
  113041. interface Scene {
  113042. /** @hidden (Backing field) */
  113043. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113044. /**
  113045. * Gets or Sets the current geometry buffer associated to the scene.
  113046. */
  113047. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113048. /**
  113049. * Enables a GeometryBufferRender and associates it with the scene
  113050. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113051. * @returns the GeometryBufferRenderer
  113052. */
  113053. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113054. /**
  113055. * Disables the GeometryBufferRender associated with the scene
  113056. */
  113057. disableGeometryBufferRenderer(): void;
  113058. }
  113059. /**
  113060. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113061. * in several rendering techniques.
  113062. */
  113063. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113064. /**
  113065. * The component name helpful to identify the component in the list of scene components.
  113066. */
  113067. readonly name: string;
  113068. /**
  113069. * The scene the component belongs to.
  113070. */
  113071. scene: Scene;
  113072. /**
  113073. * Creates a new instance of the component for the given scene
  113074. * @param scene Defines the scene to register the component in
  113075. */
  113076. constructor(scene: Scene);
  113077. /**
  113078. * Registers the component in a given scene
  113079. */
  113080. register(): void;
  113081. /**
  113082. * Rebuilds the elements related to this component in case of
  113083. * context lost for instance.
  113084. */
  113085. rebuild(): void;
  113086. /**
  113087. * Disposes the component and the associated ressources
  113088. */
  113089. dispose(): void;
  113090. private _gatherRenderTargets;
  113091. }
  113092. }
  113093. declare module BABYLON {
  113094. /** @hidden */
  113095. export var motionBlurPixelShader: {
  113096. name: string;
  113097. shader: string;
  113098. };
  113099. }
  113100. declare module BABYLON {
  113101. /**
  113102. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113103. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113104. * As an example, all you have to do is to create the post-process:
  113105. * var mb = new BABYLON.MotionBlurPostProcess(
  113106. * 'mb', // The name of the effect.
  113107. * scene, // The scene containing the objects to blur according to their velocity.
  113108. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113109. * camera // The camera to apply the render pass to.
  113110. * );
  113111. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113112. */
  113113. export class MotionBlurPostProcess extends PostProcess {
  113114. /**
  113115. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113116. */
  113117. motionStrength: number;
  113118. /**
  113119. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113120. */
  113121. /**
  113122. * Sets the number of iterations to be used for motion blur quality
  113123. */
  113124. motionBlurSamples: number;
  113125. private _motionBlurSamples;
  113126. private _geometryBufferRenderer;
  113127. /**
  113128. * Creates a new instance MotionBlurPostProcess
  113129. * @param name The name of the effect.
  113130. * @param scene The scene containing the objects to blur according to their velocity.
  113131. * @param options The required width/height ratio to downsize to before computing the render pass.
  113132. * @param camera The camera to apply the render pass to.
  113133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113134. * @param engine The engine which the post process will be applied. (default: current engine)
  113135. * @param reusable If the post process can be reused on the same frame. (default: false)
  113136. * @param textureType Type of textures used when performing the post process. (default: 0)
  113137. * @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)
  113138. */
  113139. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113140. /**
  113141. * Disposes the post process.
  113142. * @param camera The camera to dispose the post process on.
  113143. */
  113144. dispose(camera?: Camera): void;
  113145. }
  113146. }
  113147. declare module BABYLON {
  113148. /** @hidden */
  113149. export var refractionPixelShader: {
  113150. name: string;
  113151. shader: string;
  113152. };
  113153. }
  113154. declare module BABYLON {
  113155. /**
  113156. * Post process which applies a refractin texture
  113157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113158. */
  113159. export class RefractionPostProcess extends PostProcess {
  113160. /** the base color of the refraction (used to taint the rendering) */
  113161. color: Color3;
  113162. /** simulated refraction depth */
  113163. depth: number;
  113164. /** the coefficient of the base color (0 to remove base color tainting) */
  113165. colorLevel: number;
  113166. private _refTexture;
  113167. private _ownRefractionTexture;
  113168. /**
  113169. * Gets or sets the refraction texture
  113170. * Please note that you are responsible for disposing the texture if you set it manually
  113171. */
  113172. refractionTexture: Texture;
  113173. /**
  113174. * Initializes the RefractionPostProcess
  113175. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113176. * @param name The name of the effect.
  113177. * @param refractionTextureUrl Url of the refraction texture to use
  113178. * @param color the base color of the refraction (used to taint the rendering)
  113179. * @param depth simulated refraction depth
  113180. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113181. * @param camera The camera to apply the render pass to.
  113182. * @param options The required width/height ratio to downsize to before computing the render pass.
  113183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113184. * @param engine The engine which the post process will be applied. (default: current engine)
  113185. * @param reusable If the post process can be reused on the same frame. (default: false)
  113186. */
  113187. constructor(name: string, refractionTextureUrl: string,
  113188. /** the base color of the refraction (used to taint the rendering) */
  113189. color: Color3,
  113190. /** simulated refraction depth */
  113191. depth: number,
  113192. /** the coefficient of the base color (0 to remove base color tainting) */
  113193. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113194. /**
  113195. * Disposes of the post process
  113196. * @param camera Camera to dispose post process on
  113197. */
  113198. dispose(camera: Camera): void;
  113199. }
  113200. }
  113201. declare module BABYLON {
  113202. /** @hidden */
  113203. export var sharpenPixelShader: {
  113204. name: string;
  113205. shader: string;
  113206. };
  113207. }
  113208. declare module BABYLON {
  113209. /**
  113210. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113211. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113212. */
  113213. export class SharpenPostProcess extends PostProcess {
  113214. /**
  113215. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113216. */
  113217. colorAmount: number;
  113218. /**
  113219. * How much sharpness should be applied (default: 0.3)
  113220. */
  113221. edgeAmount: number;
  113222. /**
  113223. * Creates a new instance ConvolutionPostProcess
  113224. * @param name The name of the effect.
  113225. * @param options The required width/height ratio to downsize to before computing the render pass.
  113226. * @param camera The camera to apply the render pass to.
  113227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113228. * @param engine The engine which the post process will be applied. (default: current engine)
  113229. * @param reusable If the post process can be reused on the same frame. (default: false)
  113230. * @param textureType Type of textures used when performing the post process. (default: 0)
  113231. * @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)
  113232. */
  113233. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113234. }
  113235. }
  113236. declare module BABYLON {
  113237. /**
  113238. * PostProcessRenderPipeline
  113239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113240. */
  113241. export class PostProcessRenderPipeline {
  113242. private engine;
  113243. private _renderEffects;
  113244. private _renderEffectsForIsolatedPass;
  113245. /**
  113246. * List of inspectable custom properties (used by the Inspector)
  113247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113248. */
  113249. inspectableCustomProperties: IInspectable[];
  113250. /**
  113251. * @hidden
  113252. */
  113253. protected _cameras: Camera[];
  113254. /** @hidden */
  113255. _name: string;
  113256. /**
  113257. * Gets pipeline name
  113258. */
  113259. readonly name: string;
  113260. /**
  113261. * Initializes a PostProcessRenderPipeline
  113262. * @param engine engine to add the pipeline to
  113263. * @param name name of the pipeline
  113264. */
  113265. constructor(engine: Engine, name: string);
  113266. /**
  113267. * Gets the class name
  113268. * @returns "PostProcessRenderPipeline"
  113269. */
  113270. getClassName(): string;
  113271. /**
  113272. * If all the render effects in the pipeline are supported
  113273. */
  113274. readonly isSupported: boolean;
  113275. /**
  113276. * Adds an effect to the pipeline
  113277. * @param renderEffect the effect to add
  113278. */
  113279. addEffect(renderEffect: PostProcessRenderEffect): void;
  113280. /** @hidden */
  113281. _rebuild(): void;
  113282. /** @hidden */
  113283. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113284. /** @hidden */
  113285. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113286. /** @hidden */
  113287. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113288. /** @hidden */
  113289. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113290. /** @hidden */
  113291. _attachCameras(cameras: Camera, unique: boolean): void;
  113292. /** @hidden */
  113293. _attachCameras(cameras: Camera[], unique: boolean): void;
  113294. /** @hidden */
  113295. _detachCameras(cameras: Camera): void;
  113296. /** @hidden */
  113297. _detachCameras(cameras: Nullable<Camera[]>): void;
  113298. /** @hidden */
  113299. _update(): void;
  113300. /** @hidden */
  113301. _reset(): void;
  113302. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113303. /**
  113304. * Disposes of the pipeline
  113305. */
  113306. dispose(): void;
  113307. }
  113308. }
  113309. declare module BABYLON {
  113310. /**
  113311. * PostProcessRenderPipelineManager class
  113312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113313. */
  113314. export class PostProcessRenderPipelineManager {
  113315. private _renderPipelines;
  113316. /**
  113317. * Initializes a PostProcessRenderPipelineManager
  113318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113319. */
  113320. constructor();
  113321. /**
  113322. * Gets the list of supported render pipelines
  113323. */
  113324. readonly supportedPipelines: PostProcessRenderPipeline[];
  113325. /**
  113326. * Adds a pipeline to the manager
  113327. * @param renderPipeline The pipeline to add
  113328. */
  113329. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113330. /**
  113331. * Attaches a camera to the pipeline
  113332. * @param renderPipelineName The name of the pipeline to attach to
  113333. * @param cameras the camera to attach
  113334. * @param unique if the camera can be attached multiple times to the pipeline
  113335. */
  113336. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113337. /**
  113338. * Detaches a camera from the pipeline
  113339. * @param renderPipelineName The name of the pipeline to detach from
  113340. * @param cameras the camera to detach
  113341. */
  113342. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113343. /**
  113344. * Enables an effect by name on a pipeline
  113345. * @param renderPipelineName the name of the pipeline to enable the effect in
  113346. * @param renderEffectName the name of the effect to enable
  113347. * @param cameras the cameras that the effect should be enabled on
  113348. */
  113349. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113350. /**
  113351. * Disables an effect by name on a pipeline
  113352. * @param renderPipelineName the name of the pipeline to disable the effect in
  113353. * @param renderEffectName the name of the effect to disable
  113354. * @param cameras the cameras that the effect should be disabled on
  113355. */
  113356. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113357. /**
  113358. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113359. */
  113360. update(): void;
  113361. /** @hidden */
  113362. _rebuild(): void;
  113363. /**
  113364. * Disposes of the manager and pipelines
  113365. */
  113366. dispose(): void;
  113367. }
  113368. }
  113369. declare module BABYLON {
  113370. interface Scene {
  113371. /** @hidden (Backing field) */
  113372. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113373. /**
  113374. * Gets the postprocess render pipeline manager
  113375. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113376. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113377. */
  113378. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113379. }
  113380. /**
  113381. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113382. */
  113383. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113384. /**
  113385. * The component name helpfull to identify the component in the list of scene components.
  113386. */
  113387. readonly name: string;
  113388. /**
  113389. * The scene the component belongs to.
  113390. */
  113391. scene: Scene;
  113392. /**
  113393. * Creates a new instance of the component for the given scene
  113394. * @param scene Defines the scene to register the component in
  113395. */
  113396. constructor(scene: Scene);
  113397. /**
  113398. * Registers the component in a given scene
  113399. */
  113400. register(): void;
  113401. /**
  113402. * Rebuilds the elements related to this component in case of
  113403. * context lost for instance.
  113404. */
  113405. rebuild(): void;
  113406. /**
  113407. * Disposes the component and the associated ressources
  113408. */
  113409. dispose(): void;
  113410. private _gatherRenderTargets;
  113411. }
  113412. }
  113413. declare module BABYLON {
  113414. /**
  113415. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113416. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113417. */
  113418. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113419. private _scene;
  113420. private _camerasToBeAttached;
  113421. /**
  113422. * ID of the sharpen post process,
  113423. */
  113424. private readonly SharpenPostProcessId;
  113425. /**
  113426. * @ignore
  113427. * ID of the image processing post process;
  113428. */
  113429. readonly ImageProcessingPostProcessId: string;
  113430. /**
  113431. * @ignore
  113432. * ID of the Fast Approximate Anti-Aliasing post process;
  113433. */
  113434. readonly FxaaPostProcessId: string;
  113435. /**
  113436. * ID of the chromatic aberration post process,
  113437. */
  113438. private readonly ChromaticAberrationPostProcessId;
  113439. /**
  113440. * ID of the grain post process
  113441. */
  113442. private readonly GrainPostProcessId;
  113443. /**
  113444. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113445. */
  113446. sharpen: SharpenPostProcess;
  113447. private _sharpenEffect;
  113448. private bloom;
  113449. /**
  113450. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113451. */
  113452. depthOfField: DepthOfFieldEffect;
  113453. /**
  113454. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113455. */
  113456. fxaa: FxaaPostProcess;
  113457. /**
  113458. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113459. */
  113460. imageProcessing: ImageProcessingPostProcess;
  113461. /**
  113462. * Chromatic aberration post process which will shift rgb colors in the image
  113463. */
  113464. chromaticAberration: ChromaticAberrationPostProcess;
  113465. private _chromaticAberrationEffect;
  113466. /**
  113467. * Grain post process which add noise to the image
  113468. */
  113469. grain: GrainPostProcess;
  113470. private _grainEffect;
  113471. /**
  113472. * Glow post process which adds a glow to emissive areas of the image
  113473. */
  113474. private _glowLayer;
  113475. /**
  113476. * Animations which can be used to tweak settings over a period of time
  113477. */
  113478. animations: Animation[];
  113479. private _imageProcessingConfigurationObserver;
  113480. private _sharpenEnabled;
  113481. private _bloomEnabled;
  113482. private _depthOfFieldEnabled;
  113483. private _depthOfFieldBlurLevel;
  113484. private _fxaaEnabled;
  113485. private _imageProcessingEnabled;
  113486. private _defaultPipelineTextureType;
  113487. private _bloomScale;
  113488. private _chromaticAberrationEnabled;
  113489. private _grainEnabled;
  113490. private _buildAllowed;
  113491. /**
  113492. * Gets active scene
  113493. */
  113494. readonly scene: Scene;
  113495. /**
  113496. * Enable or disable the sharpen process from the pipeline
  113497. */
  113498. sharpenEnabled: boolean;
  113499. private _resizeObserver;
  113500. private _hardwareScaleLevel;
  113501. private _bloomKernel;
  113502. /**
  113503. * Specifies the size of the bloom blur kernel, relative to the final output size
  113504. */
  113505. bloomKernel: number;
  113506. /**
  113507. * Specifies the weight of the bloom in the final rendering
  113508. */
  113509. private _bloomWeight;
  113510. /**
  113511. * Specifies the luma threshold for the area that will be blurred by the bloom
  113512. */
  113513. private _bloomThreshold;
  113514. private _hdr;
  113515. /**
  113516. * The strength of the bloom.
  113517. */
  113518. bloomWeight: number;
  113519. /**
  113520. * The strength of the bloom.
  113521. */
  113522. bloomThreshold: number;
  113523. /**
  113524. * The scale of the bloom, lower value will provide better performance.
  113525. */
  113526. bloomScale: number;
  113527. /**
  113528. * Enable or disable the bloom from the pipeline
  113529. */
  113530. bloomEnabled: boolean;
  113531. private _rebuildBloom;
  113532. /**
  113533. * If the depth of field is enabled.
  113534. */
  113535. depthOfFieldEnabled: boolean;
  113536. /**
  113537. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113538. */
  113539. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113540. /**
  113541. * If the anti aliasing is enabled.
  113542. */
  113543. fxaaEnabled: boolean;
  113544. private _samples;
  113545. /**
  113546. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113547. */
  113548. samples: number;
  113549. /**
  113550. * If image processing is enabled.
  113551. */
  113552. imageProcessingEnabled: boolean;
  113553. /**
  113554. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113555. */
  113556. glowLayerEnabled: boolean;
  113557. /**
  113558. * Gets the glow layer (or null if not defined)
  113559. */
  113560. readonly glowLayer: Nullable<GlowLayer>;
  113561. /**
  113562. * Enable or disable the chromaticAberration process from the pipeline
  113563. */
  113564. chromaticAberrationEnabled: boolean;
  113565. /**
  113566. * Enable or disable the grain process from the pipeline
  113567. */
  113568. grainEnabled: boolean;
  113569. /**
  113570. * @constructor
  113571. * @param name - The rendering pipeline name (default: "")
  113572. * @param hdr - If high dynamic range textures should be used (default: true)
  113573. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113574. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113575. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113576. */
  113577. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113578. /**
  113579. * Get the class name
  113580. * @returns "DefaultRenderingPipeline"
  113581. */
  113582. getClassName(): string;
  113583. /**
  113584. * Force the compilation of the entire pipeline.
  113585. */
  113586. prepare(): void;
  113587. private _hasCleared;
  113588. private _prevPostProcess;
  113589. private _prevPrevPostProcess;
  113590. private _setAutoClearAndTextureSharing;
  113591. private _depthOfFieldSceneObserver;
  113592. private _buildPipeline;
  113593. private _disposePostProcesses;
  113594. /**
  113595. * Adds a camera to the pipeline
  113596. * @param camera the camera to be added
  113597. */
  113598. addCamera(camera: Camera): void;
  113599. /**
  113600. * Removes a camera from the pipeline
  113601. * @param camera the camera to remove
  113602. */
  113603. removeCamera(camera: Camera): void;
  113604. /**
  113605. * Dispose of the pipeline and stop all post processes
  113606. */
  113607. dispose(): void;
  113608. /**
  113609. * Serialize the rendering pipeline (Used when exporting)
  113610. * @returns the serialized object
  113611. */
  113612. serialize(): any;
  113613. /**
  113614. * Parse the serialized pipeline
  113615. * @param source Source pipeline.
  113616. * @param scene The scene to load the pipeline to.
  113617. * @param rootUrl The URL of the serialized pipeline.
  113618. * @returns An instantiated pipeline from the serialized object.
  113619. */
  113620. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113621. }
  113622. }
  113623. declare module BABYLON {
  113624. /** @hidden */
  113625. export var lensHighlightsPixelShader: {
  113626. name: string;
  113627. shader: string;
  113628. };
  113629. }
  113630. declare module BABYLON {
  113631. /** @hidden */
  113632. export var depthOfFieldPixelShader: {
  113633. name: string;
  113634. shader: string;
  113635. };
  113636. }
  113637. declare module BABYLON {
  113638. /**
  113639. * BABYLON.JS Chromatic Aberration GLSL Shader
  113640. * Author: Olivier Guyot
  113641. * Separates very slightly R, G and B colors on the edges of the screen
  113642. * Inspired by Francois Tarlier & Martins Upitis
  113643. */
  113644. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113645. /**
  113646. * @ignore
  113647. * The chromatic aberration PostProcess id in the pipeline
  113648. */
  113649. LensChromaticAberrationEffect: string;
  113650. /**
  113651. * @ignore
  113652. * The highlights enhancing PostProcess id in the pipeline
  113653. */
  113654. HighlightsEnhancingEffect: string;
  113655. /**
  113656. * @ignore
  113657. * The depth-of-field PostProcess id in the pipeline
  113658. */
  113659. LensDepthOfFieldEffect: string;
  113660. private _scene;
  113661. private _depthTexture;
  113662. private _grainTexture;
  113663. private _chromaticAberrationPostProcess;
  113664. private _highlightsPostProcess;
  113665. private _depthOfFieldPostProcess;
  113666. private _edgeBlur;
  113667. private _grainAmount;
  113668. private _chromaticAberration;
  113669. private _distortion;
  113670. private _highlightsGain;
  113671. private _highlightsThreshold;
  113672. private _dofDistance;
  113673. private _dofAperture;
  113674. private _dofDarken;
  113675. private _dofPentagon;
  113676. private _blurNoise;
  113677. /**
  113678. * @constructor
  113679. *
  113680. * Effect parameters are as follow:
  113681. * {
  113682. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113683. * edge_blur: number; // from 0 to x (1 for realism)
  113684. * distortion: number; // from 0 to x (1 for realism)
  113685. * grain_amount: number; // from 0 to 1
  113686. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113687. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113688. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113689. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113690. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113691. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113692. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113693. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113694. * }
  113695. * Note: if an effect parameter is unset, effect is disabled
  113696. *
  113697. * @param name The rendering pipeline name
  113698. * @param parameters - An object containing all parameters (see above)
  113699. * @param scene The scene linked to this pipeline
  113700. * @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)
  113701. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113702. */
  113703. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113704. /**
  113705. * Get the class name
  113706. * @returns "LensRenderingPipeline"
  113707. */
  113708. getClassName(): string;
  113709. /**
  113710. * Gets associated scene
  113711. */
  113712. readonly scene: Scene;
  113713. /**
  113714. * Gets or sets the edge blur
  113715. */
  113716. edgeBlur: number;
  113717. /**
  113718. * Gets or sets the grain amount
  113719. */
  113720. grainAmount: number;
  113721. /**
  113722. * Gets or sets the chromatic aberration amount
  113723. */
  113724. chromaticAberration: number;
  113725. /**
  113726. * Gets or sets the depth of field aperture
  113727. */
  113728. dofAperture: number;
  113729. /**
  113730. * Gets or sets the edge distortion
  113731. */
  113732. edgeDistortion: number;
  113733. /**
  113734. * Gets or sets the depth of field distortion
  113735. */
  113736. dofDistortion: number;
  113737. /**
  113738. * Gets or sets the darken out of focus amount
  113739. */
  113740. darkenOutOfFocus: number;
  113741. /**
  113742. * Gets or sets a boolean indicating if blur noise is enabled
  113743. */
  113744. blurNoise: boolean;
  113745. /**
  113746. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113747. */
  113748. pentagonBokeh: boolean;
  113749. /**
  113750. * Gets or sets the highlight grain amount
  113751. */
  113752. highlightsGain: number;
  113753. /**
  113754. * Gets or sets the highlight threshold
  113755. */
  113756. highlightsThreshold: number;
  113757. /**
  113758. * Sets the amount of blur at the edges
  113759. * @param amount blur amount
  113760. */
  113761. setEdgeBlur(amount: number): void;
  113762. /**
  113763. * Sets edge blur to 0
  113764. */
  113765. disableEdgeBlur(): void;
  113766. /**
  113767. * Sets the amout of grain
  113768. * @param amount Amount of grain
  113769. */
  113770. setGrainAmount(amount: number): void;
  113771. /**
  113772. * Set grain amount to 0
  113773. */
  113774. disableGrain(): void;
  113775. /**
  113776. * Sets the chromatic aberration amount
  113777. * @param amount amount of chromatic aberration
  113778. */
  113779. setChromaticAberration(amount: number): void;
  113780. /**
  113781. * Sets chromatic aberration amount to 0
  113782. */
  113783. disableChromaticAberration(): void;
  113784. /**
  113785. * Sets the EdgeDistortion amount
  113786. * @param amount amount of EdgeDistortion
  113787. */
  113788. setEdgeDistortion(amount: number): void;
  113789. /**
  113790. * Sets edge distortion to 0
  113791. */
  113792. disableEdgeDistortion(): void;
  113793. /**
  113794. * Sets the FocusDistance amount
  113795. * @param amount amount of FocusDistance
  113796. */
  113797. setFocusDistance(amount: number): void;
  113798. /**
  113799. * Disables depth of field
  113800. */
  113801. disableDepthOfField(): void;
  113802. /**
  113803. * Sets the Aperture amount
  113804. * @param amount amount of Aperture
  113805. */
  113806. setAperture(amount: number): void;
  113807. /**
  113808. * Sets the DarkenOutOfFocus amount
  113809. * @param amount amount of DarkenOutOfFocus
  113810. */
  113811. setDarkenOutOfFocus(amount: number): void;
  113812. private _pentagonBokehIsEnabled;
  113813. /**
  113814. * Creates a pentagon bokeh effect
  113815. */
  113816. enablePentagonBokeh(): void;
  113817. /**
  113818. * Disables the pentagon bokeh effect
  113819. */
  113820. disablePentagonBokeh(): void;
  113821. /**
  113822. * Enables noise blur
  113823. */
  113824. enableNoiseBlur(): void;
  113825. /**
  113826. * Disables noise blur
  113827. */
  113828. disableNoiseBlur(): void;
  113829. /**
  113830. * Sets the HighlightsGain amount
  113831. * @param amount amount of HighlightsGain
  113832. */
  113833. setHighlightsGain(amount: number): void;
  113834. /**
  113835. * Sets the HighlightsThreshold amount
  113836. * @param amount amount of HighlightsThreshold
  113837. */
  113838. setHighlightsThreshold(amount: number): void;
  113839. /**
  113840. * Disables highlights
  113841. */
  113842. disableHighlights(): void;
  113843. /**
  113844. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113845. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113846. */
  113847. dispose(disableDepthRender?: boolean): void;
  113848. private _createChromaticAberrationPostProcess;
  113849. private _createHighlightsPostProcess;
  113850. private _createDepthOfFieldPostProcess;
  113851. private _createGrainTexture;
  113852. }
  113853. }
  113854. declare module BABYLON {
  113855. /** @hidden */
  113856. export var ssao2PixelShader: {
  113857. name: string;
  113858. shader: string;
  113859. };
  113860. }
  113861. declare module BABYLON {
  113862. /** @hidden */
  113863. export var ssaoCombinePixelShader: {
  113864. name: string;
  113865. shader: string;
  113866. };
  113867. }
  113868. declare module BABYLON {
  113869. /**
  113870. * Render pipeline to produce ssao effect
  113871. */
  113872. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113873. /**
  113874. * @ignore
  113875. * The PassPostProcess id in the pipeline that contains the original scene color
  113876. */
  113877. SSAOOriginalSceneColorEffect: string;
  113878. /**
  113879. * @ignore
  113880. * The SSAO PostProcess id in the pipeline
  113881. */
  113882. SSAORenderEffect: string;
  113883. /**
  113884. * @ignore
  113885. * The horizontal blur PostProcess id in the pipeline
  113886. */
  113887. SSAOBlurHRenderEffect: string;
  113888. /**
  113889. * @ignore
  113890. * The vertical blur PostProcess id in the pipeline
  113891. */
  113892. SSAOBlurVRenderEffect: string;
  113893. /**
  113894. * @ignore
  113895. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113896. */
  113897. SSAOCombineRenderEffect: string;
  113898. /**
  113899. * The output strength of the SSAO post-process. Default value is 1.0.
  113900. */
  113901. totalStrength: number;
  113902. /**
  113903. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113904. */
  113905. maxZ: number;
  113906. /**
  113907. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113908. */
  113909. minZAspect: number;
  113910. private _samples;
  113911. /**
  113912. * Number of samples used for the SSAO calculations. Default value is 8
  113913. */
  113914. samples: number;
  113915. private _textureSamples;
  113916. /**
  113917. * Number of samples to use for antialiasing
  113918. */
  113919. textureSamples: number;
  113920. /**
  113921. * Ratio object used for SSAO ratio and blur ratio
  113922. */
  113923. private _ratio;
  113924. /**
  113925. * Dynamically generated sphere sampler.
  113926. */
  113927. private _sampleSphere;
  113928. /**
  113929. * Blur filter offsets
  113930. */
  113931. private _samplerOffsets;
  113932. private _expensiveBlur;
  113933. /**
  113934. * If bilateral blur should be used
  113935. */
  113936. expensiveBlur: boolean;
  113937. /**
  113938. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113939. */
  113940. radius: number;
  113941. /**
  113942. * The base color of the SSAO post-process
  113943. * The final result is "base + ssao" between [0, 1]
  113944. */
  113945. base: number;
  113946. /**
  113947. * Support test.
  113948. */
  113949. static readonly IsSupported: boolean;
  113950. private _scene;
  113951. private _depthTexture;
  113952. private _normalTexture;
  113953. private _randomTexture;
  113954. private _originalColorPostProcess;
  113955. private _ssaoPostProcess;
  113956. private _blurHPostProcess;
  113957. private _blurVPostProcess;
  113958. private _ssaoCombinePostProcess;
  113959. private _firstUpdate;
  113960. /**
  113961. * Gets active scene
  113962. */
  113963. readonly scene: Scene;
  113964. /**
  113965. * @constructor
  113966. * @param name The rendering pipeline name
  113967. * @param scene The scene linked to this pipeline
  113968. * @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 }
  113969. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113970. */
  113971. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113972. /**
  113973. * Get the class name
  113974. * @returns "SSAO2RenderingPipeline"
  113975. */
  113976. getClassName(): string;
  113977. /**
  113978. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113979. */
  113980. dispose(disableGeometryBufferRenderer?: boolean): void;
  113981. private _createBlurPostProcess;
  113982. /** @hidden */
  113983. _rebuild(): void;
  113984. private _bits;
  113985. private _radicalInverse_VdC;
  113986. private _hammersley;
  113987. private _hemisphereSample_uniform;
  113988. private _generateHemisphere;
  113989. private _createSSAOPostProcess;
  113990. private _createSSAOCombinePostProcess;
  113991. private _createRandomTexture;
  113992. /**
  113993. * Serialize the rendering pipeline (Used when exporting)
  113994. * @returns the serialized object
  113995. */
  113996. serialize(): any;
  113997. /**
  113998. * Parse the serialized pipeline
  113999. * @param source Source pipeline.
  114000. * @param scene The scene to load the pipeline to.
  114001. * @param rootUrl The URL of the serialized pipeline.
  114002. * @returns An instantiated pipeline from the serialized object.
  114003. */
  114004. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114005. }
  114006. }
  114007. declare module BABYLON {
  114008. /** @hidden */
  114009. export var ssaoPixelShader: {
  114010. name: string;
  114011. shader: string;
  114012. };
  114013. }
  114014. declare module BABYLON {
  114015. /**
  114016. * Render pipeline to produce ssao effect
  114017. */
  114018. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114019. /**
  114020. * @ignore
  114021. * The PassPostProcess id in the pipeline that contains the original scene color
  114022. */
  114023. SSAOOriginalSceneColorEffect: string;
  114024. /**
  114025. * @ignore
  114026. * The SSAO PostProcess id in the pipeline
  114027. */
  114028. SSAORenderEffect: string;
  114029. /**
  114030. * @ignore
  114031. * The horizontal blur PostProcess id in the pipeline
  114032. */
  114033. SSAOBlurHRenderEffect: string;
  114034. /**
  114035. * @ignore
  114036. * The vertical blur PostProcess id in the pipeline
  114037. */
  114038. SSAOBlurVRenderEffect: string;
  114039. /**
  114040. * @ignore
  114041. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114042. */
  114043. SSAOCombineRenderEffect: string;
  114044. /**
  114045. * The output strength of the SSAO post-process. Default value is 1.0.
  114046. */
  114047. totalStrength: number;
  114048. /**
  114049. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114050. */
  114051. radius: number;
  114052. /**
  114053. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114054. * Must not be equal to fallOff and superior to fallOff.
  114055. * Default value is 0.0075
  114056. */
  114057. area: number;
  114058. /**
  114059. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114060. * Must not be equal to area and inferior to area.
  114061. * Default value is 0.000001
  114062. */
  114063. fallOff: number;
  114064. /**
  114065. * The base color of the SSAO post-process
  114066. * The final result is "base + ssao" between [0, 1]
  114067. */
  114068. base: number;
  114069. private _scene;
  114070. private _depthTexture;
  114071. private _randomTexture;
  114072. private _originalColorPostProcess;
  114073. private _ssaoPostProcess;
  114074. private _blurHPostProcess;
  114075. private _blurVPostProcess;
  114076. private _ssaoCombinePostProcess;
  114077. private _firstUpdate;
  114078. /**
  114079. * Gets active scene
  114080. */
  114081. readonly scene: Scene;
  114082. /**
  114083. * @constructor
  114084. * @param name - The rendering pipeline name
  114085. * @param scene - The scene linked to this pipeline
  114086. * @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 }
  114087. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114088. */
  114089. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114090. /**
  114091. * Get the class name
  114092. * @returns "SSAORenderingPipeline"
  114093. */
  114094. getClassName(): string;
  114095. /**
  114096. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114097. */
  114098. dispose(disableDepthRender?: boolean): void;
  114099. private _createBlurPostProcess;
  114100. /** @hidden */
  114101. _rebuild(): void;
  114102. private _createSSAOPostProcess;
  114103. private _createSSAOCombinePostProcess;
  114104. private _createRandomTexture;
  114105. }
  114106. }
  114107. declare module BABYLON {
  114108. /** @hidden */
  114109. export var standardPixelShader: {
  114110. name: string;
  114111. shader: string;
  114112. };
  114113. }
  114114. declare module BABYLON {
  114115. /**
  114116. * Standard rendering pipeline
  114117. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114118. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114119. */
  114120. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114121. /**
  114122. * Public members
  114123. */
  114124. /**
  114125. * Post-process which contains the original scene color before the pipeline applies all the effects
  114126. */
  114127. originalPostProcess: Nullable<PostProcess>;
  114128. /**
  114129. * Post-process used to down scale an image x4
  114130. */
  114131. downSampleX4PostProcess: Nullable<PostProcess>;
  114132. /**
  114133. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114134. */
  114135. brightPassPostProcess: Nullable<PostProcess>;
  114136. /**
  114137. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114138. */
  114139. blurHPostProcesses: PostProcess[];
  114140. /**
  114141. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114142. */
  114143. blurVPostProcesses: PostProcess[];
  114144. /**
  114145. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114146. */
  114147. textureAdderPostProcess: Nullable<PostProcess>;
  114148. /**
  114149. * Post-process used to create volumetric lighting effect
  114150. */
  114151. volumetricLightPostProcess: Nullable<PostProcess>;
  114152. /**
  114153. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114154. */
  114155. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114156. /**
  114157. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114158. */
  114159. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114160. /**
  114161. * Post-process used to merge the volumetric light effect and the real scene color
  114162. */
  114163. volumetricLightMergePostProces: Nullable<PostProcess>;
  114164. /**
  114165. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114166. */
  114167. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114168. /**
  114169. * Base post-process used to calculate the average luminance of the final image for HDR
  114170. */
  114171. luminancePostProcess: Nullable<PostProcess>;
  114172. /**
  114173. * Post-processes used to create down sample post-processes in order to get
  114174. * the average luminance of the final image for HDR
  114175. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114176. */
  114177. luminanceDownSamplePostProcesses: PostProcess[];
  114178. /**
  114179. * Post-process used to create a HDR effect (light adaptation)
  114180. */
  114181. hdrPostProcess: Nullable<PostProcess>;
  114182. /**
  114183. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114184. */
  114185. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114186. /**
  114187. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114188. */
  114189. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114190. /**
  114191. * Post-process used to merge the final HDR post-process and the real scene color
  114192. */
  114193. hdrFinalPostProcess: Nullable<PostProcess>;
  114194. /**
  114195. * Post-process used to create a lens flare effect
  114196. */
  114197. lensFlarePostProcess: Nullable<PostProcess>;
  114198. /**
  114199. * Post-process that merges the result of the lens flare post-process and the real scene color
  114200. */
  114201. lensFlareComposePostProcess: Nullable<PostProcess>;
  114202. /**
  114203. * Post-process used to create a motion blur effect
  114204. */
  114205. motionBlurPostProcess: Nullable<PostProcess>;
  114206. /**
  114207. * Post-process used to create a depth of field effect
  114208. */
  114209. depthOfFieldPostProcess: Nullable<PostProcess>;
  114210. /**
  114211. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114212. */
  114213. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114214. /**
  114215. * Represents the brightness threshold in order to configure the illuminated surfaces
  114216. */
  114217. brightThreshold: number;
  114218. /**
  114219. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114220. */
  114221. blurWidth: number;
  114222. /**
  114223. * Sets if the blur for highlighted surfaces must be only horizontal
  114224. */
  114225. horizontalBlur: boolean;
  114226. /**
  114227. * Gets the overall exposure used by the pipeline
  114228. */
  114229. /**
  114230. * Sets the overall exposure used by the pipeline
  114231. */
  114232. exposure: number;
  114233. /**
  114234. * Texture used typically to simulate "dirty" on camera lens
  114235. */
  114236. lensTexture: Nullable<Texture>;
  114237. /**
  114238. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114239. */
  114240. volumetricLightCoefficient: number;
  114241. /**
  114242. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114243. */
  114244. volumetricLightPower: number;
  114245. /**
  114246. * Used the set the blur intensity to smooth the volumetric lights
  114247. */
  114248. volumetricLightBlurScale: number;
  114249. /**
  114250. * Light (spot or directional) used to generate the volumetric lights rays
  114251. * The source light must have a shadow generate so the pipeline can get its
  114252. * depth map
  114253. */
  114254. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114255. /**
  114256. * For eye adaptation, represents the minimum luminance the eye can see
  114257. */
  114258. hdrMinimumLuminance: number;
  114259. /**
  114260. * For eye adaptation, represents the decrease luminance speed
  114261. */
  114262. hdrDecreaseRate: number;
  114263. /**
  114264. * For eye adaptation, represents the increase luminance speed
  114265. */
  114266. hdrIncreaseRate: number;
  114267. /**
  114268. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114269. */
  114270. /**
  114271. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114272. */
  114273. hdrAutoExposure: boolean;
  114274. /**
  114275. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114276. */
  114277. lensColorTexture: Nullable<Texture>;
  114278. /**
  114279. * The overall strengh for the lens flare effect
  114280. */
  114281. lensFlareStrength: number;
  114282. /**
  114283. * Dispersion coefficient for lens flare ghosts
  114284. */
  114285. lensFlareGhostDispersal: number;
  114286. /**
  114287. * Main lens flare halo width
  114288. */
  114289. lensFlareHaloWidth: number;
  114290. /**
  114291. * Based on the lens distortion effect, defines how much the lens flare result
  114292. * is distorted
  114293. */
  114294. lensFlareDistortionStrength: number;
  114295. /**
  114296. * Lens star texture must be used to simulate rays on the flares and is available
  114297. * in the documentation
  114298. */
  114299. lensStarTexture: Nullable<Texture>;
  114300. /**
  114301. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114302. * flare effect by taking account of the dirt texture
  114303. */
  114304. lensFlareDirtTexture: Nullable<Texture>;
  114305. /**
  114306. * Represents the focal length for the depth of field effect
  114307. */
  114308. depthOfFieldDistance: number;
  114309. /**
  114310. * Represents the blur intensity for the blurred part of the depth of field effect
  114311. */
  114312. depthOfFieldBlurWidth: number;
  114313. /**
  114314. * For motion blur, defines how much the image is blurred by the movement
  114315. */
  114316. motionStrength: number;
  114317. /**
  114318. * List of animations for the pipeline (IAnimatable implementation)
  114319. */
  114320. animations: Animation[];
  114321. /**
  114322. * Private members
  114323. */
  114324. private _scene;
  114325. private _currentDepthOfFieldSource;
  114326. private _basePostProcess;
  114327. private _fixedExposure;
  114328. private _currentExposure;
  114329. private _hdrAutoExposure;
  114330. private _hdrCurrentLuminance;
  114331. private _floatTextureType;
  114332. private _ratio;
  114333. private _bloomEnabled;
  114334. private _depthOfFieldEnabled;
  114335. private _vlsEnabled;
  114336. private _lensFlareEnabled;
  114337. private _hdrEnabled;
  114338. private _motionBlurEnabled;
  114339. private _fxaaEnabled;
  114340. private _motionBlurSamples;
  114341. private _volumetricLightStepsCount;
  114342. private _samples;
  114343. /**
  114344. * @ignore
  114345. * Specifies if the bloom pipeline is enabled
  114346. */
  114347. BloomEnabled: boolean;
  114348. /**
  114349. * @ignore
  114350. * Specifies if the depth of field pipeline is enabed
  114351. */
  114352. DepthOfFieldEnabled: boolean;
  114353. /**
  114354. * @ignore
  114355. * Specifies if the lens flare pipeline is enabed
  114356. */
  114357. LensFlareEnabled: boolean;
  114358. /**
  114359. * @ignore
  114360. * Specifies if the HDR pipeline is enabled
  114361. */
  114362. HDREnabled: boolean;
  114363. /**
  114364. * @ignore
  114365. * Specifies if the volumetric lights scattering effect is enabled
  114366. */
  114367. VLSEnabled: boolean;
  114368. /**
  114369. * @ignore
  114370. * Specifies if the motion blur effect is enabled
  114371. */
  114372. MotionBlurEnabled: boolean;
  114373. /**
  114374. * Specifies if anti-aliasing is enabled
  114375. */
  114376. fxaaEnabled: boolean;
  114377. /**
  114378. * Specifies the number of steps used to calculate the volumetric lights
  114379. * Typically in interval [50, 200]
  114380. */
  114381. volumetricLightStepsCount: number;
  114382. /**
  114383. * Specifies the number of samples used for the motion blur effect
  114384. * Typically in interval [16, 64]
  114385. */
  114386. motionBlurSamples: number;
  114387. /**
  114388. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114389. */
  114390. samples: number;
  114391. /**
  114392. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114393. * @constructor
  114394. * @param name The rendering pipeline name
  114395. * @param scene The scene linked to this pipeline
  114396. * @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)
  114397. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114398. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114399. */
  114400. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114401. private _buildPipeline;
  114402. private _createDownSampleX4PostProcess;
  114403. private _createBrightPassPostProcess;
  114404. private _createBlurPostProcesses;
  114405. private _createTextureAdderPostProcess;
  114406. private _createVolumetricLightPostProcess;
  114407. private _createLuminancePostProcesses;
  114408. private _createHdrPostProcess;
  114409. private _createLensFlarePostProcess;
  114410. private _createDepthOfFieldPostProcess;
  114411. private _createMotionBlurPostProcess;
  114412. private _getDepthTexture;
  114413. private _disposePostProcesses;
  114414. /**
  114415. * Dispose of the pipeline and stop all post processes
  114416. */
  114417. dispose(): void;
  114418. /**
  114419. * Serialize the rendering pipeline (Used when exporting)
  114420. * @returns the serialized object
  114421. */
  114422. serialize(): any;
  114423. /**
  114424. * Parse the serialized pipeline
  114425. * @param source Source pipeline.
  114426. * @param scene The scene to load the pipeline to.
  114427. * @param rootUrl The URL of the serialized pipeline.
  114428. * @returns An instantiated pipeline from the serialized object.
  114429. */
  114430. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114431. /**
  114432. * Luminance steps
  114433. */
  114434. static LuminanceSteps: number;
  114435. }
  114436. }
  114437. declare module BABYLON {
  114438. /** @hidden */
  114439. export var tonemapPixelShader: {
  114440. name: string;
  114441. shader: string;
  114442. };
  114443. }
  114444. declare module BABYLON {
  114445. /** Defines operator used for tonemapping */
  114446. export enum TonemappingOperator {
  114447. /** Hable */
  114448. Hable = 0,
  114449. /** Reinhard */
  114450. Reinhard = 1,
  114451. /** HejiDawson */
  114452. HejiDawson = 2,
  114453. /** Photographic */
  114454. Photographic = 3
  114455. }
  114456. /**
  114457. * Defines a post process to apply tone mapping
  114458. */
  114459. export class TonemapPostProcess extends PostProcess {
  114460. private _operator;
  114461. /** Defines the required exposure adjustement */
  114462. exposureAdjustment: number;
  114463. /**
  114464. * Creates a new TonemapPostProcess
  114465. * @param name defines the name of the postprocess
  114466. * @param _operator defines the operator to use
  114467. * @param exposureAdjustment defines the required exposure adjustement
  114468. * @param camera defines the camera to use (can be null)
  114469. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114470. * @param engine defines the hosting engine (can be ignore if camera is set)
  114471. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114472. */
  114473. constructor(name: string, _operator: TonemappingOperator,
  114474. /** Defines the required exposure adjustement */
  114475. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114476. }
  114477. }
  114478. declare module BABYLON {
  114479. /** @hidden */
  114480. export var depthVertexShader: {
  114481. name: string;
  114482. shader: string;
  114483. };
  114484. }
  114485. declare module BABYLON {
  114486. /** @hidden */
  114487. export var volumetricLightScatteringPixelShader: {
  114488. name: string;
  114489. shader: string;
  114490. };
  114491. }
  114492. declare module BABYLON {
  114493. /** @hidden */
  114494. export var volumetricLightScatteringPassPixelShader: {
  114495. name: string;
  114496. shader: string;
  114497. };
  114498. }
  114499. declare module BABYLON {
  114500. /**
  114501. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114502. */
  114503. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114504. private _volumetricLightScatteringPass;
  114505. private _volumetricLightScatteringRTT;
  114506. private _viewPort;
  114507. private _screenCoordinates;
  114508. private _cachedDefines;
  114509. /**
  114510. * If not undefined, the mesh position is computed from the attached node position
  114511. */
  114512. attachedNode: {
  114513. position: Vector3;
  114514. };
  114515. /**
  114516. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114517. */
  114518. customMeshPosition: Vector3;
  114519. /**
  114520. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114521. */
  114522. useCustomMeshPosition: boolean;
  114523. /**
  114524. * If the post-process should inverse the light scattering direction
  114525. */
  114526. invert: boolean;
  114527. /**
  114528. * The internal mesh used by the post-process
  114529. */
  114530. mesh: Mesh;
  114531. /**
  114532. * @hidden
  114533. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114534. */
  114535. useDiffuseColor: boolean;
  114536. /**
  114537. * Array containing the excluded meshes not rendered in the internal pass
  114538. */
  114539. excludedMeshes: AbstractMesh[];
  114540. /**
  114541. * Controls the overall intensity of the post-process
  114542. */
  114543. exposure: number;
  114544. /**
  114545. * Dissipates each sample's contribution in range [0, 1]
  114546. */
  114547. decay: number;
  114548. /**
  114549. * Controls the overall intensity of each sample
  114550. */
  114551. weight: number;
  114552. /**
  114553. * Controls the density of each sample
  114554. */
  114555. density: number;
  114556. /**
  114557. * @constructor
  114558. * @param name The post-process name
  114559. * @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)
  114560. * @param camera The camera that the post-process will be attached to
  114561. * @param mesh The mesh used to create the light scattering
  114562. * @param samples The post-process quality, default 100
  114563. * @param samplingModeThe post-process filtering mode
  114564. * @param engine The babylon engine
  114565. * @param reusable If the post-process is reusable
  114566. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114567. */
  114568. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114569. /**
  114570. * Returns the string "VolumetricLightScatteringPostProcess"
  114571. * @returns "VolumetricLightScatteringPostProcess"
  114572. */
  114573. getClassName(): string;
  114574. private _isReady;
  114575. /**
  114576. * Sets the new light position for light scattering effect
  114577. * @param position The new custom light position
  114578. */
  114579. setCustomMeshPosition(position: Vector3): void;
  114580. /**
  114581. * Returns the light position for light scattering effect
  114582. * @return Vector3 The custom light position
  114583. */
  114584. getCustomMeshPosition(): Vector3;
  114585. /**
  114586. * Disposes the internal assets and detaches the post-process from the camera
  114587. */
  114588. dispose(camera: Camera): void;
  114589. /**
  114590. * Returns the render target texture used by the post-process
  114591. * @return the render target texture used by the post-process
  114592. */
  114593. getPass(): RenderTargetTexture;
  114594. private _meshExcluded;
  114595. private _createPass;
  114596. private _updateMeshScreenCoordinates;
  114597. /**
  114598. * Creates a default mesh for the Volumeric Light Scattering post-process
  114599. * @param name The mesh name
  114600. * @param scene The scene where to create the mesh
  114601. * @return the default mesh
  114602. */
  114603. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114604. }
  114605. }
  114606. declare module BABYLON {
  114607. interface Scene {
  114608. /** @hidden (Backing field) */
  114609. _boundingBoxRenderer: BoundingBoxRenderer;
  114610. /** @hidden (Backing field) */
  114611. _forceShowBoundingBoxes: boolean;
  114612. /**
  114613. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114614. */
  114615. forceShowBoundingBoxes: boolean;
  114616. /**
  114617. * Gets the bounding box renderer associated with the scene
  114618. * @returns a BoundingBoxRenderer
  114619. */
  114620. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114621. }
  114622. interface AbstractMesh {
  114623. /** @hidden (Backing field) */
  114624. _showBoundingBox: boolean;
  114625. /**
  114626. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114627. */
  114628. showBoundingBox: boolean;
  114629. }
  114630. /**
  114631. * Component responsible of rendering the bounding box of the meshes in a scene.
  114632. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114633. */
  114634. export class BoundingBoxRenderer implements ISceneComponent {
  114635. /**
  114636. * The component name helpfull to identify the component in the list of scene components.
  114637. */
  114638. readonly name: string;
  114639. /**
  114640. * The scene the component belongs to.
  114641. */
  114642. scene: Scene;
  114643. /**
  114644. * Color of the bounding box lines placed in front of an object
  114645. */
  114646. frontColor: Color3;
  114647. /**
  114648. * Color of the bounding box lines placed behind an object
  114649. */
  114650. backColor: Color3;
  114651. /**
  114652. * Defines if the renderer should show the back lines or not
  114653. */
  114654. showBackLines: boolean;
  114655. /**
  114656. * @hidden
  114657. */
  114658. renderList: SmartArray<BoundingBox>;
  114659. private _colorShader;
  114660. private _vertexBuffers;
  114661. private _indexBuffer;
  114662. /**
  114663. * Instantiates a new bounding box renderer in a scene.
  114664. * @param scene the scene the renderer renders in
  114665. */
  114666. constructor(scene: Scene);
  114667. /**
  114668. * Registers the component in a given scene
  114669. */
  114670. register(): void;
  114671. private _evaluateSubMesh;
  114672. private _activeMesh;
  114673. private _prepareRessources;
  114674. private _createIndexBuffer;
  114675. /**
  114676. * Rebuilds the elements related to this component in case of
  114677. * context lost for instance.
  114678. */
  114679. rebuild(): void;
  114680. /**
  114681. * @hidden
  114682. */
  114683. reset(): void;
  114684. /**
  114685. * Render the bounding boxes of a specific rendering group
  114686. * @param renderingGroupId defines the rendering group to render
  114687. */
  114688. render(renderingGroupId: number): void;
  114689. /**
  114690. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114691. * @param mesh Define the mesh to render the occlusion bounding box for
  114692. */
  114693. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114694. /**
  114695. * Dispose and release the resources attached to this renderer.
  114696. */
  114697. dispose(): void;
  114698. }
  114699. }
  114700. declare module BABYLON {
  114701. /** @hidden */
  114702. export var depthPixelShader: {
  114703. name: string;
  114704. shader: string;
  114705. };
  114706. }
  114707. declare module BABYLON {
  114708. /**
  114709. * This represents a depth renderer in Babylon.
  114710. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114711. */
  114712. export class DepthRenderer {
  114713. private _scene;
  114714. private _depthMap;
  114715. private _effect;
  114716. private _cachedDefines;
  114717. private _camera;
  114718. /**
  114719. * Specifiess that the depth renderer will only be used within
  114720. * the camera it is created for.
  114721. * This can help forcing its rendering during the camera processing.
  114722. */
  114723. useOnlyInActiveCamera: boolean;
  114724. /** @hidden */
  114725. static _SceneComponentInitialization: (scene: Scene) => void;
  114726. /**
  114727. * Instantiates a depth renderer
  114728. * @param scene The scene the renderer belongs to
  114729. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114730. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114731. */
  114732. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114733. /**
  114734. * Creates the depth rendering effect and checks if the effect is ready.
  114735. * @param subMesh The submesh to be used to render the depth map of
  114736. * @param useInstances If multiple world instances should be used
  114737. * @returns if the depth renderer is ready to render the depth map
  114738. */
  114739. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114740. /**
  114741. * Gets the texture which the depth map will be written to.
  114742. * @returns The depth map texture
  114743. */
  114744. getDepthMap(): RenderTargetTexture;
  114745. /**
  114746. * Disposes of the depth renderer.
  114747. */
  114748. dispose(): void;
  114749. }
  114750. }
  114751. declare module BABYLON {
  114752. interface Scene {
  114753. /** @hidden (Backing field) */
  114754. _depthRenderer: {
  114755. [id: string]: DepthRenderer;
  114756. };
  114757. /**
  114758. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114759. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114760. * @returns the created depth renderer
  114761. */
  114762. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114763. /**
  114764. * Disables a depth renderer for a given camera
  114765. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114766. */
  114767. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114768. }
  114769. /**
  114770. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114771. * in several rendering techniques.
  114772. */
  114773. export class DepthRendererSceneComponent implements ISceneComponent {
  114774. /**
  114775. * The component name helpfull to identify the component in the list of scene components.
  114776. */
  114777. readonly name: string;
  114778. /**
  114779. * The scene the component belongs to.
  114780. */
  114781. scene: Scene;
  114782. /**
  114783. * Creates a new instance of the component for the given scene
  114784. * @param scene Defines the scene to register the component in
  114785. */
  114786. constructor(scene: Scene);
  114787. /**
  114788. * Registers the component in a given scene
  114789. */
  114790. register(): void;
  114791. /**
  114792. * Rebuilds the elements related to this component in case of
  114793. * context lost for instance.
  114794. */
  114795. rebuild(): void;
  114796. /**
  114797. * Disposes the component and the associated ressources
  114798. */
  114799. dispose(): void;
  114800. private _gatherRenderTargets;
  114801. private _gatherActiveCameraRenderTargets;
  114802. }
  114803. }
  114804. declare module BABYLON {
  114805. /** @hidden */
  114806. export var outlinePixelShader: {
  114807. name: string;
  114808. shader: string;
  114809. };
  114810. }
  114811. declare module BABYLON {
  114812. /** @hidden */
  114813. export var outlineVertexShader: {
  114814. name: string;
  114815. shader: string;
  114816. };
  114817. }
  114818. declare module BABYLON {
  114819. interface Scene {
  114820. /** @hidden */
  114821. _outlineRenderer: OutlineRenderer;
  114822. /**
  114823. * Gets the outline renderer associated with the scene
  114824. * @returns a OutlineRenderer
  114825. */
  114826. getOutlineRenderer(): OutlineRenderer;
  114827. }
  114828. interface AbstractMesh {
  114829. /** @hidden (Backing field) */
  114830. _renderOutline: boolean;
  114831. /**
  114832. * Gets or sets a boolean indicating if the outline must be rendered as well
  114833. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114834. */
  114835. renderOutline: boolean;
  114836. /** @hidden (Backing field) */
  114837. _renderOverlay: boolean;
  114838. /**
  114839. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114840. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114841. */
  114842. renderOverlay: boolean;
  114843. }
  114844. /**
  114845. * This class is responsible to draw bothe outline/overlay of meshes.
  114846. * It should not be used directly but through the available method on mesh.
  114847. */
  114848. export class OutlineRenderer implements ISceneComponent {
  114849. /**
  114850. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114851. */
  114852. private static _StencilReference;
  114853. /**
  114854. * The name of the component. Each component must have a unique name.
  114855. */
  114856. name: string;
  114857. /**
  114858. * The scene the component belongs to.
  114859. */
  114860. scene: Scene;
  114861. /**
  114862. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114863. */
  114864. zOffset: number;
  114865. private _engine;
  114866. private _effect;
  114867. private _cachedDefines;
  114868. private _savedDepthWrite;
  114869. /**
  114870. * Instantiates a new outline renderer. (There could be only one per scene).
  114871. * @param scene Defines the scene it belongs to
  114872. */
  114873. constructor(scene: Scene);
  114874. /**
  114875. * Register the component to one instance of a scene.
  114876. */
  114877. register(): void;
  114878. /**
  114879. * Rebuilds the elements related to this component in case of
  114880. * context lost for instance.
  114881. */
  114882. rebuild(): void;
  114883. /**
  114884. * Disposes the component and the associated ressources.
  114885. */
  114886. dispose(): void;
  114887. /**
  114888. * Renders the outline in the canvas.
  114889. * @param subMesh Defines the sumesh to render
  114890. * @param batch Defines the batch of meshes in case of instances
  114891. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114892. */
  114893. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114894. /**
  114895. * Returns whether or not the outline renderer is ready for a given submesh.
  114896. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114897. * @param subMesh Defines the submesh to check readyness for
  114898. * @param useInstances Defines wheter wee are trying to render instances or not
  114899. * @returns true if ready otherwise false
  114900. */
  114901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114902. private _beforeRenderingMesh;
  114903. private _afterRenderingMesh;
  114904. }
  114905. }
  114906. declare module BABYLON {
  114907. /**
  114908. * Defines the list of states available for a task inside a AssetsManager
  114909. */
  114910. export enum AssetTaskState {
  114911. /**
  114912. * Initialization
  114913. */
  114914. INIT = 0,
  114915. /**
  114916. * Running
  114917. */
  114918. RUNNING = 1,
  114919. /**
  114920. * Done
  114921. */
  114922. DONE = 2,
  114923. /**
  114924. * Error
  114925. */
  114926. ERROR = 3
  114927. }
  114928. /**
  114929. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114930. */
  114931. export abstract class AbstractAssetTask {
  114932. /**
  114933. * Task name
  114934. */ name: string;
  114935. /**
  114936. * Callback called when the task is successful
  114937. */
  114938. onSuccess: (task: any) => void;
  114939. /**
  114940. * Callback called when the task is not successful
  114941. */
  114942. onError: (task: any, message?: string, exception?: any) => void;
  114943. /**
  114944. * Creates a new AssetsManager
  114945. * @param name defines the name of the task
  114946. */
  114947. constructor(
  114948. /**
  114949. * Task name
  114950. */ name: string);
  114951. private _isCompleted;
  114952. private _taskState;
  114953. private _errorObject;
  114954. /**
  114955. * Get if the task is completed
  114956. */
  114957. readonly isCompleted: boolean;
  114958. /**
  114959. * Gets the current state of the task
  114960. */
  114961. readonly taskState: AssetTaskState;
  114962. /**
  114963. * Gets the current error object (if task is in error)
  114964. */
  114965. readonly errorObject: {
  114966. message?: string;
  114967. exception?: any;
  114968. };
  114969. /**
  114970. * Internal only
  114971. * @hidden
  114972. */
  114973. _setErrorObject(message?: string, exception?: any): void;
  114974. /**
  114975. * Execute the current task
  114976. * @param scene defines the scene where you want your assets to be loaded
  114977. * @param onSuccess is a callback called when the task is successfully executed
  114978. * @param onError is a callback called if an error occurs
  114979. */
  114980. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): 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. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114988. /**
  114989. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114990. * This can be used with failed tasks that have the reason for failure fixed.
  114991. */
  114992. reset(): void;
  114993. private onErrorCallback;
  114994. private onDoneCallback;
  114995. }
  114996. /**
  114997. * Define the interface used by progress events raised during assets loading
  114998. */
  114999. export interface IAssetsProgressEvent {
  115000. /**
  115001. * Defines the number of remaining tasks to process
  115002. */
  115003. remainingCount: number;
  115004. /**
  115005. * Defines the total number of tasks
  115006. */
  115007. totalCount: number;
  115008. /**
  115009. * Defines the task that was just processed
  115010. */
  115011. task: AbstractAssetTask;
  115012. }
  115013. /**
  115014. * Class used to share progress information about assets loading
  115015. */
  115016. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115017. /**
  115018. * Defines the number of remaining tasks to process
  115019. */
  115020. remainingCount: number;
  115021. /**
  115022. * Defines the total number of tasks
  115023. */
  115024. totalCount: number;
  115025. /**
  115026. * Defines the task that was just processed
  115027. */
  115028. task: AbstractAssetTask;
  115029. /**
  115030. * Creates a AssetsProgressEvent
  115031. * @param remainingCount defines the number of remaining tasks to process
  115032. * @param totalCount defines the total number of tasks
  115033. * @param task defines the task that was just processed
  115034. */
  115035. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115036. }
  115037. /**
  115038. * Define a task used by AssetsManager to load meshes
  115039. */
  115040. export class MeshAssetTask extends AbstractAssetTask {
  115041. /**
  115042. * Defines the name of the task
  115043. */
  115044. name: string;
  115045. /**
  115046. * Defines the list of mesh's names you want to load
  115047. */
  115048. meshesNames: any;
  115049. /**
  115050. * Defines the root url to use as a base to load your meshes and associated resources
  115051. */
  115052. rootUrl: string;
  115053. /**
  115054. * Defines the filename of the scene to load from
  115055. */
  115056. sceneFilename: string;
  115057. /**
  115058. * Gets the list of loaded meshes
  115059. */
  115060. loadedMeshes: Array<AbstractMesh>;
  115061. /**
  115062. * Gets the list of loaded particle systems
  115063. */
  115064. loadedParticleSystems: Array<IParticleSystem>;
  115065. /**
  115066. * Gets the list of loaded skeletons
  115067. */
  115068. loadedSkeletons: Array<Skeleton>;
  115069. /**
  115070. * Gets the list of loaded animation groups
  115071. */
  115072. loadedAnimationGroups: Array<AnimationGroup>;
  115073. /**
  115074. * Callback called when the task is successful
  115075. */
  115076. onSuccess: (task: MeshAssetTask) => void;
  115077. /**
  115078. * Callback called when the task is successful
  115079. */
  115080. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115081. /**
  115082. * Creates a new MeshAssetTask
  115083. * @param name defines the name of the task
  115084. * @param meshesNames defines the list of mesh's names you want to load
  115085. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115086. * @param sceneFilename defines the filename of the scene to load from
  115087. */
  115088. constructor(
  115089. /**
  115090. * Defines the name of the task
  115091. */
  115092. name: string,
  115093. /**
  115094. * Defines the list of mesh's names you want to load
  115095. */
  115096. meshesNames: any,
  115097. /**
  115098. * Defines the root url to use as a base to load your meshes and associated resources
  115099. */
  115100. rootUrl: string,
  115101. /**
  115102. * Defines the filename of the scene to load from
  115103. */
  115104. sceneFilename: string);
  115105. /**
  115106. * Execute the current task
  115107. * @param scene defines the scene where you want your assets to be loaded
  115108. * @param onSuccess is a callback called when the task is successfully executed
  115109. * @param onError is a callback called if an error occurs
  115110. */
  115111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115112. }
  115113. /**
  115114. * Define a task used by AssetsManager to load text content
  115115. */
  115116. export class TextFileAssetTask extends AbstractAssetTask {
  115117. /**
  115118. * Defines the name of the task
  115119. */
  115120. name: string;
  115121. /**
  115122. * Defines the location of the file to load
  115123. */
  115124. url: string;
  115125. /**
  115126. * Gets the loaded text string
  115127. */
  115128. text: string;
  115129. /**
  115130. * Callback called when the task is successful
  115131. */
  115132. onSuccess: (task: TextFileAssetTask) => void;
  115133. /**
  115134. * Callback called when the task is successful
  115135. */
  115136. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115137. /**
  115138. * Creates a new TextFileAssetTask object
  115139. * @param name defines the name of the task
  115140. * @param url defines the location of the file to load
  115141. */
  115142. constructor(
  115143. /**
  115144. * Defines the name of the task
  115145. */
  115146. name: string,
  115147. /**
  115148. * Defines the location of the file to load
  115149. */
  115150. url: string);
  115151. /**
  115152. * Execute the current task
  115153. * @param scene defines the scene where you want your assets to be loaded
  115154. * @param onSuccess is a callback called when the task is successfully executed
  115155. * @param onError is a callback called if an error occurs
  115156. */
  115157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115158. }
  115159. /**
  115160. * Define a task used by AssetsManager to load binary data
  115161. */
  115162. export class BinaryFileAssetTask extends AbstractAssetTask {
  115163. /**
  115164. * Defines the name of the task
  115165. */
  115166. name: string;
  115167. /**
  115168. * Defines the location of the file to load
  115169. */
  115170. url: string;
  115171. /**
  115172. * Gets the lodaded data (as an array buffer)
  115173. */
  115174. data: ArrayBuffer;
  115175. /**
  115176. * Callback called when the task is successful
  115177. */
  115178. onSuccess: (task: BinaryFileAssetTask) => void;
  115179. /**
  115180. * Callback called when the task is successful
  115181. */
  115182. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115183. /**
  115184. * Creates a new BinaryFileAssetTask object
  115185. * @param name defines the name of the new task
  115186. * @param url defines the location of the file to load
  115187. */
  115188. constructor(
  115189. /**
  115190. * Defines the name of the task
  115191. */
  115192. name: string,
  115193. /**
  115194. * Defines the location of the file to load
  115195. */
  115196. url: string);
  115197. /**
  115198. * Execute the current task
  115199. * @param scene defines the scene where you want your assets to be loaded
  115200. * @param onSuccess is a callback called when the task is successfully executed
  115201. * @param onError is a callback called if an error occurs
  115202. */
  115203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115204. }
  115205. /**
  115206. * Define a task used by AssetsManager to load images
  115207. */
  115208. export class ImageAssetTask extends AbstractAssetTask {
  115209. /**
  115210. * Defines the name of the task
  115211. */
  115212. name: string;
  115213. /**
  115214. * Defines the location of the image to load
  115215. */
  115216. url: string;
  115217. /**
  115218. * Gets the loaded images
  115219. */
  115220. image: HTMLImageElement;
  115221. /**
  115222. * Callback called when the task is successful
  115223. */
  115224. onSuccess: (task: ImageAssetTask) => void;
  115225. /**
  115226. * Callback called when the task is successful
  115227. */
  115228. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115229. /**
  115230. * Creates a new ImageAssetTask
  115231. * @param name defines the name of the task
  115232. * @param url defines the location of the image to load
  115233. */
  115234. constructor(
  115235. /**
  115236. * Defines the name of the task
  115237. */
  115238. name: string,
  115239. /**
  115240. * Defines the location of the image to load
  115241. */
  115242. url: string);
  115243. /**
  115244. * Execute the current task
  115245. * @param scene defines the scene where you want your assets to be loaded
  115246. * @param onSuccess is a callback called when the task is successfully executed
  115247. * @param onError is a callback called if an error occurs
  115248. */
  115249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115250. }
  115251. /**
  115252. * Defines the interface used by texture loading tasks
  115253. */
  115254. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115255. /**
  115256. * Gets the loaded texture
  115257. */
  115258. texture: TEX;
  115259. }
  115260. /**
  115261. * Define a task used by AssetsManager to load 2D textures
  115262. */
  115263. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115264. /**
  115265. * Defines the name of the task
  115266. */
  115267. name: string;
  115268. /**
  115269. * Defines the location of the file to load
  115270. */
  115271. url: string;
  115272. /**
  115273. * Defines if mipmap should not be generated (default is false)
  115274. */
  115275. noMipmap?: boolean | undefined;
  115276. /**
  115277. * Defines if texture must be inverted on Y axis (default is false)
  115278. */
  115279. invertY?: boolean | undefined;
  115280. /**
  115281. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115282. */
  115283. samplingMode: number;
  115284. /**
  115285. * Gets the loaded texture
  115286. */
  115287. texture: Texture;
  115288. /**
  115289. * Callback called when the task is successful
  115290. */
  115291. onSuccess: (task: TextureAssetTask) => void;
  115292. /**
  115293. * Callback called when the task is successful
  115294. */
  115295. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115296. /**
  115297. * Creates a new TextureAssetTask object
  115298. * @param name defines the name of the task
  115299. * @param url defines the location of the file to load
  115300. * @param noMipmap defines if mipmap should not be generated (default is false)
  115301. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115302. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115303. */
  115304. constructor(
  115305. /**
  115306. * Defines the name of the task
  115307. */
  115308. name: string,
  115309. /**
  115310. * Defines the location of the file to load
  115311. */
  115312. url: string,
  115313. /**
  115314. * Defines if mipmap should not be generated (default is false)
  115315. */
  115316. noMipmap?: boolean | undefined,
  115317. /**
  115318. * Defines if texture must be inverted on Y axis (default is false)
  115319. */
  115320. invertY?: boolean | undefined,
  115321. /**
  115322. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115323. */
  115324. samplingMode?: number);
  115325. /**
  115326. * Execute the current task
  115327. * @param scene defines the scene where you want your assets to be loaded
  115328. * @param onSuccess is a callback called when the task is successfully executed
  115329. * @param onError is a callback called if an error occurs
  115330. */
  115331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115332. }
  115333. /**
  115334. * Define a task used by AssetsManager to load cube textures
  115335. */
  115336. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115337. /**
  115338. * Defines the name of the task
  115339. */
  115340. name: string;
  115341. /**
  115342. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115343. */
  115344. url: string;
  115345. /**
  115346. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115347. */
  115348. extensions?: string[] | undefined;
  115349. /**
  115350. * Defines if mipmaps should not be generated (default is false)
  115351. */
  115352. noMipmap?: boolean | undefined;
  115353. /**
  115354. * Defines the explicit list of files (undefined by default)
  115355. */
  115356. files?: string[] | undefined;
  115357. /**
  115358. * Gets the loaded texture
  115359. */
  115360. texture: CubeTexture;
  115361. /**
  115362. * Callback called when the task is successful
  115363. */
  115364. onSuccess: (task: CubeTextureAssetTask) => void;
  115365. /**
  115366. * Callback called when the task is successful
  115367. */
  115368. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115369. /**
  115370. * Creates a new CubeTextureAssetTask
  115371. * @param name defines the name of the task
  115372. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115373. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115374. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115375. * @param files defines the explicit list of files (undefined by default)
  115376. */
  115377. constructor(
  115378. /**
  115379. * Defines the name of the task
  115380. */
  115381. name: string,
  115382. /**
  115383. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115384. */
  115385. url: string,
  115386. /**
  115387. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115388. */
  115389. extensions?: string[] | undefined,
  115390. /**
  115391. * Defines if mipmaps should not be generated (default is false)
  115392. */
  115393. noMipmap?: boolean | undefined,
  115394. /**
  115395. * Defines the explicit list of files (undefined by default)
  115396. */
  115397. files?: string[] | undefined);
  115398. /**
  115399. * Execute the current task
  115400. * @param scene defines the scene where you want your assets to be loaded
  115401. * @param onSuccess is a callback called when the task is successfully executed
  115402. * @param onError is a callback called if an error occurs
  115403. */
  115404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115405. }
  115406. /**
  115407. * Define a task used by AssetsManager to load HDR cube textures
  115408. */
  115409. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115410. /**
  115411. * Defines the name of the task
  115412. */
  115413. name: string;
  115414. /**
  115415. * Defines the location of the file to load
  115416. */
  115417. url: string;
  115418. /**
  115419. * Defines the desired size (the more it increases the longer the generation will be)
  115420. */
  115421. size: number;
  115422. /**
  115423. * Defines if mipmaps should not be generated (default is false)
  115424. */
  115425. noMipmap: boolean;
  115426. /**
  115427. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115428. */
  115429. generateHarmonics: boolean;
  115430. /**
  115431. * 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)
  115432. */
  115433. gammaSpace: boolean;
  115434. /**
  115435. * Internal Use Only
  115436. */
  115437. reserved: boolean;
  115438. /**
  115439. * Gets the loaded texture
  115440. */
  115441. texture: HDRCubeTexture;
  115442. /**
  115443. * Callback called when the task is successful
  115444. */
  115445. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115446. /**
  115447. * Callback called when the task is successful
  115448. */
  115449. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115450. /**
  115451. * Creates a new HDRCubeTextureAssetTask object
  115452. * @param name defines the name of the task
  115453. * @param url defines the location of the file to load
  115454. * @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.
  115455. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115456. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115457. * @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)
  115458. * @param reserved Internal use only
  115459. */
  115460. constructor(
  115461. /**
  115462. * Defines the name of the task
  115463. */
  115464. name: string,
  115465. /**
  115466. * Defines the location of the file to load
  115467. */
  115468. url: string,
  115469. /**
  115470. * Defines the desired size (the more it increases the longer the generation will be)
  115471. */
  115472. size: number,
  115473. /**
  115474. * Defines if mipmaps should not be generated (default is false)
  115475. */
  115476. noMipmap?: boolean,
  115477. /**
  115478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115479. */
  115480. generateHarmonics?: boolean,
  115481. /**
  115482. * 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)
  115483. */
  115484. gammaSpace?: boolean,
  115485. /**
  115486. * Internal Use Only
  115487. */
  115488. reserved?: boolean);
  115489. /**
  115490. * Execute the current task
  115491. * @param scene defines the scene where you want your assets to be loaded
  115492. * @param onSuccess is a callback called when the task is successfully executed
  115493. * @param onError is a callback called if an error occurs
  115494. */
  115495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115496. }
  115497. /**
  115498. * Define a task used by AssetsManager to load Equirectangular cube textures
  115499. */
  115500. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115501. /**
  115502. * Defines the name of the task
  115503. */
  115504. name: string;
  115505. /**
  115506. * Defines the location of the file to load
  115507. */
  115508. url: string;
  115509. /**
  115510. * Defines the desired size (the more it increases the longer the generation will be)
  115511. */
  115512. size: number;
  115513. /**
  115514. * Defines if mipmaps should not be generated (default is false)
  115515. */
  115516. noMipmap: boolean;
  115517. /**
  115518. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115519. * but the standard material would require them in Gamma space) (default is true)
  115520. */
  115521. gammaSpace: boolean;
  115522. /**
  115523. * Gets the loaded texture
  115524. */
  115525. texture: EquiRectangularCubeTexture;
  115526. /**
  115527. * Callback called when the task is successful
  115528. */
  115529. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115530. /**
  115531. * Callback called when the task is successful
  115532. */
  115533. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115534. /**
  115535. * Creates a new EquiRectangularCubeTextureAssetTask object
  115536. * @param name defines the name of the task
  115537. * @param url defines the location of the file to load
  115538. * @param size defines the desired size (the more it increases the longer the generation will be)
  115539. * If the size is omitted this implies you are using a preprocessed cubemap.
  115540. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115541. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115542. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115543. * (default is true)
  115544. */
  115545. constructor(
  115546. /**
  115547. * Defines the name of the task
  115548. */
  115549. name: string,
  115550. /**
  115551. * Defines the location of the file to load
  115552. */
  115553. url: string,
  115554. /**
  115555. * Defines the desired size (the more it increases the longer the generation will be)
  115556. */
  115557. size: number,
  115558. /**
  115559. * Defines if mipmaps should not be generated (default is false)
  115560. */
  115561. noMipmap?: boolean,
  115562. /**
  115563. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115564. * but the standard material would require them in Gamma space) (default is true)
  115565. */
  115566. gammaSpace?: boolean);
  115567. /**
  115568. * Execute the current task
  115569. * @param scene defines the scene where you want your assets to be loaded
  115570. * @param onSuccess is a callback called when the task is successfully executed
  115571. * @param onError is a callback called if an error occurs
  115572. */
  115573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115574. }
  115575. /**
  115576. * This class can be used to easily import assets into a scene
  115577. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115578. */
  115579. export class AssetsManager {
  115580. private _scene;
  115581. private _isLoading;
  115582. protected _tasks: AbstractAssetTask[];
  115583. protected _waitingTasksCount: number;
  115584. protected _totalTasksCount: number;
  115585. /**
  115586. * Callback called when all tasks are processed
  115587. */
  115588. onFinish: (tasks: AbstractAssetTask[]) => void;
  115589. /**
  115590. * Callback called when a task is successful
  115591. */
  115592. onTaskSuccess: (task: AbstractAssetTask) => void;
  115593. /**
  115594. * Callback called when a task had an error
  115595. */
  115596. onTaskError: (task: AbstractAssetTask) => void;
  115597. /**
  115598. * Callback called when a task is done (whatever the result is)
  115599. */
  115600. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115601. /**
  115602. * Observable called when all tasks are processed
  115603. */
  115604. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115605. /**
  115606. * Observable called when a task had an error
  115607. */
  115608. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115609. /**
  115610. * Observable called when all tasks were executed
  115611. */
  115612. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115613. /**
  115614. * Observable called when a task is done (whatever the result is)
  115615. */
  115616. onProgressObservable: Observable<IAssetsProgressEvent>;
  115617. /**
  115618. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115619. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115620. */
  115621. useDefaultLoadingScreen: boolean;
  115622. /**
  115623. * Creates a new AssetsManager
  115624. * @param scene defines the scene to work on
  115625. */
  115626. constructor(scene: Scene);
  115627. /**
  115628. * Add a MeshAssetTask to the list of active tasks
  115629. * @param taskName defines the name of the new task
  115630. * @param meshesNames defines the name of meshes to load
  115631. * @param rootUrl defines the root url to use to locate files
  115632. * @param sceneFilename defines the filename of the scene file
  115633. * @returns a new MeshAssetTask object
  115634. */
  115635. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115636. /**
  115637. * Add a TextFileAssetTask to the list of active tasks
  115638. * @param taskName defines the name of the new task
  115639. * @param url defines the url of the file to load
  115640. * @returns a new TextFileAssetTask object
  115641. */
  115642. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115643. /**
  115644. * Add a BinaryFileAssetTask 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 BinaryFileAssetTask object
  115648. */
  115649. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115650. /**
  115651. * Add a ImageAssetTask 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 ImageAssetTask object
  115655. */
  115656. addImageTask(taskName: string, url: string): ImageAssetTask;
  115657. /**
  115658. * Add a TextureAssetTask 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. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115662. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115663. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115664. * @returns a new TextureAssetTask object
  115665. */
  115666. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115667. /**
  115668. * Add a CubeTextureAssetTask to the list of active tasks
  115669. * @param taskName defines the name of the new task
  115670. * @param url defines the url of the file to load
  115671. * @param extensions defines the extension to use to load the cube map (can be null)
  115672. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115673. * @param files defines the list of files to load (can be null)
  115674. * @returns a new CubeTextureAssetTask object
  115675. */
  115676. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115677. /**
  115678. *
  115679. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115680. * @param taskName defines the name of the new task
  115681. * @param url defines the url of the file to load
  115682. * @param size defines the size you want for the cubemap (can be null)
  115683. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115684. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115685. * @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)
  115686. * @param reserved Internal use only
  115687. * @returns a new HDRCubeTextureAssetTask object
  115688. */
  115689. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115690. /**
  115691. *
  115692. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115693. * @param taskName defines the name of the new task
  115694. * @param url defines the url of the file to load
  115695. * @param size defines the size you want for the cubemap (can be null)
  115696. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115697. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115698. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115699. * @returns a new EquiRectangularCubeTextureAssetTask object
  115700. */
  115701. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115702. /**
  115703. * Remove a task from the assets manager.
  115704. * @param task the task to remove
  115705. */
  115706. removeTask(task: AbstractAssetTask): void;
  115707. private _decreaseWaitingTasksCount;
  115708. private _runTask;
  115709. /**
  115710. * Reset the AssetsManager and remove all tasks
  115711. * @return the current instance of the AssetsManager
  115712. */
  115713. reset(): AssetsManager;
  115714. /**
  115715. * Start the loading process
  115716. * @return the current instance of the AssetsManager
  115717. */
  115718. load(): AssetsManager;
  115719. /**
  115720. * Start the loading process as an async operation
  115721. * @return a promise returning the list of failed tasks
  115722. */
  115723. loadAsync(): Promise<void>;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. /**
  115728. * Wrapper class for promise with external resolve and reject.
  115729. */
  115730. export class Deferred<T> {
  115731. /**
  115732. * The promise associated with this deferred object.
  115733. */
  115734. readonly promise: Promise<T>;
  115735. private _resolve;
  115736. private _reject;
  115737. /**
  115738. * The resolve method of the promise associated with this deferred object.
  115739. */
  115740. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115741. /**
  115742. * The reject method of the promise associated with this deferred object.
  115743. */
  115744. readonly reject: (reason?: any) => void;
  115745. /**
  115746. * Constructor for this deferred object.
  115747. */
  115748. constructor();
  115749. }
  115750. }
  115751. declare module BABYLON {
  115752. /**
  115753. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115754. */
  115755. export class MeshExploder {
  115756. private _centerMesh;
  115757. private _meshes;
  115758. private _meshesOrigins;
  115759. private _toCenterVectors;
  115760. private _scaledDirection;
  115761. private _newPosition;
  115762. private _centerPosition;
  115763. /**
  115764. * Explodes meshes from a center mesh.
  115765. * @param meshes The meshes to explode.
  115766. * @param centerMesh The mesh to be center of explosion.
  115767. */
  115768. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115769. private _setCenterMesh;
  115770. /**
  115771. * Get class name
  115772. * @returns "MeshExploder"
  115773. */
  115774. getClassName(): string;
  115775. /**
  115776. * "Exploded meshes"
  115777. * @returns Array of meshes with the centerMesh at index 0.
  115778. */
  115779. getMeshes(): Array<Mesh>;
  115780. /**
  115781. * Explodes meshes giving a specific direction
  115782. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115783. */
  115784. explode(direction?: number): void;
  115785. }
  115786. }
  115787. declare module BABYLON {
  115788. /**
  115789. * Class used to help managing file picking and drag'n'drop
  115790. */
  115791. export class FilesInput {
  115792. /**
  115793. * List of files ready to be loaded
  115794. */
  115795. static readonly FilesToLoad: {
  115796. [key: string]: File;
  115797. };
  115798. /**
  115799. * Callback called when a file is processed
  115800. */
  115801. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115802. private _engine;
  115803. private _currentScene;
  115804. private _sceneLoadedCallback;
  115805. private _progressCallback;
  115806. private _additionalRenderLoopLogicCallback;
  115807. private _textureLoadingCallback;
  115808. private _startingProcessingFilesCallback;
  115809. private _onReloadCallback;
  115810. private _errorCallback;
  115811. private _elementToMonitor;
  115812. private _sceneFileToLoad;
  115813. private _filesToLoad;
  115814. /**
  115815. * Creates a new FilesInput
  115816. * @param engine defines the rendering engine
  115817. * @param scene defines the hosting scene
  115818. * @param sceneLoadedCallback callback called when scene is loaded
  115819. * @param progressCallback callback called to track progress
  115820. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115821. * @param textureLoadingCallback callback called when a texture is loading
  115822. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115823. * @param onReloadCallback callback called when a reload is requested
  115824. * @param errorCallback callback call if an error occurs
  115825. */
  115826. 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);
  115827. private _dragEnterHandler;
  115828. private _dragOverHandler;
  115829. private _dropHandler;
  115830. /**
  115831. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115832. * @param elementToMonitor defines the DOM element to track
  115833. */
  115834. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115835. /**
  115836. * Release all associated resources
  115837. */
  115838. dispose(): void;
  115839. private renderFunction;
  115840. private drag;
  115841. private drop;
  115842. private _traverseFolder;
  115843. private _processFiles;
  115844. /**
  115845. * Load files from a drop event
  115846. * @param event defines the drop event to use as source
  115847. */
  115848. loadFiles(event: any): void;
  115849. private _processReload;
  115850. /**
  115851. * Reload the current scene from the loaded files
  115852. */
  115853. reload(): void;
  115854. }
  115855. }
  115856. declare module BABYLON {
  115857. /**
  115858. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115860. */
  115861. export class SceneOptimization {
  115862. /**
  115863. * Defines the priority of this optimization (0 by default which means first in the list)
  115864. */
  115865. priority: number;
  115866. /**
  115867. * Gets a string describing the action executed by the current optimization
  115868. * @returns description string
  115869. */
  115870. getDescription(): string;
  115871. /**
  115872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115873. * @param scene defines the current scene where to apply this optimization
  115874. * @param optimizer defines the current optimizer
  115875. * @returns true if everything that can be done was applied
  115876. */
  115877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115878. /**
  115879. * Creates the SceneOptimization object
  115880. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115881. * @param desc defines the description associated with the optimization
  115882. */
  115883. constructor(
  115884. /**
  115885. * Defines the priority of this optimization (0 by default which means first in the list)
  115886. */
  115887. priority?: number);
  115888. }
  115889. /**
  115890. * Defines an optimization used to reduce the size of render target textures
  115891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115892. */
  115893. export class TextureOptimization extends SceneOptimization {
  115894. /**
  115895. * Defines the priority of this optimization (0 by default which means first in the list)
  115896. */
  115897. priority: number;
  115898. /**
  115899. * 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
  115900. */
  115901. maximumSize: number;
  115902. /**
  115903. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115904. */
  115905. step: number;
  115906. /**
  115907. * Gets a string describing the action executed by the current optimization
  115908. * @returns description string
  115909. */
  115910. getDescription(): string;
  115911. /**
  115912. * Creates the TextureOptimization object
  115913. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115914. * @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
  115915. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115916. */
  115917. constructor(
  115918. /**
  115919. * Defines the priority of this optimization (0 by default which means first in the list)
  115920. */
  115921. priority?: number,
  115922. /**
  115923. * 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
  115924. */
  115925. maximumSize?: number,
  115926. /**
  115927. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115928. */
  115929. step?: number);
  115930. /**
  115931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115932. * @param scene defines the current scene where to apply this optimization
  115933. * @param optimizer defines the current optimizer
  115934. * @returns true if everything that can be done was applied
  115935. */
  115936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115937. }
  115938. /**
  115939. * Defines an optimization used to increase or decrease the rendering resolution
  115940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115941. */
  115942. export class HardwareScalingOptimization extends SceneOptimization {
  115943. /**
  115944. * Defines the priority of this optimization (0 by default which means first in the list)
  115945. */
  115946. priority: number;
  115947. /**
  115948. * Defines the maximum scale to use (2 by default)
  115949. */
  115950. maximumScale: number;
  115951. /**
  115952. * Defines the step to use between two passes (0.5 by default)
  115953. */
  115954. step: number;
  115955. private _currentScale;
  115956. private _directionOffset;
  115957. /**
  115958. * Gets a string describing the action executed by the current optimization
  115959. * @return description string
  115960. */
  115961. getDescription(): string;
  115962. /**
  115963. * Creates the HardwareScalingOptimization object
  115964. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115965. * @param maximumScale defines the maximum scale to use (2 by default)
  115966. * @param step defines the step to use between two passes (0.5 by default)
  115967. */
  115968. constructor(
  115969. /**
  115970. * Defines the priority of this optimization (0 by default which means first in the list)
  115971. */
  115972. priority?: number,
  115973. /**
  115974. * Defines the maximum scale to use (2 by default)
  115975. */
  115976. maximumScale?: number,
  115977. /**
  115978. * Defines the step to use between two passes (0.5 by default)
  115979. */
  115980. step?: number);
  115981. /**
  115982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115983. * @param scene defines the current scene where to apply this optimization
  115984. * @param optimizer defines the current optimizer
  115985. * @returns true if everything that can be done was applied
  115986. */
  115987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115988. }
  115989. /**
  115990. * Defines an optimization used to remove shadows
  115991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115992. */
  115993. export class ShadowsOptimization extends SceneOptimization {
  115994. /**
  115995. * Gets a string describing the action executed by the current optimization
  115996. * @return description string
  115997. */
  115998. getDescription(): string;
  115999. /**
  116000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116001. * @param scene defines the current scene where to apply this optimization
  116002. * @param optimizer defines the current optimizer
  116003. * @returns true if everything that can be done was applied
  116004. */
  116005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116006. }
  116007. /**
  116008. * Defines an optimization used to turn post-processes off
  116009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116010. */
  116011. export class PostProcessesOptimization extends SceneOptimization {
  116012. /**
  116013. * Gets a string describing the action executed by the current optimization
  116014. * @return description string
  116015. */
  116016. getDescription(): string;
  116017. /**
  116018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116019. * @param scene defines the current scene where to apply this optimization
  116020. * @param optimizer defines the current optimizer
  116021. * @returns true if everything that can be done was applied
  116022. */
  116023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116024. }
  116025. /**
  116026. * Defines an optimization used to turn lens flares off
  116027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116028. */
  116029. export class LensFlaresOptimization extends SceneOptimization {
  116030. /**
  116031. * Gets a string describing the action executed by the current optimization
  116032. * @return description string
  116033. */
  116034. getDescription(): string;
  116035. /**
  116036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116037. * @param scene defines the current scene where to apply this optimization
  116038. * @param optimizer defines the current optimizer
  116039. * @returns true if everything that can be done was applied
  116040. */
  116041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116042. }
  116043. /**
  116044. * Defines an optimization based on user defined callback.
  116045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116046. */
  116047. export class CustomOptimization extends SceneOptimization {
  116048. /**
  116049. * Callback called to apply the custom optimization.
  116050. */
  116051. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116052. /**
  116053. * Callback called to get custom description
  116054. */
  116055. onGetDescription: () => string;
  116056. /**
  116057. * Gets a string describing the action executed by the current optimization
  116058. * @returns description string
  116059. */
  116060. getDescription(): string;
  116061. /**
  116062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116063. * @param scene defines the current scene where to apply this optimization
  116064. * @param optimizer defines the current optimizer
  116065. * @returns true if everything that can be done was applied
  116066. */
  116067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116068. }
  116069. /**
  116070. * Defines an optimization used to turn particles off
  116071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116072. */
  116073. export class ParticlesOptimization extends SceneOptimization {
  116074. /**
  116075. * Gets a string describing the action executed by the current optimization
  116076. * @return description string
  116077. */
  116078. getDescription(): string;
  116079. /**
  116080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116081. * @param scene defines the current scene where to apply this optimization
  116082. * @param optimizer defines the current optimizer
  116083. * @returns true if everything that can be done was applied
  116084. */
  116085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116086. }
  116087. /**
  116088. * Defines an optimization used to turn render targets off
  116089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116090. */
  116091. export class RenderTargetsOptimization extends SceneOptimization {
  116092. /**
  116093. * Gets a string describing the action executed by the current optimization
  116094. * @return description string
  116095. */
  116096. getDescription(): string;
  116097. /**
  116098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116099. * @param scene defines the current scene where to apply this optimization
  116100. * @param optimizer defines the current optimizer
  116101. * @returns true if everything that can be done was applied
  116102. */
  116103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116104. }
  116105. /**
  116106. * Defines an optimization used to merge meshes with compatible materials
  116107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116108. */
  116109. export class MergeMeshesOptimization extends SceneOptimization {
  116110. private static _UpdateSelectionTree;
  116111. /**
  116112. * Gets or sets a boolean which defines if optimization octree has to be updated
  116113. */
  116114. /**
  116115. * Gets or sets a boolean which defines if optimization octree has to be updated
  116116. */
  116117. static UpdateSelectionTree: boolean;
  116118. /**
  116119. * Gets a string describing the action executed by the current optimization
  116120. * @return description string
  116121. */
  116122. getDescription(): string;
  116123. private _canBeMerged;
  116124. /**
  116125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116126. * @param scene defines the current scene where to apply this optimization
  116127. * @param optimizer defines the current optimizer
  116128. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116129. * @returns true if everything that can be done was applied
  116130. */
  116131. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116132. }
  116133. /**
  116134. * Defines a list of options used by SceneOptimizer
  116135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116136. */
  116137. export class SceneOptimizerOptions {
  116138. /**
  116139. * Defines the target frame rate to reach (60 by default)
  116140. */
  116141. targetFrameRate: number;
  116142. /**
  116143. * Defines the interval between two checkes (2000ms by default)
  116144. */
  116145. trackerDuration: number;
  116146. /**
  116147. * Gets the list of optimizations to apply
  116148. */
  116149. optimizations: SceneOptimization[];
  116150. /**
  116151. * Creates a new list of options used by SceneOptimizer
  116152. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116153. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116154. */
  116155. constructor(
  116156. /**
  116157. * Defines the target frame rate to reach (60 by default)
  116158. */
  116159. targetFrameRate?: number,
  116160. /**
  116161. * Defines the interval between two checkes (2000ms by default)
  116162. */
  116163. trackerDuration?: number);
  116164. /**
  116165. * Add a new optimization
  116166. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116167. * @returns the current SceneOptimizerOptions
  116168. */
  116169. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116170. /**
  116171. * Add a new custom optimization
  116172. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116173. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116174. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116175. * @returns the current SceneOptimizerOptions
  116176. */
  116177. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116178. /**
  116179. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116180. * @param targetFrameRate defines the target frame rate (60 by default)
  116181. * @returns a SceneOptimizerOptions object
  116182. */
  116183. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116184. /**
  116185. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116186. * @param targetFrameRate defines the target frame rate (60 by default)
  116187. * @returns a SceneOptimizerOptions object
  116188. */
  116189. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116190. /**
  116191. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116192. * @param targetFrameRate defines the target frame rate (60 by default)
  116193. * @returns a SceneOptimizerOptions object
  116194. */
  116195. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116196. }
  116197. /**
  116198. * Class used to run optimizations in order to reach a target frame rate
  116199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116200. */
  116201. export class SceneOptimizer implements IDisposable {
  116202. private _isRunning;
  116203. private _options;
  116204. private _scene;
  116205. private _currentPriorityLevel;
  116206. private _targetFrameRate;
  116207. private _trackerDuration;
  116208. private _currentFrameRate;
  116209. private _sceneDisposeObserver;
  116210. private _improvementMode;
  116211. /**
  116212. * Defines an observable called when the optimizer reaches the target frame rate
  116213. */
  116214. onSuccessObservable: Observable<SceneOptimizer>;
  116215. /**
  116216. * Defines an observable called when the optimizer enables an optimization
  116217. */
  116218. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116219. /**
  116220. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116221. */
  116222. onFailureObservable: Observable<SceneOptimizer>;
  116223. /**
  116224. * Gets a boolean indicating if the optimizer is in improvement mode
  116225. */
  116226. readonly isInImprovementMode: boolean;
  116227. /**
  116228. * Gets the current priority level (0 at start)
  116229. */
  116230. readonly currentPriorityLevel: number;
  116231. /**
  116232. * Gets the current frame rate checked by the SceneOptimizer
  116233. */
  116234. readonly currentFrameRate: number;
  116235. /**
  116236. * Gets or sets the current target frame rate (60 by default)
  116237. */
  116238. /**
  116239. * Gets or sets the current target frame rate (60 by default)
  116240. */
  116241. targetFrameRate: number;
  116242. /**
  116243. * Gets or sets the current interval between two checks (every 2000ms by default)
  116244. */
  116245. /**
  116246. * Gets or sets the current interval between two checks (every 2000ms by default)
  116247. */
  116248. trackerDuration: number;
  116249. /**
  116250. * Gets the list of active optimizations
  116251. */
  116252. readonly optimizations: SceneOptimization[];
  116253. /**
  116254. * Creates a new SceneOptimizer
  116255. * @param scene defines the scene to work on
  116256. * @param options defines the options to use with the SceneOptimizer
  116257. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116258. * @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)
  116259. */
  116260. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116261. /**
  116262. * Stops the current optimizer
  116263. */
  116264. stop(): void;
  116265. /**
  116266. * Reset the optimizer to initial step (current priority level = 0)
  116267. */
  116268. reset(): void;
  116269. /**
  116270. * Start the optimizer. By default it will try to reach a specific framerate
  116271. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116272. */
  116273. start(): void;
  116274. private _checkCurrentState;
  116275. /**
  116276. * Release all resources
  116277. */
  116278. dispose(): void;
  116279. /**
  116280. * Helper function to create a SceneOptimizer with one single line of code
  116281. * @param scene defines the scene to work on
  116282. * @param options defines the options to use with the SceneOptimizer
  116283. * @param onSuccess defines a callback to call on success
  116284. * @param onFailure defines a callback to call on failure
  116285. * @returns the new SceneOptimizer object
  116286. */
  116287. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116288. }
  116289. }
  116290. declare module BABYLON {
  116291. /**
  116292. * Class used to serialize a scene into a string
  116293. */
  116294. export class SceneSerializer {
  116295. /**
  116296. * Clear cache used by a previous serialization
  116297. */
  116298. static ClearCache(): void;
  116299. /**
  116300. * Serialize a scene into a JSON compatible object
  116301. * @param scene defines the scene to serialize
  116302. * @returns a JSON compatible object
  116303. */
  116304. static Serialize(scene: Scene): any;
  116305. /**
  116306. * Serialize a mesh into a JSON compatible object
  116307. * @param toSerialize defines the mesh to serialize
  116308. * @param withParents defines if parents must be serialized as well
  116309. * @param withChildren defines if children must be serialized as well
  116310. * @returns a JSON compatible object
  116311. */
  116312. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116313. }
  116314. }
  116315. declare module BABYLON {
  116316. /**
  116317. * Class used to host texture specific utilities
  116318. */
  116319. export class TextureTools {
  116320. /**
  116321. * Uses the GPU to create a copy texture rescaled at a given size
  116322. * @param texture Texture to copy from
  116323. * @param width defines the desired width
  116324. * @param height defines the desired height
  116325. * @param useBilinearMode defines if bilinear mode has to be used
  116326. * @return the generated texture
  116327. */
  116328. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116329. }
  116330. }
  116331. declare module BABYLON {
  116332. /**
  116333. * This represents the different options avilable for the video capture.
  116334. */
  116335. export interface VideoRecorderOptions {
  116336. /** Defines the mime type of the video */
  116337. mimeType: string;
  116338. /** Defines the video the video should be recorded at */
  116339. fps: number;
  116340. /** Defines the chunk size for the recording data */
  116341. recordChunckSize: number;
  116342. /** The audio tracks to attach to the record */
  116343. audioTracks?: MediaStreamTrack[];
  116344. }
  116345. /**
  116346. * This can helps recording videos from BabylonJS.
  116347. * This is based on the available WebRTC functionalities of the browser.
  116348. *
  116349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116350. */
  116351. export class VideoRecorder {
  116352. private static readonly _defaultOptions;
  116353. /**
  116354. * Returns wehther or not the VideoRecorder is available in your browser.
  116355. * @param engine Defines the Babylon Engine to check the support for
  116356. * @returns true if supported otherwise false
  116357. */
  116358. static IsSupported(engine: Engine): boolean;
  116359. private readonly _options;
  116360. private _canvas;
  116361. private _mediaRecorder;
  116362. private _recordedChunks;
  116363. private _fileName;
  116364. private _resolve;
  116365. private _reject;
  116366. /**
  116367. * True wether a recording is already in progress.
  116368. */
  116369. readonly isRecording: boolean;
  116370. /**
  116371. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116372. * a video file.
  116373. * @param engine Defines the BabylonJS Engine you wish to record
  116374. * @param options Defines options that can be used to customized the capture
  116375. */
  116376. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116377. /**
  116378. * Stops the current recording before the default capture timeout passed in the startRecording
  116379. * functions.
  116380. */
  116381. stopRecording(): void;
  116382. /**
  116383. * Starts recording the canvas for a max duration specified in parameters.
  116384. * @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.
  116385. * @param maxDuration Defines the maximum recording time in seconds.
  116386. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116387. * @return a promise callback at the end of the recording with the video data in Blob.
  116388. */
  116389. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116390. /**
  116391. * Releases internal resources used during the recording.
  116392. */
  116393. dispose(): void;
  116394. private _handleDataAvailable;
  116395. private _handleError;
  116396. private _handleStop;
  116397. }
  116398. }
  116399. declare module BABYLON {
  116400. /**
  116401. * Class containing a set of static utilities functions for screenshots
  116402. */
  116403. export class ScreenshotTools {
  116404. /**
  116405. * Captures a screenshot of the current rendering
  116406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116407. * @param engine defines the rendering engine
  116408. * @param camera defines the source camera
  116409. * @param size This parameter can be set to a single number or to an object with the
  116410. * following (optional) properties: precision, width, height. If a single number is passed,
  116411. * it will be used for both width and height. If an object is passed, the screenshot size
  116412. * will be derived from the parameters. The precision property is a multiplier allowing
  116413. * rendering at a higher or lower resolution
  116414. * @param successCallback defines the callback receives a single parameter which contains the
  116415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116416. * src parameter of an <img> to display it
  116417. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116418. * Check your browser for supported MIME types
  116419. */
  116420. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116421. /**
  116422. * Generates an image screenshot from the specified camera.
  116423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116424. * @param engine The engine to use for rendering
  116425. * @param camera The camera to use for rendering
  116426. * @param size This parameter can be set to a single number or to an object with the
  116427. * following (optional) properties: precision, width, height. If a single number is passed,
  116428. * it will be used for both width and height. If an object is passed, the screenshot size
  116429. * will be derived from the parameters. The precision property is a multiplier allowing
  116430. * rendering at a higher or lower resolution
  116431. * @param successCallback The callback receives a single parameter which contains the
  116432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116433. * src parameter of an <img> to display it
  116434. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116435. * Check your browser for supported MIME types
  116436. * @param samples Texture samples (default: 1)
  116437. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116438. * @param fileName A name for for the downloaded file.
  116439. */
  116440. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116441. }
  116442. }
  116443. declare module BABYLON {
  116444. /**
  116445. * A cursor which tracks a point on a path
  116446. */
  116447. export class PathCursor {
  116448. private path;
  116449. /**
  116450. * Stores path cursor callbacks for when an onchange event is triggered
  116451. */
  116452. private _onchange;
  116453. /**
  116454. * The value of the path cursor
  116455. */
  116456. value: number;
  116457. /**
  116458. * The animation array of the path cursor
  116459. */
  116460. animations: Animation[];
  116461. /**
  116462. * Initializes the path cursor
  116463. * @param path The path to track
  116464. */
  116465. constructor(path: Path2);
  116466. /**
  116467. * Gets the cursor point on the path
  116468. * @returns A point on the path cursor at the cursor location
  116469. */
  116470. getPoint(): Vector3;
  116471. /**
  116472. * Moves the cursor ahead by the step amount
  116473. * @param step The amount to move the cursor forward
  116474. * @returns This path cursor
  116475. */
  116476. moveAhead(step?: number): PathCursor;
  116477. /**
  116478. * Moves the cursor behind by the step amount
  116479. * @param step The amount to move the cursor back
  116480. * @returns This path cursor
  116481. */
  116482. moveBack(step?: number): PathCursor;
  116483. /**
  116484. * Moves the cursor by the step amount
  116485. * If the step amount is greater than one, an exception is thrown
  116486. * @param step The amount to move the cursor
  116487. * @returns This path cursor
  116488. */
  116489. move(step: number): PathCursor;
  116490. /**
  116491. * Ensures that the value is limited between zero and one
  116492. * @returns This path cursor
  116493. */
  116494. private ensureLimits;
  116495. /**
  116496. * Runs onchange callbacks on change (used by the animation engine)
  116497. * @returns This path cursor
  116498. */
  116499. private raiseOnChange;
  116500. /**
  116501. * Executes a function on change
  116502. * @param f A path cursor onchange callback
  116503. * @returns This path cursor
  116504. */
  116505. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116506. }
  116507. }
  116508. declare module BABYLON {
  116509. /** @hidden */
  116510. export var blurPixelShader: {
  116511. name: string;
  116512. shader: string;
  116513. };
  116514. }
  116515. declare module BABYLON {
  116516. /** @hidden */
  116517. export var bones300Declaration: {
  116518. name: string;
  116519. shader: string;
  116520. };
  116521. }
  116522. declare module BABYLON {
  116523. /** @hidden */
  116524. export var instances300Declaration: {
  116525. name: string;
  116526. shader: string;
  116527. };
  116528. }
  116529. declare module BABYLON {
  116530. /** @hidden */
  116531. export var pointCloudVertexDeclaration: {
  116532. name: string;
  116533. shader: string;
  116534. };
  116535. }
  116536. // Mixins
  116537. interface Window {
  116538. mozIndexedDB: IDBFactory;
  116539. webkitIndexedDB: IDBFactory;
  116540. msIndexedDB: IDBFactory;
  116541. webkitURL: typeof URL;
  116542. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116543. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116544. WebGLRenderingContext: WebGLRenderingContext;
  116545. MSGesture: MSGesture;
  116546. CANNON: any;
  116547. AudioContext: AudioContext;
  116548. webkitAudioContext: AudioContext;
  116549. PointerEvent: any;
  116550. Math: Math;
  116551. Uint8Array: Uint8ArrayConstructor;
  116552. Float32Array: Float32ArrayConstructor;
  116553. mozURL: typeof URL;
  116554. msURL: typeof URL;
  116555. VRFrameData: any; // WebVR, from specs 1.1
  116556. DracoDecoderModule: any;
  116557. setImmediate(handler: (...args: any[]) => void): number;
  116558. }
  116559. interface HTMLCanvasElement {
  116560. requestPointerLock(): void;
  116561. msRequestPointerLock?(): void;
  116562. mozRequestPointerLock?(): void;
  116563. webkitRequestPointerLock?(): void;
  116564. /** Track wether a record is in progress */
  116565. isRecording: boolean;
  116566. /** Capture Stream method defined by some browsers */
  116567. captureStream(fps?: number): MediaStream;
  116568. }
  116569. interface CanvasRenderingContext2D {
  116570. msImageSmoothingEnabled: boolean;
  116571. }
  116572. interface MouseEvent {
  116573. mozMovementX: number;
  116574. mozMovementY: number;
  116575. webkitMovementX: number;
  116576. webkitMovementY: number;
  116577. msMovementX: number;
  116578. msMovementY: number;
  116579. }
  116580. interface Navigator {
  116581. mozGetVRDevices: (any: any) => any;
  116582. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116583. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116584. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116585. webkitGetGamepads(): Gamepad[];
  116586. msGetGamepads(): Gamepad[];
  116587. webkitGamepads(): Gamepad[];
  116588. }
  116589. interface HTMLVideoElement {
  116590. mozSrcObject: any;
  116591. }
  116592. interface Math {
  116593. fround(x: number): number;
  116594. imul(a: number, b: number): number;
  116595. }
  116596. interface WebGLRenderingContext {
  116597. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116598. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116599. vertexAttribDivisor(index: number, divisor: number): void;
  116600. createVertexArray(): any;
  116601. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116602. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116603. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116604. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116605. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116606. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116607. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116608. // Queries
  116609. createQuery(): WebGLQuery;
  116610. deleteQuery(query: WebGLQuery): void;
  116611. beginQuery(target: number, query: WebGLQuery): void;
  116612. endQuery(target: number): void;
  116613. getQueryParameter(query: WebGLQuery, pname: number): any;
  116614. getQuery(target: number, pname: number): any;
  116615. MAX_SAMPLES: number;
  116616. RGBA8: number;
  116617. READ_FRAMEBUFFER: number;
  116618. DRAW_FRAMEBUFFER: number;
  116619. UNIFORM_BUFFER: number;
  116620. HALF_FLOAT_OES: number;
  116621. RGBA16F: number;
  116622. RGBA32F: number;
  116623. R32F: number;
  116624. RG32F: number;
  116625. RGB32F: number;
  116626. R16F: number;
  116627. RG16F: number;
  116628. RGB16F: number;
  116629. RED: number;
  116630. RG: number;
  116631. R8: number;
  116632. RG8: number;
  116633. UNSIGNED_INT_24_8: number;
  116634. DEPTH24_STENCIL8: number;
  116635. /* Multiple Render Targets */
  116636. drawBuffers(buffers: number[]): void;
  116637. readBuffer(src: number): void;
  116638. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116639. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116640. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116641. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116642. // Occlusion Query
  116643. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116644. ANY_SAMPLES_PASSED: number;
  116645. QUERY_RESULT_AVAILABLE: number;
  116646. QUERY_RESULT: number;
  116647. }
  116648. interface WebGLProgram {
  116649. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116650. }
  116651. interface EXT_disjoint_timer_query {
  116652. QUERY_COUNTER_BITS_EXT: number;
  116653. TIME_ELAPSED_EXT: number;
  116654. TIMESTAMP_EXT: number;
  116655. GPU_DISJOINT_EXT: number;
  116656. QUERY_RESULT_EXT: number;
  116657. QUERY_RESULT_AVAILABLE_EXT: number;
  116658. queryCounterEXT(query: WebGLQuery, target: number): void;
  116659. createQueryEXT(): WebGLQuery;
  116660. beginQueryEXT(target: number, query: WebGLQuery): void;
  116661. endQueryEXT(target: number): void;
  116662. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116663. deleteQueryEXT(query: WebGLQuery): void;
  116664. }
  116665. interface WebGLUniformLocation {
  116666. _currentState: any;
  116667. }
  116668. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116669. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116670. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116671. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116672. interface WebGLRenderingContext {
  116673. readonly RASTERIZER_DISCARD: number;
  116674. readonly DEPTH_COMPONENT24: number;
  116675. readonly TEXTURE_3D: number;
  116676. readonly TEXTURE_2D_ARRAY: number;
  116677. readonly TEXTURE_COMPARE_FUNC: number;
  116678. readonly TEXTURE_COMPARE_MODE: number;
  116679. readonly COMPARE_REF_TO_TEXTURE: number;
  116680. readonly TEXTURE_WRAP_R: number;
  116681. readonly HALF_FLOAT: number;
  116682. readonly RGB8: number;
  116683. readonly RED_INTEGER: number;
  116684. readonly RG_INTEGER: number;
  116685. readonly RGB_INTEGER: number;
  116686. readonly RGBA_INTEGER: number;
  116687. readonly R8_SNORM: number;
  116688. readonly RG8_SNORM: number;
  116689. readonly RGB8_SNORM: number;
  116690. readonly RGBA8_SNORM: number;
  116691. readonly R8I: number;
  116692. readonly RG8I: number;
  116693. readonly RGB8I: number;
  116694. readonly RGBA8I: number;
  116695. readonly R8UI: number;
  116696. readonly RG8UI: number;
  116697. readonly RGB8UI: number;
  116698. readonly RGBA8UI: number;
  116699. readonly R16I: number;
  116700. readonly RG16I: number;
  116701. readonly RGB16I: number;
  116702. readonly RGBA16I: number;
  116703. readonly R16UI: number;
  116704. readonly RG16UI: number;
  116705. readonly RGB16UI: number;
  116706. readonly RGBA16UI: number;
  116707. readonly R32I: number;
  116708. readonly RG32I: number;
  116709. readonly RGB32I: number;
  116710. readonly RGBA32I: number;
  116711. readonly R32UI: number;
  116712. readonly RG32UI: number;
  116713. readonly RGB32UI: number;
  116714. readonly RGBA32UI: number;
  116715. readonly RGB10_A2UI: number;
  116716. readonly R11F_G11F_B10F: number;
  116717. readonly RGB9_E5: number;
  116718. readonly RGB10_A2: number;
  116719. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116720. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116721. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116722. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116723. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116724. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116725. 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;
  116726. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116727. readonly TRANSFORM_FEEDBACK: number;
  116728. readonly INTERLEAVED_ATTRIBS: number;
  116729. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116730. createTransformFeedback(): WebGLTransformFeedback;
  116731. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116732. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116733. beginTransformFeedback(primitiveMode: number): void;
  116734. endTransformFeedback(): void;
  116735. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116736. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116737. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116738. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116739. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116740. }
  116741. interface ImageBitmap {
  116742. readonly width: number;
  116743. readonly height: number;
  116744. close(): void;
  116745. }
  116746. interface WebGLQuery extends WebGLObject {
  116747. }
  116748. declare var WebGLQuery: {
  116749. prototype: WebGLQuery;
  116750. new(): WebGLQuery;
  116751. };
  116752. interface WebGLSampler extends WebGLObject {
  116753. }
  116754. declare var WebGLSampler: {
  116755. prototype: WebGLSampler;
  116756. new(): WebGLSampler;
  116757. };
  116758. interface WebGLSync extends WebGLObject {
  116759. }
  116760. declare var WebGLSync: {
  116761. prototype: WebGLSync;
  116762. new(): WebGLSync;
  116763. };
  116764. interface WebGLTransformFeedback extends WebGLObject {
  116765. }
  116766. declare var WebGLTransformFeedback: {
  116767. prototype: WebGLTransformFeedback;
  116768. new(): WebGLTransformFeedback;
  116769. };
  116770. interface WebGLVertexArrayObject extends WebGLObject {
  116771. }
  116772. declare var WebGLVertexArrayObject: {
  116773. prototype: WebGLVertexArrayObject;
  116774. new(): WebGLVertexArrayObject;
  116775. };
  116776. // Type definitions for WebVR API
  116777. // Project: https://w3c.github.io/webvr/
  116778. // Definitions by: six a <https://github.com/lostfictions>
  116779. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116780. interface VRDisplay extends EventTarget {
  116781. /**
  116782. * Dictionary of capabilities describing the VRDisplay.
  116783. */
  116784. readonly capabilities: VRDisplayCapabilities;
  116785. /**
  116786. * z-depth defining the far plane of the eye view frustum
  116787. * enables mapping of values in the render target depth
  116788. * attachment to scene coordinates. Initially set to 10000.0.
  116789. */
  116790. depthFar: number;
  116791. /**
  116792. * z-depth defining the near plane of the eye view frustum
  116793. * enables mapping of values in the render target depth
  116794. * attachment to scene coordinates. Initially set to 0.01.
  116795. */
  116796. depthNear: number;
  116797. /**
  116798. * An identifier for this distinct VRDisplay. Used as an
  116799. * association point in the Gamepad API.
  116800. */
  116801. readonly displayId: number;
  116802. /**
  116803. * A display name, a user-readable name identifying it.
  116804. */
  116805. readonly displayName: string;
  116806. readonly isConnected: boolean;
  116807. readonly isPresenting: boolean;
  116808. /**
  116809. * If this VRDisplay supports room-scale experiences, the optional
  116810. * stage attribute contains details on the room-scale parameters.
  116811. */
  116812. readonly stageParameters: VRStageParameters | null;
  116813. /**
  116814. * Passing the value returned by `requestAnimationFrame` to
  116815. * `cancelAnimationFrame` will unregister the callback.
  116816. * @param handle Define the hanle of the request to cancel
  116817. */
  116818. cancelAnimationFrame(handle: number): void;
  116819. /**
  116820. * Stops presenting to the VRDisplay.
  116821. * @returns a promise to know when it stopped
  116822. */
  116823. exitPresent(): Promise<void>;
  116824. /**
  116825. * Return the current VREyeParameters for the given eye.
  116826. * @param whichEye Define the eye we want the parameter for
  116827. * @returns the eye parameters
  116828. */
  116829. getEyeParameters(whichEye: string): VREyeParameters;
  116830. /**
  116831. * Populates the passed VRFrameData with the information required to render
  116832. * the current frame.
  116833. * @param frameData Define the data structure to populate
  116834. * @returns true if ok otherwise false
  116835. */
  116836. getFrameData(frameData: VRFrameData): boolean;
  116837. /**
  116838. * Get the layers currently being presented.
  116839. * @returns the list of VR layers
  116840. */
  116841. getLayers(): VRLayer[];
  116842. /**
  116843. * Return a VRPose containing the future predicted pose of the VRDisplay
  116844. * when the current frame will be presented. The value returned will not
  116845. * change until JavaScript has returned control to the browser.
  116846. *
  116847. * The VRPose will contain the position, orientation, velocity,
  116848. * and acceleration of each of these properties.
  116849. * @returns the pose object
  116850. */
  116851. getPose(): VRPose;
  116852. /**
  116853. * Return the current instantaneous pose of the VRDisplay, with no
  116854. * prediction applied.
  116855. * @returns the current instantaneous pose
  116856. */
  116857. getImmediatePose(): VRPose;
  116858. /**
  116859. * The callback passed to `requestAnimationFrame` will be called
  116860. * any time a new frame should be rendered. When the VRDisplay is
  116861. * presenting the callback will be called at the native refresh
  116862. * rate of the HMD. When not presenting this function acts
  116863. * identically to how window.requestAnimationFrame acts. Content should
  116864. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116865. * asynchronously from other displays and at differing refresh rates.
  116866. * @param callback Define the eaction to run next frame
  116867. * @returns the request handle it
  116868. */
  116869. requestAnimationFrame(callback: FrameRequestCallback): number;
  116870. /**
  116871. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116872. * Repeat calls while already presenting will update the VRLayers being displayed.
  116873. * @param layers Define the list of layer to present
  116874. * @returns a promise to know when the request has been fulfilled
  116875. */
  116876. requestPresent(layers: VRLayer[]): Promise<void>;
  116877. /**
  116878. * Reset the pose for this display, treating its current position and
  116879. * orientation as the "origin/zero" values. VRPose.position,
  116880. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116881. * updated when calling resetPose(). This should be called in only
  116882. * sitting-space experiences.
  116883. */
  116884. resetPose(): void;
  116885. /**
  116886. * The VRLayer provided to the VRDisplay will be captured and presented
  116887. * in the HMD. Calling this function has the same effect on the source
  116888. * canvas as any other operation that uses its source image, and canvases
  116889. * created without preserveDrawingBuffer set to true will be cleared.
  116890. * @param pose Define the pose to submit
  116891. */
  116892. submitFrame(pose?: VRPose): void;
  116893. }
  116894. declare var VRDisplay: {
  116895. prototype: VRDisplay;
  116896. new(): VRDisplay;
  116897. };
  116898. interface VRLayer {
  116899. leftBounds?: number[] | Float32Array | null;
  116900. rightBounds?: number[] | Float32Array | null;
  116901. source?: HTMLCanvasElement | null;
  116902. }
  116903. interface VRDisplayCapabilities {
  116904. readonly canPresent: boolean;
  116905. readonly hasExternalDisplay: boolean;
  116906. readonly hasOrientation: boolean;
  116907. readonly hasPosition: boolean;
  116908. readonly maxLayers: number;
  116909. }
  116910. interface VREyeParameters {
  116911. /** @deprecated */
  116912. readonly fieldOfView: VRFieldOfView;
  116913. readonly offset: Float32Array;
  116914. readonly renderHeight: number;
  116915. readonly renderWidth: number;
  116916. }
  116917. interface VRFieldOfView {
  116918. readonly downDegrees: number;
  116919. readonly leftDegrees: number;
  116920. readonly rightDegrees: number;
  116921. readonly upDegrees: number;
  116922. }
  116923. interface VRFrameData {
  116924. readonly leftProjectionMatrix: Float32Array;
  116925. readonly leftViewMatrix: Float32Array;
  116926. readonly pose: VRPose;
  116927. readonly rightProjectionMatrix: Float32Array;
  116928. readonly rightViewMatrix: Float32Array;
  116929. readonly timestamp: number;
  116930. }
  116931. interface VRPose {
  116932. readonly angularAcceleration: Float32Array | null;
  116933. readonly angularVelocity: Float32Array | null;
  116934. readonly linearAcceleration: Float32Array | null;
  116935. readonly linearVelocity: Float32Array | null;
  116936. readonly orientation: Float32Array | null;
  116937. readonly position: Float32Array | null;
  116938. readonly timestamp: number;
  116939. }
  116940. interface VRStageParameters {
  116941. sittingToStandingTransform?: Float32Array;
  116942. sizeX?: number;
  116943. sizeY?: number;
  116944. }
  116945. interface Navigator {
  116946. getVRDisplays(): Promise<VRDisplay[]>;
  116947. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116948. }
  116949. interface Window {
  116950. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116951. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116952. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116953. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116954. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116955. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116956. }
  116957. interface Gamepad {
  116958. readonly displayId: number;
  116959. }
  116960. interface XRDevice {
  116961. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116962. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116963. }
  116964. interface XRSession {
  116965. getInputSources(): Array<any>;
  116966. baseLayer: XRWebGLLayer;
  116967. requestFrameOfReference(type: string): Promise<void>;
  116968. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116969. end(): Promise<void>;
  116970. requestAnimationFrame: Function;
  116971. addEventListener: Function;
  116972. }
  116973. interface XRSessionCreationOptions {
  116974. outputContext?: WebGLRenderingContext | null;
  116975. immersive?: boolean;
  116976. environmentIntegration?: boolean;
  116977. }
  116978. interface XRLayer {
  116979. getViewport: Function;
  116980. framebufferWidth: number;
  116981. framebufferHeight: number;
  116982. }
  116983. interface XRView {
  116984. projectionMatrix: Float32Array;
  116985. }
  116986. interface XRFrame {
  116987. getDevicePose: Function;
  116988. getInputPose: Function;
  116989. views: Array<XRView>;
  116990. baseLayer: XRLayer;
  116991. }
  116992. interface XRFrameOfReference {
  116993. }
  116994. interface XRWebGLLayer extends XRLayer {
  116995. framebuffer: WebGLFramebuffer;
  116996. }
  116997. declare var XRWebGLLayer: {
  116998. prototype: XRWebGLLayer;
  116999. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117000. };